From 6d53195823d383bd53eee22e9f04a030aa453860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 12:31:46 +0900 Subject: [PATCH 01/19] Move tests.yml --- scripts/github/create-matrix.sh | 2 +- scripts/github/run-cargo-hack.sh | 2 +- scripts/github/tests.yml => tests.yml | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) rename scripts/github/tests.yml => tests.yml (95%) diff --git a/scripts/github/create-matrix.sh b/scripts/github/create-matrix.sh index 6fab8e6098eb..8c12e1007836 100755 --- a/scripts/github/create-matrix.sh +++ b/scripts/github/create-matrix.sh @@ -11,7 +11,7 @@ crates=$(\ ) # yq query syntax is weird, so we have to use jq -json_str="$(yq -o=json $SCRIPT_DIR/tests.yml)" +json_str="$(yq -o=json $SCRIPT_DIR/../../tests.yml)" for crate in $crates do diff --git a/scripts/github/run-cargo-hack.sh b/scripts/github/run-cargo-hack.sh index be3d94cffb95..0c817eb4e240 100755 --- a/scripts/github/run-cargo-hack.sh +++ b/scripts/github/run-cargo-hack.sh @@ -8,7 +8,7 @@ crate=$1 echo "Running cargo hack for crate $crate" # yq query syntax is weird, so we have to use jq -json_str="$(yq -o=json $SCRIPT_DIR/tests.yml)" +json_str="$(yq -o=json $SCRIPT_DIR/../../tests.yml)" if echo $json_str | jq -e ".check.\"$crate\"" > /dev/null; then diff --git a/scripts/github/tests.yml b/tests.yml similarity index 95% rename from scripts/github/tests.yml rename to tests.yml index 452b896f767b..5786f7f099fd 100644 --- a/scripts/github/tests.yml +++ b/tests.yml @@ -1,6 +1,7 @@ os: windows: - swc + - swc_allocator - swc_cli - swc_common - swc_css_codegen @@ -18,6 +19,7 @@ os: - swc_plugin_runner - swc_plugin_testing macos: + - swc_allocator - swc_plugin_runner # host: @@ -27,6 +29,8 @@ check: swc: # plugin feature is verified by other tasks - "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_transform_host_js" + swc_allocator: + - "cargo hack check" swc_bundler: - "cargo hack check --feature-powerset --no-dev-deps" swc_common: From 205389ef011d8e7a16f63062b062f74873e70c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 12:31:52 +0900 Subject: [PATCH 02/19] CI --- .github/workflows/CI.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 982520a6ec56..8e50d5a8ad19 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -211,6 +211,15 @@ jobs: - crate: swc_atoms os: ubuntu-latest runner: ubuntu-latest + - crate: swc_allocator + os: ubuntu-latest + runner: ubuntu-latest + - crate: swc_allocator + os: ubuntu-latest + runner: windows-latest + - crate: swc_allocator + os: macos-latest + runner: ubuntu-latest - crate: swc_bundler os: ubuntu-latest runner: ubuntu-latest From fead1b43bd6bd6fdad3850f60f865c3103504698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 12:35:18 +0900 Subject: [PATCH 03/19] CI --- .github/workflows/CI.yml | 410 +++------------------------------------ 1 file changed, 22 insertions(+), 388 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8e50d5a8ad19..379de34d68ff 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -168,400 +168,34 @@ jobs: run: | (cd bindings/${{ matrix.pkg }} && ./scripts/test.sh) + list-cargo-tests: + if: >- + ${{ !contains(github.event.head_commit.message, 'chore: ') }} + name: List crates + runs-on: ubuntu-latest + outputs: + settings: ${{ steps.list-tests.outputs.crates }} + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + + - name: List crates + id: list-tests + run: echo "settings=$(./scripts/cargo/get-test-matrix.sh)" >> $GITHUB_OUTPUT + cargo-test: name: Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} runs-on: ${{ matrix.settings.runner }} - if: >- - ${{ !contains(github.event.head_commit.message, 'chore: ') }} + needs: + - list-cargo-tests strategy: fail-fast: false matrix: - settings: - # Use scripts/github/create-matrix.sh to create this. - - crate: ast_node - os: ubuntu-latest - runner: ubuntu-latest - - crate: better_scoped_tls - os: ubuntu-latest - runner: ubuntu-latest - - crate: binding_macros - os: ubuntu-latest - runner: ubuntu-latest - - crate: dbg-swc - os: ubuntu-latest - runner: ubuntu-latest - - crate: from_variant - os: ubuntu-latest - runner: ubuntu-latest - - crate: jsdoc - os: ubuntu-latest - runner: ubuntu-latest - - crate: preset_env_base - os: ubuntu-latest - runner: ubuntu-latest - - crate: string_enum - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc - os: windows-latest - runner: windows-latest - - crate: swc_atoms - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_allocator - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_allocator - os: ubuntu-latest - runner: windows-latest - - crate: swc_allocator - os: macos-latest - runner: ubuntu-latest - - crate: swc_bundler - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_cached - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_cli_impl - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_common - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_common - os: windows-latest - runner: windows-latest - - crate: swc_compiler_base - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_config - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_config_macro - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_core - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css_ast - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css_codegen - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css_codegen - os: windows-latest - runner: windows-latest - - crate: swc_css_codegen_macros - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css_compat - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css_lints - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css_minifier - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css_modules - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css_parser - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css_parser - os: windows-latest - runner: windows-latest - - crate: swc_css_prefixer - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css_utils - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_css_visit - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_ast - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_codegen - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_codegen - os: windows-latest - runner: windows-latest - - crate: swc_ecma_codegen_macros - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_compat_bugfixes - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_compat_common - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_compat_es2015 - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_compat_es2016 - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_compat_es2017 - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_compat_es2018 - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_compat_es2019 - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_compat_es2020 - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_compat_es2021 - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_compat_es2022 - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_compat_es3 - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_ext_transforms - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_lints - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_loader - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_loader - os: windows-latest - runner: windows-latest - - crate: swc_ecma_minifier - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_parser - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_parser - os: windows-latest - runner: windows-latest - - crate: swc_ecma_preset_env - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_preset_env - os: windows-latest - runner: windows-latest - - crate: swc_ecma_quote - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_quote_macros - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_testing - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_transforms - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_transforms_base - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_transforms_classes - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_transforms_compat - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_transforms_macros - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_transforms_module - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_transforms_module - os: windows-latest - runner: windows-latest - - crate: swc_ecma_transforms_optimization - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_transforms_proposal - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_transforms_react - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_transforms_testing - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_transforms_testing - os: windows-latest - runner: windows-latest - - crate: swc_ecma_transforms_typescript - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_usage_analyzer - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_utils - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecma_visit - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_ecmascript - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_eq_ignore_macros - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_error_reporters - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_estree_ast - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_estree_compat - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_fast_graph - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_fast_ts_strip - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_graph_analyzer - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_html - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_html_ast - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_html_codegen - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_html_codegen - os: windows-latest - runner: windows-latest - - crate: swc_html_codegen_macros - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_html_minifier - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_html_parser - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_html_parser - os: windows-latest - runner: windows-latest - - crate: swc_html_utils - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_html_visit - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_macros_common - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_malloc - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_node_bundler - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_node_bundler - os: windows-latest - runner: windows-latest - - crate: swc_node_comments - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_nodejs_common - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_plugin - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_plugin - os: windows-latest - runner: windows-latest - - crate: swc_plugin_macro - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_plugin_proxy - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_plugin_runner - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_plugin_runner - os: macos-latest - runner: macos-latest - - crate: swc_plugin_runner - os: windows-latest - runner: windows-latest - - crate: swc_plugin_testing - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_plugin_testing - os: windows-latest - runner: windows-latest - - crate: swc_timer - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_trace_macro - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_transform_common - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_visit - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_visit_macros - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_x_optimizer - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_xml - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_xml_ast - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_xml_codegen - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_xml_codegen_macros - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_xml_parser - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_xml_visit - os: ubuntu-latest - runner: ubuntu-latest - - crate: testing - os: ubuntu-latest - runner: ubuntu-latest - - crate: testing_macros - os: ubuntu-latest - runner: ubuntu-latest - - crate: swc_typescript - os: ubuntu-latest - runner: ubuntu-latest + settings: ${{fromJson(needs.list-cargo-tests.outputs.settings)}} steps: - name: Handle line endings shell: bash From 3ab4d9973c7a5e025e078f93d7e645c227b9eefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 12:36:00 +0900 Subject: [PATCH 04/19] Rename --- .github/workflows/CI.yml | 2 +- scripts/github/{create-matrix.sh => get-test-matrix.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename scripts/github/{create-matrix.sh => get-test-matrix.sh} (100%) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 379de34d68ff..50f40cab3873 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -185,7 +185,7 @@ jobs: - name: List crates id: list-tests - run: echo "settings=$(./scripts/cargo/get-test-matrix.sh)" >> $GITHUB_OUTPUT + run: echo "settings=$(./scripts/github/get-test-matrix.sh)" >> $GITHUB_OUTPUT cargo-test: name: Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} diff --git a/scripts/github/create-matrix.sh b/scripts/github/get-test-matrix.sh similarity index 100% rename from scripts/github/create-matrix.sh rename to scripts/github/get-test-matrix.sh From bcd8b6f4e8efa1f97e07ee1526fd32c0f4c611ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 12:37:46 +0900 Subject: [PATCH 05/19] DEp on zx --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d0503467bf00..8b9364cc8ea6 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,8 @@ "swc-plugin-coverage-instrument": "^0.0.12", "terser": "^5.7.1", "ts-node": "^10.5.0", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "zx": "^8.1.4" }, "lint-staged": { "*.toml": [ From d4e8108d45dc623ec542ef7aabed6a1b3a48d46f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 12:37:50 +0900 Subject: [PATCH 06/19] yarn lockfile --- yarn.lock | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 5aca9fc529a7..63f6e7209d92 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4781,6 +4781,7 @@ __metadata: terser: "npm:^5.7.1" ts-node: "npm:^10.5.0" typescript: "npm:^5.3.3" + zx: "npm:^8.1.4" languageName: unknown linkType: soft @@ -4905,7 +4906,7 @@ __metadata: languageName: node linkType: hard -"@types/fs-extra@npm:^11.0.1": +"@types/fs-extra@npm:>=11, @types/fs-extra@npm:^11.0.1": version: 11.0.4 resolution: "@types/fs-extra@npm:11.0.4" dependencies: @@ -5034,6 +5035,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:>=20": + version: 20.14.10 + resolution: "@types/node@npm:20.14.10" + dependencies: + undici-types: "npm:~5.26.4" + checksum: 672892cf94d0d95cf052f11271990686a0fd204cd1e5fe7a4ef240e5315e06711765dc47b9ec98627d3adac18b8c92bb7e2d8db21d18faa20bc3e3203a143e79 + languageName: node + linkType: hard + "@types/node@npm:^17.0.17": version: 17.0.45 resolution: "@types/node@npm:17.0.45" @@ -18143,3 +18153,20 @@ __metadata: checksum: 8dfecbb939cc8390707a686ccf85dcff3ac24ff69482fe5c39ec43848f438d9e84a8e946b823f8a725bf7ac606d1a6c596a3ffc2b7aaa22f9480b06b5b777ef9 languageName: node linkType: hard + +"zx@npm:^8.1.4": + version: 8.1.4 + resolution: "zx@npm:8.1.4" + dependencies: + "@types/fs-extra": "npm:>=11" + "@types/node": "npm:>=20" + dependenciesMeta: + "@types/fs-extra": + optional: true + "@types/node": + optional: true + bin: + zx: build/cli.js + checksum: 1ffa4c51a1edad25de0729d09667b3d1b7b4f9c8f6b4300e34d85f8f18c2e768f7e297b9bfad4d3b8a24792b3f14085f229933d0a224febba49ac2588ed155b1 + languageName: node + linkType: hard From 3ba32b70be8a286aaebcb43cc0c9e2b797dfdd68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 12:39:28 +0900 Subject: [PATCH 07/19] zx --- .github/workflows/CI.yml | 2 +- scripts/github/get-test-matrix.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100755 scripts/github/get-test-matrix.js diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 50f40cab3873..3f61c5d6d147 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -185,7 +185,7 @@ jobs: - name: List crates id: list-tests - run: echo "settings=$(./scripts/github/get-test-matrix.sh)" >> $GITHUB_OUTPUT + run: npx zx ./scripts/github/get-test-matrix.js cargo-test: name: Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} diff --git a/scripts/github/get-test-matrix.js b/scripts/github/get-test-matrix.js new file mode 100755 index 000000000000..142c002cf08d --- /dev/null +++ b/scripts/github/get-test-matrix.js @@ -0,0 +1,5 @@ +#!/usr/bin/env zx + +const scriptDir = __dirname; + +console.error("scriptDir", scriptDir); From 2d4e5b580b9a00a5aef119bf4e5b5b75c48bbb60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 12:42:47 +0900 Subject: [PATCH 08/19] More work --- .github/workflows/CI.yml | 2 +- scripts/github/get-test-matrix.js | 5 ----- scripts/github/get-test-matrix.mjs | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) delete mode 100755 scripts/github/get-test-matrix.js create mode 100755 scripts/github/get-test-matrix.mjs diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3f61c5d6d147..e91e3ff42a5d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -185,7 +185,7 @@ jobs: - name: List crates id: list-tests - run: npx zx ./scripts/github/get-test-matrix.js + run: npx zx ./scripts/github/get-test-matrix.mjs cargo-test: name: Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} diff --git a/scripts/github/get-test-matrix.js b/scripts/github/get-test-matrix.js deleted file mode 100755 index 142c002cf08d..000000000000 --- a/scripts/github/get-test-matrix.js +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env zx - -const scriptDir = __dirname; - -console.error("scriptDir", scriptDir); diff --git a/scripts/github/get-test-matrix.mjs b/scripts/github/get-test-matrix.mjs new file mode 100755 index 000000000000..896b7ef349fd --- /dev/null +++ b/scripts/github/get-test-matrix.mjs @@ -0,0 +1,16 @@ +#!/usr/bin/env zx +import * as path from 'node:path'; +import * as fs from 'node:fs/promises'; + +const scriptDir = __dirname; +const repoRootDir = path.resolve(scriptDir, '../../'); +const testsYmlPath = path.resolve(repoRootDir, 'tests.yml'); + +console.log("Script dir:", scriptDir); +console.log(`Using tests.yml at ${testsYmlPath}`); + +const rawMetadata = await $`cargo metadata --format-version=1 --all-features --no-deps`; +const metadata = JSON.parse(rawMetadata.stdout); +const packages = metadata.packages.map(p => p.name).filter(name => name !== 'xtask'); + +console.log('Crates: ', packages) \ No newline at end of file From d7839ccc818875d61d0347406748003f37c526d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 12:43:48 +0900 Subject: [PATCH 09/19] Dep --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 8b9364cc8ea6..89e22190a08d 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "terser": "^5.7.1", "ts-node": "^10.5.0", "typescript": "^5.3.3", + "yaml": "^2.4.5", "zx": "^8.1.4" }, "lint-staged": { From c148489f019c57a4393edbfa292ea6e2bf2f7e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 12:43:53 +0900 Subject: [PATCH 10/19] yarn lockfile --- yarn.lock | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/yarn.lock b/yarn.lock index 63f6e7209d92..cf6b2b8379fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4781,6 +4781,7 @@ __metadata: terser: "npm:^5.7.1" ts-node: "npm:^10.5.0" typescript: "npm:^5.3.3" + yaml: "npm:^2.4.5" zx: "npm:^8.1.4" languageName: unknown linkType: soft @@ -17985,6 +17986,15 @@ __metadata: languageName: node linkType: hard +"yaml@npm:^2.4.5": + version: 2.4.5 + resolution: "yaml@npm:2.4.5" + bin: + yaml: bin.mjs + checksum: b09bf5a615a65276d433d76b8e34ad6b4c0320b85eb3f1a39da132c61ae6e2ff34eff4624e6458d96d49566c93cf43408ba5e568218293a8c6541a2006883f64 + languageName: node + linkType: hard + "yargs-parser@npm:20.2.4": version: 20.2.4 resolution: "yargs-parser@npm:20.2.4" From 7c08be733c44be29751edf186cf0b7949d815485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 12:59:19 +0900 Subject: [PATCH 11/19] matrix.mjs --- scripts/github/get-test-matrix.mjs | 35 ++++++++++++++++++++++++++- scripts/github/get-test-matrix.sh | 39 ------------------------------ 2 files changed, 34 insertions(+), 40 deletions(-) delete mode 100755 scripts/github/get-test-matrix.sh diff --git a/scripts/github/get-test-matrix.mjs b/scripts/github/get-test-matrix.mjs index 896b7ef349fd..6b53d971dbd0 100755 --- a/scripts/github/get-test-matrix.mjs +++ b/scripts/github/get-test-matrix.mjs @@ -1,10 +1,12 @@ #!/usr/bin/env zx import * as path from 'node:path'; import * as fs from 'node:fs/promises'; +import { parse, } from 'yaml' const scriptDir = __dirname; const repoRootDir = path.resolve(scriptDir, '../../'); const testsYmlPath = path.resolve(repoRootDir, 'tests.yml'); +const testsYml = parse(await fs.readFile(testsYmlPath, 'utf8')); console.log("Script dir:", scriptDir); console.log(`Using tests.yml at ${testsYmlPath}`); @@ -13,4 +15,35 @@ const rawMetadata = await $`cargo metadata --format-version=1 --all-features --n const metadata = JSON.parse(rawMetadata.stdout); const packages = metadata.packages.map(p => p.name).filter(name => name !== 'xtask'); -console.log('Crates: ', packages) \ No newline at end of file +console.log('Crates: ', packages) +console.log('Test config: ', testsYml) + +const settings = []; + +for (const pkg of packages) { + settings.push({ + crate: pkg, + runner: 'ubunut-latest', + os: 'ubuntu-latest', + }); + + if (testsYml.os?.windows?.includes(pkg)) { + settings.push({ + crate: pkg, + runner: 'windows-latest', + os: 'windows-latest', + }); + } + + if (testsYml.os?.macos?.includes(pkg)) { + settings.push({ + crate: pkg, + runner: 'macos-latest', + os: 'macos-latest', + }); + } +} + +const output = JSON.stringify(settings) +console.log(output) +await `echo ${output} >> $GITHUB_OUTPUT`; \ No newline at end of file diff --git a/scripts/github/get-test-matrix.sh b/scripts/github/get-test-matrix.sh deleted file mode 100755 index 8c12e1007836..000000000000 --- a/scripts/github/get-test-matrix.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash -set -u - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - -function prepend() { while read line; do echo "${1}${line}"; done; } - -crates=$(\ - cargo metadata --format-version=1 --all-features \ - | jq '.packages .[] | select(.repository == "https://github.com/swc-project/swc.git") | .name' -r\ -) - -# yq query syntax is weird, so we have to use jq -json_str="$(yq -o=json $SCRIPT_DIR/../../tests.yml)" - -for crate in $crates -do - echo "- crate: $crate" - echo " os: ubuntu-latest" - - if echo $json_str | jq -e "select(.host.\"$crate\")" > /dev/null; then - echo " runner: " `echo $json_str | jq -e -r ".host.\"$crate\""` - - else - echo " runner: ubuntu-latest" - fi - - if echo $json_str | jq -e "select(.os.macos | index(\"$crate\"))" > /dev/null; then - echo "- crate: $crate" - echo " os: macos-latest" - echo " runner: macos-latest" - fi - - if echo $json_str | jq -e "select(.os.windows | index(\"$crate\"))" > /dev/null; then - echo "- crate: $crate" - echo " os: windows-latest" - echo " runner: windows-latest" - fi -done \ No newline at end of file From 9a71f75b6c56f4c9463644be6a20f9b347508492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 13:01:47 +0900 Subject: [PATCH 12/19] setup node --- .github/workflows/CI.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e91e3ff42a5d..fbb0f77e6a7e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -178,10 +178,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal + - uses: ./.github/actions/setup-node - name: List crates id: list-tests From 7cc94a5de80799ad0442de963fa369505c1f0d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 13:02:30 +0900 Subject: [PATCH 13/19] --feature-powerset --- tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.yml b/tests.yml index 5786f7f099fd..ffcc47170fb5 100644 --- a/tests.yml +++ b/tests.yml @@ -30,7 +30,7 @@ check: # plugin feature is verified by other tasks - "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_transform_host_js" swc_allocator: - - "cargo hack check" + - "cargo hack check --feature-powerset" swc_bundler: - "cargo hack check --feature-powerset --no-dev-deps" swc_common: From 4d5d00aecb1891fdf38bc97c82120e5f16338b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 13:02:39 +0900 Subject: [PATCH 14/19] --no-dev-deps --- tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.yml b/tests.yml index ffcc47170fb5..967e19d20948 100644 --- a/tests.yml +++ b/tests.yml @@ -30,7 +30,7 @@ check: # plugin feature is verified by other tasks - "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_transform_host_js" swc_allocator: - - "cargo hack check --feature-powerset" + - "cargo hack check --feature-powerset --no-dev-deps" swc_bundler: - "cargo hack check --feature-powerset --no-dev-deps" swc_common: From 688ea161d0f3d4250b64e24fb74a11744189df47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 13:05:56 +0900 Subject: [PATCH 15/19] fix --- .github/workflows/CI.yml | 2 +- scripts/github/get-test-matrix.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index fbb0f77e6a7e..83dffca5faf8 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -174,7 +174,7 @@ jobs: name: List crates runs-on: ubuntu-latest outputs: - settings: ${{ steps.list-tests.outputs.crates }} + settings: ${{ steps.list-tests.outputs.settings }} steps: - uses: actions/checkout@v4 diff --git a/scripts/github/get-test-matrix.mjs b/scripts/github/get-test-matrix.mjs index 6b53d971dbd0..5b44abe98219 100755 --- a/scripts/github/get-test-matrix.mjs +++ b/scripts/github/get-test-matrix.mjs @@ -46,4 +46,4 @@ for (const pkg of packages) { const output = JSON.stringify(settings) console.log(output) -await `echo ${output} >> $GITHUB_OUTPUT`; \ No newline at end of file +await `echo settings='${output}' >> $GITHUB_OUTPUT`; \ No newline at end of file From 4ef5e2836d27f1536d660d7db70637db542e3876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 13:06:04 +0900 Subject: [PATCH 16/19] $ --- scripts/github/get-test-matrix.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/github/get-test-matrix.mjs b/scripts/github/get-test-matrix.mjs index 5b44abe98219..222638821b36 100755 --- a/scripts/github/get-test-matrix.mjs +++ b/scripts/github/get-test-matrix.mjs @@ -46,4 +46,4 @@ for (const pkg of packages) { const output = JSON.stringify(settings) console.log(output) -await `echo settings='${output}' >> $GITHUB_OUTPUT`; \ No newline at end of file +await $`echo settings='${output}' >> $GITHUB_OUTPUT`; \ No newline at end of file From 317473c399869df6ebe7a984017f09044073b17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 13:09:48 +0900 Subject: [PATCH 17/19] Remove runner --- .github/workflows/CI.yml | 2 +- scripts/github/get-test-matrix.mjs | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 83dffca5faf8..18393fd02d84 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -186,7 +186,7 @@ jobs: cargo-test: name: Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} - runs-on: ${{ matrix.settings.runner }} + runs-on: ${{ matrix.settings.os }} needs: - list-cargo-tests strategy: diff --git a/scripts/github/get-test-matrix.mjs b/scripts/github/get-test-matrix.mjs index 222638821b36..04897ed11dcc 100755 --- a/scripts/github/get-test-matrix.mjs +++ b/scripts/github/get-test-matrix.mjs @@ -23,14 +23,12 @@ const settings = []; for (const pkg of packages) { settings.push({ crate: pkg, - runner: 'ubunut-latest', os: 'ubuntu-latest', }); if (testsYml.os?.windows?.includes(pkg)) { settings.push({ crate: pkg, - runner: 'windows-latest', os: 'windows-latest', }); } @@ -38,7 +36,6 @@ for (const pkg of packages) { if (testsYml.os?.macos?.includes(pkg)) { settings.push({ crate: pkg, - runner: 'macos-latest', os: 'macos-latest', }); } From bc043ecb01d8c932f8cb3cf40a729c2ac57fefce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 13:15:39 +0900 Subject: [PATCH 18/19] echo --- .github/workflows/CI.yml | 2 +- scripts/github/get-test-matrix.mjs | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 18393fd02d84..1aa288d946d6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -182,7 +182,7 @@ jobs: - name: List crates id: list-tests - run: npx zx ./scripts/github/get-test-matrix.mjs + run: echo "settings=$(npx zx ./scripts/github/get-test-matrix.mjs) >> $GITHUB_OUTPUT" cargo-test: name: Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} diff --git a/scripts/github/get-test-matrix.mjs b/scripts/github/get-test-matrix.mjs index 04897ed11dcc..3c1904fd9de6 100755 --- a/scripts/github/get-test-matrix.mjs +++ b/scripts/github/get-test-matrix.mjs @@ -8,15 +8,15 @@ const repoRootDir = path.resolve(scriptDir, '../../'); const testsYmlPath = path.resolve(repoRootDir, 'tests.yml'); const testsYml = parse(await fs.readFile(testsYmlPath, 'utf8')); -console.log("Script dir:", scriptDir); -console.log(`Using tests.yml at ${testsYmlPath}`); +process.stderr.write(`Script dir: ${scriptDir}\n`); +process.stderr.write(`Using tests.yml at ${testsYmlPath}\n`); const rawMetadata = await $`cargo metadata --format-version=1 --all-features --no-deps`; const metadata = JSON.parse(rawMetadata.stdout); const packages = metadata.packages.map(p => p.name).filter(name => name !== 'xtask'); -console.log('Crates: ', packages) -console.log('Test config: ', testsYml) +process.stderr.write(`Crates: ${packages}\n`) +process.stderr.write(`Test config: ${testsYml}\n`) const settings = []; @@ -42,5 +42,4 @@ for (const pkg of packages) { } const output = JSON.stringify(settings) -console.log(output) -await $`echo settings='${output}' >> $GITHUB_OUTPUT`; \ No newline at end of file +console.log(output) \ No newline at end of file From 3d2658162bcc2d81b236daa39ba4b9cbd4edb43b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sun, 14 Jul 2024 13:15:56 +0900 Subject: [PATCH 19/19] fixup --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1aa288d946d6..84d4a00fa283 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -182,7 +182,7 @@ jobs: - name: List crates id: list-tests - run: echo "settings=$(npx zx ./scripts/github/get-test-matrix.mjs) >> $GITHUB_OUTPUT" + run: echo "settings=$(npx zx ./scripts/github/get-test-matrix.mjs)" >> $GITHUB_OUTPUT cargo-test: name: Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }}