@@ -12,78 +12,100 @@ concurrency:
12
12
cancel-in-progress : true
13
13
14
14
jobs :
15
- ci :
16
- name : Detect affected packages, build and test
15
+ build :
16
+ name : Build
17
17
runs-on : ubuntu-latest
18
+ outputs :
19
+ any-workspace : ${{ steps.filter.outputs.any-workspace }}
20
+ packages : ${{ steps.filter.outputs.changes }}
18
21
steps :
19
22
- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
20
23
- uses : actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
21
24
with :
22
25
cache : ' npm'
23
26
node-version-file : ' .nvmrc'
24
- - uses : wagoid/commitlint-github-action@9763196e10f27aef304c9b8b660d31d97fce0f99 # v5
25
27
- name : Debug info
28
+ # https://docs.github.com/en/actions/reference/security/secure-use#use-an-intermediate-environment-variable
29
+ env :
30
+ GH_HEAD_REF : ${{ github.head_ref }}
26
31
run : |
27
32
cat <<EOF
28
33
Scratch environment: ${{ vars.SCRATCH_ENV || '<none>' }}
29
34
Node version: $(node --version)
30
35
NPM version: $(npm --version)
31
36
GitHub ref: ${{ github.ref }}
32
- GitHub head ref: ${{ github.head_ref } }
37
+ GitHub head ref: ${GH_HEAD_REF }
33
38
Working directory: $(pwd)
34
39
EOF
35
40
36
41
- uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
37
42
id : filter
38
43
with :
39
- # Files in the `global` filter affect all workspaces, even if workspace-specific files have not changed.
40
- filters : |
41
- global:
42
- - ".github/workflows/ci.yml"
43
- - "package.json"
44
- - "package-lock.json"
45
- - "scripts/**"
46
- any-workspace:
47
- - "packages/**"
48
- scratch-svg-renderer:
49
- - "packages/scratch-svg-renderer/**"
50
- scratch-render:
51
- - "packages/scratch-render/**"
52
- - "packages/scratch-svg-renderer/**"
53
- scratch-vm:
54
- - "packages/scratch-render/**"
55
- - "packages/scratch-svg-renderer/**"
56
- - "packages/scratch-vm/**"
57
- scratch-gui:
58
- - "packages/scratch-gui/**"
59
- - "packages/scratch-render/**"
60
- - "packages/scratch-svg-renderer/**"
61
- - "packages/scratch-vm/**"
44
+ filters : ./.github/path-filters.yml
62
45
63
- - if : ${{ steps.filter.outputs.global == 'true' || steps.filter.outputs. any-workspace == 'true' }}
46
+ - if : ${{ steps.filter.outputs.any-workspace == 'true' }}
64
47
uses : ./.github/actions/install-dependencies
65
48
66
49
- name : Build packages
67
- if : ${{ steps.filter.outputs.global == 'true' || steps.filter.outputs. any-workspace == 'true' }}
50
+ if : ${{ steps.filter.outputs.any-workspace == 'true' }}
68
51
run : npm run build
69
52
70
- - name : Test scratch-svg-renderer
71
- if : ${{ !cancelled() && ( steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-svg-renderer == 'true') }}
72
- uses : ./.github/ actions/test-package
53
+ - name : Store build artifacts
54
+ if : ${{ steps.filter.outputs.any-workspace == 'true' }}
55
+ uses : actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4
73
56
with :
74
- package_name : scratch-svg-renderer
75
- - name : Test scratch-render
76
- if : ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-render == 'true') }}
77
- uses : ./.github/actions/test-package
57
+ name : build
58
+ path : |
59
+ packages/**/build
60
+ packages/**/dist
61
+ packages/**/playground
62
+
63
+ test :
64
+ runs-on : ubuntu-latest
65
+ needs : build
66
+ if : ${{ needs.build.outputs.any-workspace == 'true' }}
67
+ strategy :
68
+ fail-fast : false
69
+ matrix :
70
+ package : ${{ fromJSON(needs.build.outputs.packages) }}
71
+ exclude :
72
+ - package : global
73
+ - package : any-workspace
74
+ name : Test ${{ matrix.package }}
75
+ steps :
76
+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
77
+ - uses : actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
78
78
with :
79
- package_name : scratch-render
80
- - name : Test scratch-vm
81
- if : ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-vm == 'true') }}
82
- uses : ./.github/ actions/test-package
79
+ cache : ' npm '
80
+ node-version-file : ' .nvmrc '
81
+ - uses : ./.github/actions/install-dependencies
82
+ - uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
83
83
with :
84
- package_name : scratch-vm
85
- - name : Test scratch-gui
86
- if : ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-gui == 'true') }}
87
- uses : ./.github/actions/test-package
84
+ name : build
85
+ path : packages
86
+ - uses : ./.github/actions/test-package
88
87
with :
89
- package_name : scratch-gui
88
+ package_name : ${{ matrix.package }}
89
+
90
+ results :
91
+ name : Results
92
+ runs-on : ubuntu-latest
93
+ needs : test
94
+ if : ${{ always() }}
95
+ steps :
96
+ - run : |
97
+ case "${{ needs.test.result }}" in
98
+ success)
99
+ echo "Tests passed successfully."
100
+ exit 0
101
+ ;;
102
+ skipped)
103
+ echo "Tests were unnecessary for these changes, so they were skipped."
104
+ echo "If this is unexpected, check the path filters."
105
+ exit 0
106
+ ;;
107
+ *)
108
+ echo "Tests failed."
109
+ exit 1
110
+ ;;
111
+ esac
0 commit comments