From 4f3000cff8404fe91f3e30c03dd8665b10c9f097 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Thu, 17 Jul 2025 14:24:48 -0700 Subject: [PATCH 1/5] ci: let .nvmrc break node_modules cache --- .github/actions/install-dependencies/action.yml | 4 ++-- .github/workflows/ci.yml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml index 793e38a331..a3394a62f4 100644 --- a/.github/actions/install-dependencies/action.yml +++ b/.github/actions/install-dependencies/action.yml @@ -33,7 +33,7 @@ runs: packages/*/node_modules packages/*/src/generated packages/scratch-gui/static/microbit - key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} + key: ${{ runner.os }}-npm-${{ hashFiles('.nvmrc', 'package-lock.json') }} - if: steps.restore-node-modules-cache.outputs.cache-hit != 'true' name: Install NPM dependencies working-directory: . @@ -47,4 +47,4 @@ runs: packages/*/node_modules packages/*/src/generated packages/scratch-gui/static/microbit - key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} + key: ${{ runner.os }}-npm-${{ hashFiles('.nvmrc', 'package-lock.json') }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01e72a92fc..320e0ec13d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: filters: | global: - ".github/workflows/ci.yml" + - ".nvmrc" - "package.json" - "package-lock.json" - "scripts/**" From a40e8cfe5dd3fc5949a506af9a986ad32a5e6157 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Thu, 17 Jul 2025 14:28:36 -0700 Subject: [PATCH 2/5] ci: move path filters to a separate file --- .github/path-filters.yml | 26 ++++++++++++++++++++++++++ .github/workflows/ci.yml | 25 +------------------------ 2 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 .github/path-filters.yml diff --git a/.github/path-filters.yml b/.github/path-filters.yml new file mode 100644 index 0000000000..f76b0965e3 --- /dev/null +++ b/.github/path-filters.yml @@ -0,0 +1,26 @@ +# Files in the `global` filter affect all workspaces, even if workspace-specific files have not changed. +global: + - ".github/path-filters.yml" + - ".github/workflows/ci.yml" + - ".nvmrc" + - "package.json" + - "package-lock.json" + - "scripts/**" + +any-workspace: + - "packages/**" + +scratch-svg-renderer: + - "packages/scratch-svg-renderer/**" +scratch-render: + - "packages/scratch-render/**" + - "packages/scratch-svg-renderer/**" +scratch-vm: + - "packages/scratch-render/**" + - "packages/scratch-svg-renderer/**" + - "packages/scratch-vm/**" +scratch-gui: + - "packages/scratch-gui/**" + - "packages/scratch-render/**" + - "packages/scratch-svg-renderer/**" + - "packages/scratch-vm/**" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 320e0ec13d..2ff17233b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,30 +36,7 @@ jobs: - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3 id: filter with: - # Files in the `global` filter affect all workspaces, even if workspace-specific files have not changed. - filters: | - global: - - ".github/workflows/ci.yml" - - ".nvmrc" - - "package.json" - - "package-lock.json" - - "scripts/**" - any-workspace: - - "packages/**" - scratch-svg-renderer: - - "packages/scratch-svg-renderer/**" - scratch-render: - - "packages/scratch-render/**" - - "packages/scratch-svg-renderer/**" - scratch-vm: - - "packages/scratch-render/**" - - "packages/scratch-svg-renderer/**" - - "packages/scratch-vm/**" - scratch-gui: - - "packages/scratch-gui/**" - - "packages/scratch-render/**" - - "packages/scratch-svg-renderer/**" - - "packages/scratch-vm/**" + filters: ./.github/path-filters.yml - if: ${{ steps.filter.outputs.global == 'true' || steps.filter.outputs.any-workspace == 'true' }} uses: ./.github/actions/install-dependencies From 49a284d0d68651e6c374573a87ac55465f72c9ec Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Thu, 17 Jul 2025 14:55:34 -0700 Subject: [PATCH 3/5] ci: move commitlint to its own action --- .github/workflows/ci.yml | 1 - .github/workflows/commitlint.yml | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/commitlint.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ff17233b0..4dde87b25e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,6 @@ jobs: with: cache: 'npm' node-version-file: '.nvmrc' - - uses: wagoid/commitlint-github-action@9763196e10f27aef304c9b8b660d31d97fce0f99 # v5 - name: Debug info run: | cat < Date: Thu, 17 Jul 2025 14:56:43 -0700 Subject: [PATCH 4/5] ci: move tests to independent job matrix --- .github/path-filters.yml | 9 +++++-- .github/workflows/ci.yml | 56 ++++++++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/.github/path-filters.yml b/.github/path-filters.yml index f76b0965e3..d980a41921 100644 --- a/.github/path-filters.yml +++ b/.github/path-filters.yml @@ -1,5 +1,5 @@ -# Files in the `global` filter affect all workspaces, even if workspace-specific files have not changed. -global: +# The `&global` anchor defines a set of common paths to include by reference in the other filters. +global: &global - ".github/path-filters.yml" - ".github/workflows/ci.yml" - ".nvmrc" @@ -8,18 +8,23 @@ global: - "scripts/**" any-workspace: + - *global - "packages/**" scratch-svg-renderer: + - *global - "packages/scratch-svg-renderer/**" scratch-render: + - *global - "packages/scratch-render/**" - "packages/scratch-svg-renderer/**" scratch-vm: + - *global - "packages/scratch-render/**" - "packages/scratch-svg-renderer/**" - "packages/scratch-vm/**" scratch-gui: + - *global - "packages/scratch-gui/**" - "packages/scratch-render/**" - "packages/scratch-svg-renderer/**" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4dde87b25e..be4b9ea05b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,9 +12,10 @@ concurrency: cancel-in-progress: true jobs: - ci: - name: Detect affected packages, build and test + build: runs-on: ubuntu-latest + outputs: + packages: ${{ steps.filter.outputs.changes }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4 @@ -37,30 +38,45 @@ jobs: with: filters: ./.github/path-filters.yml - - if: ${{ steps.filter.outputs.global == 'true' || steps.filter.outputs.any-workspace == 'true' }} + - if: ${{ steps.filter.outputs.any-workspace == 'true' }} uses: ./.github/actions/install-dependencies - name: Build packages - if: ${{ steps.filter.outputs.global == 'true' || steps.filter.outputs.any-workspace == 'true' }} + if: ${{ steps.filter.outputs.any-workspace == 'true' }} run: npm run build - - name: Test scratch-svg-renderer - if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-svg-renderer == 'true') }} - uses: ./.github/actions/test-package + - name: Store build artifacts + if: ${{ steps.filter.outputs.any-workspace == 'true' }} + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4 with: - package_name: scratch-svg-renderer - - name: Test scratch-render - if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-render == 'true') }} - uses: ./.github/actions/test-package + name: build + path: | + packages/**/build + packages/**/dist + packages/**/playground + + test: + runs-on: ubuntu-latest + needs: build + strategy: + fail-fast: false + matrix: + package: ${{ fromJSON(needs.build.outputs.packages) }} + exclude: + - package: global + - package: any-workspace + name: Test ${{ matrix.package }} + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4 with: - package_name: scratch-render - - name: Test scratch-vm - if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-vm == 'true') }} - uses: ./.github/actions/test-package + cache: 'npm' + node-version-file: '.nvmrc' + - uses: ./.github/actions/install-dependencies + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4 with: - package_name: scratch-vm - - name: Test scratch-gui - if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-gui == 'true') }} - uses: ./.github/actions/test-package + name: build + path: packages + - uses: ./.github/actions/test-package with: - package_name: scratch-gui + package_name: ${{ matrix.package }} From d39f1a435908e976666a6faf55265a6c8ac629b0 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Fri, 18 Jul 2025 07:38:00 -0700 Subject: [PATCH 5/5] ci: skip tests if nothing builds --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be4b9ea05b..5951f0ecdd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: build: runs-on: ubuntu-latest outputs: + any-workspace: ${{ steps.filter.outputs.any-workspace }} packages: ${{ steps.filter.outputs.changes }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 @@ -58,6 +59,7 @@ jobs: test: runs-on: ubuntu-latest needs: build + if: ${{ needs.build.outputs.any-workspace == 'true' }} strategy: fail-fast: false matrix: