Skip to content

Improve GHA workflows #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
Expand All @@ -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') }}
31 changes: 31 additions & 0 deletions .github/path-filters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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"
- "package.json"
- "package-lock.json"
- "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/**"
- "packages/scratch-vm/**"
83 changes: 39 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ concurrency:
cancel-in-progress: true

jobs:
ci:
name: Detect affected packages, build and test
build:
runs-on: ubuntu-latest
outputs:
any-workspace: ${{ steps.filter.outputs.any-workspace }}
packages: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
with:
cache: 'npm'
node-version-file: '.nvmrc'
- uses: wagoid/commitlint-github-action@9763196e10f27aef304c9b8b660d31d97fce0f99 # v5
- name: Debug info
run: |
cat <<EOF
Expand All @@ -36,54 +37,48 @@ 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"
- "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' }}
- 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
if: ${{ needs.build.outputs.any-workspace == 'true' }}
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 }}
12 changes: 12 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint commit messages
on: [pull_request]

concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.sha }}"

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: wagoid/commitlint-github-action@9763196e10f27aef304c9b8b660d31d97fce0f99 # v5
Loading