swc/.github/workflows/cargo.yml

585 lines
19 KiB
YAML
Raw Normal View History

name: Cargo
on: [push, pull_request]
2020-02-18 05:36:56 +03:00
#on:
# push:
# # Ignore commits created by bors
# branches-ignore:
# - 'staging'
# - 'trying'
# pull_request:
# branches-ignore:
# - 'staging'
# - 'trying'
env:
CARGO_INCREMENTAL: 0
RUST_LOG: "debug"
DIFF: 0
# https://github.com/swc-project/swc/pull/3742
RUST_MIN_STACK: 4194304
CI: 1
CARGO_TERM_COLOR: "always"
jobs:
check-license:
name: Check license
runs-on: ubuntu-latest
2022-05-08 11:55:51 +03:00
if: >-
${{ !contains(github.event.head_commit.message, 'chore: ') }}
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
- name: Install cargo-deny
uses: baptiste0928/cargo-install@v1.1.0
with:
crate: cargo-deny
version: "0.11.3"
- name: Check licenses
run: |
cargo deny check
check:
name: Check
runs-on: ${{ matrix.os }}
2022-05-08 11:55:51 +03:00
if: >-
${{ !contains(github.event.head_commit.message, 'chore: ') }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
2022-07-25 07:48:01 +03:00
- macos-latest
- windows-latest
steps:
- uses: actions/checkout@v3
2021-12-27 11:32:47 +03:00
with:
submodules: true
2021-11-10 12:08:45 +03:00
2021-03-25 19:22:09 +03:00
# We explicitly do this to cache properly.
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
2022-09-14 13:33:49 +03:00
# MSRV is current stable for ES crates and nightly for other languages
# toolchain: stable
# override: true
2021-03-25 19:22:09 +03:00
- uses: actions/setup-node@v3
with:
node-version: "18"
cache: "yarn"
- name: Install node dependencies
shell: bash
run: |
yarn
# Ensure that all components are compilable.
- name: Run cargo check for all targets
run: cargo check --all --all-targets
test:
name: Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }}
2022-09-06 19:47:06 +03:00
runs-on: ${{ matrix.settings.runner }}
if: >-
${{ !contains(github.event.head_commit.message, 'chore: ') }}
strategy:
fail-fast: false
matrix:
settings:
# Use scripts/github/create-matrix.sh to create this.
- crate: ast_node
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: better_scoped_tls
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: binding_macros
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: dbg-swc
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: enum_kind
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: from_variant
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: jsdoc
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: preset_env_base
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: string_enum
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-02-24 09:06:03 +03:00
check: |
cargo hack check --feature-powerset --no-dev-deps --exclude-features debug --exclude-features plugin --exclude-features plugin_transform_schema_v1 --exclude-features plugin_transform_schema_vtest --exclude-features plugin-bytecheck
- crate: swc
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_atoms
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_bundler
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-02-24 09:06:03 +03:00
check: |
cargo hack check --feature-powerset --no-dev-deps
- crate: swc_cached
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_common
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-02-24 09:06:03 +03:00
check: |
cargo hack check --feature-powerset --no-dev-deps --exclude-features plugin_transform_schema_vtest --exclude-features __plugin --exclude-features __plugin_mode --exclude-features __plugin_rt --exclude-features __rkyv --exclude-features plugin-bytecheck-base --exclude-features plugin-bytecheck-mode --exclude-features plugin-bytecheck-rt --exclude-features rkyv-bytecheck-impl --exclude-features rkyv-impl
- crate: swc_common
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_config
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_config_macro
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_core
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_css
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_css_ast
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_css_codegen
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_css_codegen
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_css_codegen_macros
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_css_lints
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_css_minifier
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_css_parser
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_css_parser
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_css_prefixer
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_css_utils
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_css_visit
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_ast
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-02-24 09:06:03 +03:00
check: |
cargo hack check --feature-powerset --no-dev-deps --exclude-features __rkyv --exclude-features rkyv-bytecheck-impl
- crate: swc_ecma_codegen
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_codegen
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_ecma_codegen_macros
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_dep_graph
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_ext_transforms
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_lints
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_loader
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-02-24 09:06:03 +03:00
check: |
cargo hack check --feature-powerset --no-dev-deps
- crate: swc_ecma_loader
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_ecma_minifier
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_parser
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_parser
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_ecma_preset_env
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_preset_env
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_ecma_quote
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_quote_macros
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_testing
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_transforms
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-02-24 09:06:03 +03:00
check: |
cargo hack check --feature-powerset --no-dev-deps
- crate: swc_ecma_transforms_base
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-02-24 09:06:03 +03:00
check: |
cargo hack check --feature-powerset --no-dev-deps
- crate: swc_ecma_transforms_classes
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_transforms_compat
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-02-24 09:06:03 +03:00
check: |
cargo hack check --feature-powerset --no-dev-deps
- crate: swc_ecma_transforms_macros
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_transforms_module
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_transforms_module
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_ecma_transforms_optimization
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-02-24 09:06:03 +03:00
check: |
cargo hack check --feature-powerset --no-dev-deps
- crate: swc_ecma_transforms_proposal
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_transforms_react
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_transforms_testing
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_transforms_testing
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_ecma_transforms_typescript
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_ecma_utils
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-02-24 09:06:03 +03:00
check: |
cargo hack check --feature-powerset --no-dev-deps
- crate: swc_ecma_visit
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
check: |
cargo hack check --feature-powerset --no-dev-deps
- crate: swc_ecmascript
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_eq_ignore_macros
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_error_reporters
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_estree_ast
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_estree_compat
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_fast_graph
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_graph_analyzer
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-04-04 07:12:45 +03:00
- crate: swc_html
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-04-04 07:12:45 +03:00
- crate: swc_html_ast
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-04-04 07:12:45 +03:00
- crate: swc_html_codegen
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-04-04 07:12:45 +03:00
- crate: swc_html_codegen
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
2022-04-04 07:12:45 +03:00
- crate: swc_html_codegen_macros
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_html_minifier
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-04-04 07:12:45 +03:00
- crate: swc_html_parser
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-04-04 07:12:45 +03:00
- crate: swc_html_parser
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_html_utils
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-04-04 07:12:45 +03:00
- crate: swc_html_visit
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_macros_common
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_node_base
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_node_bundler
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
2022-02-24 09:06:03 +03:00
check: |
cargo check
cargo check --no-default-features --features swc_v2
- crate: swc_node_bundler
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_node_comments
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_nodejs_common
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_plugin
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_plugin
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_plugin_macro
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_plugin_proxy
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_plugin_runner
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_plugin_runner
os: macos-latest
2022-09-06 19:47:06 +03:00
runner: macos-latest
- crate: swc_plugin_runner
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_plugin_testing
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_plugin_testing
os: windows-latest
2022-09-06 19:47:06 +03:00
runner: windows-latest
- crate: swc_timer
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_trace_macro
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_visit
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_visit_macros
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_xml
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_xml_ast
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_xml_codegen
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_xml_codegen_macros
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_xml_parser
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: swc_xml_visit
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: testing
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
- crate: testing_macros
os: ubuntu-latest
2022-09-06 19:47:06 +03:00
runner: ubuntu-latest
steps:
- name: Handle line endings
shell: bash
if: runner.os == 'Windows'
run: |
git config --system core.autocrlf false
git config --system core.eol lf
- uses: actions/checkout@v3
2021-12-27 11:32:47 +03:00
with:
submodules: true
# Source map format
- uses: actions/setup-node@v3
with:
node-version: "18"
2021-12-12 10:16:20 +03:00
cache: "yarn"
2021-03-25 19:22:09 +03:00
# We explicitly do this to cache properly.
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
target: wasm32-wasi
2022-09-14 13:33:49 +03:00
# MSRV is current stable for ES crates and nightly for other languages
# toolchain: stable
# override: true
2021-03-25 19:22:09 +03:00
- uses: denoland/setup-deno@v1
if: matrix.settings.crate == 'swc_bundler'
with:
deno-version: v1.x
- name: Install node dependencies
shell: bash
run: |
yarn
# I don't want to think deeply about this
yarn global add jest@27 mocha || \
yarn global add jest@27 mocha || \
yarn global add jest@27 mocha || \
yarn global add jest@27 mocha || \
yarn global add jest@27 mocha || \
yarn global add jest@27 mocha || \
yarn global add jest@27 mocha || \
yarn global add jest@27 mocha || true
- name: Configure path (windows)
shell: bash
if: runner.os == 'Windows'
run: |
echo $(yarn global bin) >> $GITHUB_PATH
- name: Verify dependencies
shell: bash
run: |
jest --version && mocha --version
2022-09-15 09:53:09 +03:00
- name: Cache rust artifacts
uses: Swatinem/rust-cache@v2
if: matrix.settings.crate == 'swc' || matrix.settings.crate == 'swc_plugin_runner'
2022-09-15 09:53:09 +03:00
with:
shared-key: cargo-test-${{ matrix.settings.crate }}
cache-on-failure: true
- name: Configure execution cache
shell: bash
run: |
mkdir -p .swc-exec-cache
echo "SWC_ECMA_TESTING_CACHE_DIR=$(pwd)/.swc-exec-cache" >> $GITHUB_ENV
- name: Cache execution results
uses: actions/cache@v3
with:
path: |
.swc-exec-cache
key: swc-exec-cache-${{ runner.os }}-${{ matrix.settings.crate }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
swc-exec-cache-${{ matrix.settings.crate }}-${{ runner.os }}
- name: Run cargo test
if: matrix.settings.crate != 'swc_plugin_runner' && matrix.settings.crate != 'swc_ecma_minifier' && matrix.settings.crate != 'swc_core' && matrix.settings.crate != 'swc_ecma_quote' && matrix.settings.crate != 'swc_cli' && matrix.settings.crate != 'binding_core_wasm'
run: |
cargo test -p ${{ matrix.settings.crate }}
- name: Run cargo test (core)
if: matrix.settings.crate == 'swc_core'
run: |
cargo test -p swc_core --features ecma_quote --features common --features ecma_utils
- name: Run cargo test (binding_core_wasm)
if: matrix.settings.crate == 'binding_core_wasm'
run: |
cargo test --manifest-path ./bindings/binding_core_wasm/Cargo.toml
- name: Run cargo test (cli)
if: matrix.settings.crate == 'swc_cli'
run: |
cargo test --manifest-path ./bindings/swc_cli/Cargo.toml --features plugin
- name: Run cargo test (plugin)
if: matrix.settings.crate == 'swc_plugin_runner'
run: |
cargo test -p swc_plugin_runner --release --features plugin_transform_schema_v1 --features rkyv-impl
- name: Run cargo test (swc_ecma_minifier)
if: matrix.settings.crate == 'swc_ecma_minifier'
run: |
cargo test -p swc_ecma_minifier --features concurrent
2022-04-10 12:33:18 +03:00
- name: Run cargo test (all features)
if: matrix.settings.crate == 'swc_ecma_parser' || matrix.settings.crate == 'swc_ecma_loader' || matrix.settings.crate == 'swc_ecma_transforms'
run: |
cargo test -p ${{ matrix.settings.crate }} --all-features
2022-06-13 14:15:18 +03:00
- name: Run cargo test (concurrent)
2022-08-11 05:04:58 +03:00
if: runner.os == 'Linux' && matrix.settings.crate != 'swc_ecma_minifier'
2022-06-13 14:15:18 +03:00
shell: bash
env:
SWC_FORCE_CONCURRENT: "1"
2022-06-13 14:15:18 +03:00
run: |
./scripts/ci/test-concurrent.sh ${{ matrix.settings.crate }}
- name: Run cargo test (swc, concurrent)
shell: bash
if: matrix.settings.crate == 'swc' && runner.os == 'Linux'
env:
SWC_FORCE_CONCURRENT: "1"
2022-06-13 14:15:18 +03:00
run: |
cargo test -p swc --all-targets --features concurrent
2022-06-13 14:15:18 +03:00
2022-02-24 09:06:03 +03:00
- name: Install cargo-hack
uses: baptiste0928/cargo-install@v1.1.0
if: matrix.settings.os == 'ubuntu-latest' && matrix.settings.check
with:
crate: cargo-hack
version: "0.5.7"
- name: Check compilation
if: matrix.settings.check
working-directory: "crates/${{ matrix.settings.crate }}"
run: "${{ matrix.settings.check }}"