From b3889a9365c2c99fd62d6eedce526fe78692bfe0 Mon Sep 17 00:00:00 2001 From: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com> Date: Mon, 25 Aug 2025 12:10:26 +0200 Subject: [PATCH 1/3] setup(ci): separate legacy/new --- .github/workflows/ci.yml | 49 ++++++++++++++++++---- package-lock.json | 9 ++++ package.json | 3 +- recipes/correct-ts-specifiers/package.json | 2 +- 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57674d81..aef20c63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,7 +92,41 @@ jobs: - name: Validate YAML files run: yamllint -c .yamllint.yaml -f github ./ - tests: + test: + name: Unit, e2e, coverage + + if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }} + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: + - macos-latest + - ubuntu-latest + - windows-latest + + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + show-progress: false + - name: Set up Node.js LTS + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + cache: "npm" + check-latest: true + node-version-file: ".nvmrc" + - run: npm ci + - run: node --run test + + legacy-tests: name: Unit, e2e, coverage if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }} @@ -126,10 +160,9 @@ jobs: check-latest: true node-version: ${{ matrix.node-version }} - run: npm ci - - name: Run recipe tests - run: >- - node - --run test - --test-coverage-lines=0.8 - --test-reporter-destination=./coverage.lcov - --test-reporter=lcov + # Codemod has changed its paradigm, but there is still a recipe that uses the old one, which is why we run it alongside it. + # The old paradigm used node to run codemod, which is why we run it on several versions. + # REF: https://codemod.com/blog/new-codemod-cli + - name: Run legacy recipe tests + run: node --run test-legacy + diff --git a/package-lock.json b/package-lock.json index 4c7e22d5..099bf7ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -196,6 +196,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -212,6 +213,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -228,6 +230,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -244,6 +247,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -260,6 +264,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -276,6 +281,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -292,6 +298,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -308,6 +315,7 @@ "cpu": [ "ia32" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -324,6 +332,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ diff --git a/package.json b/package.json index 803157c5..daa19b87 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "lint:fix": "biome lint --fix ./", "lint": "biome lint ./", "pre-commit": "node --run lint:fix; node --run type-check; node --run test", - "test": "npm run test --workspaces", + "test": "npm run test --workspaces --if-present", + "test-legacy": "npm run test-legacy --workspaces --if-present", "type-check": "tsc" }, "repository": { diff --git a/recipes/correct-ts-specifiers/package.json b/recipes/correct-ts-specifiers/package.json index 74d30bdf..683f1419 100644 --- a/recipes/correct-ts-specifiers/package.json +++ b/recipes/correct-ts-specifiers/package.json @@ -9,7 +9,7 @@ }, "scripts": { "start": "node --no-warnings --experimental-import-meta-resolve --experimental-strip-types ./src/workflow.ts", - "test": "node --no-warnings --experimental-import-meta-resolve --experimental-test-module-mocks --experimental-test-snapshots --experimental-strip-types --import='@nodejs/codemod-utils/snapshots' --test --experimental-test-coverage --test-coverage-include='src/**/*' --test-coverage-exclude='**/*.test.ts' './**/*.test.ts'" + "test-legacy": "node --no-warnings --experimental-import-meta-resolve --experimental-test-module-mocks --experimental-test-snapshots --experimental-strip-types --import='@nodejs/codemod-utils/snapshots' --test --experimental-test-coverage --test-coverage-include='src/**/*' --test-coverage-exclude='**/*.test.ts' './**/*.test.ts'" }, "repository": { "type": "git", From 0667c267d2736b858eb17c43d839e8450d0059bb Mon Sep 17 00:00:00 2001 From: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com> Date: Mon, 25 Aug 2025 12:12:00 +0200 Subject: [PATCH 2/3] fix: yaml --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aef20c63..9fb0bc9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -165,4 +165,3 @@ jobs: # REF: https://codemod.com/blog/new-codemod-cli - name: Run legacy recipe tests run: node --run test-legacy - From c2fcc1407a96ac17c963d53269766662067bac1e Mon Sep 17 00:00:00 2001 From: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com> Date: Mon, 25 Aug 2025 12:15:50 +0200 Subject: [PATCH 3/3] polish naming --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9fb0bc9a..ae98aac9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ # For more information see: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow -name: CI +name: Quality Assurance on: push: @@ -30,7 +30,7 @@ permissions: jobs: get-matrix: - name: Configure Node LTS environment matrix + name: Configure Node environment matrix runs-on: ubuntu-latest outputs: @@ -65,7 +65,7 @@ jobs: with: persist-credentials: false show-progress: false - - name: Set up Node.js LTS + - name: Set up Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: cache: "npm" @@ -93,7 +93,7 @@ jobs: run: yamllint -c .yamllint.yaml -f github ./ test: - name: Unit, e2e, coverage + name: Codemod JSSG tests if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }} @@ -117,7 +117,7 @@ jobs: with: persist-credentials: false show-progress: false - - name: Set up Node.js LTS + - name: Set up Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: cache: "npm" @@ -127,7 +127,7 @@ jobs: - run: node --run test legacy-tests: - name: Unit, e2e, coverage + name: Run legacy tests if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}