Skip to content

Commit 30afc3c

Browse files
committed
Merge branch 'develop' into spork
2 parents 26ffd97 + 19a7e7f commit 30afc3c

File tree

101 files changed

+3594
-3630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+3594
-3630
lines changed

.github/actions/install-dependencies/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ runs:
3333
packages/*/node_modules
3434
packages/*/src/generated
3535
packages/scratch-gui/static/microbit
36-
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
36+
key: ${{ runner.os }}-npm-${{ hashFiles('.nvmrc', 'package-lock.json') }}
3737
- if: steps.restore-node-modules-cache.outputs.cache-hit != 'true'
3838
name: Install NPM dependencies
3939
working-directory: .
@@ -47,4 +47,4 @@ runs:
4747
packages/*/node_modules
4848
packages/*/src/generated
4949
packages/scratch-gui/static/microbit
50-
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
50+
key: ${{ runner.os }}-npm-${{ hashFiles('.nvmrc', 'package-lock.json') }}

.github/actions/test-package/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Test package
22

3+
description: Test one of the packages in this monorepo.
4+
35
inputs:
46
package_name:
57
description: The name of the tested package

.github/actions/update-i18n/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Update i18n
22

3+
description: Update i18n files for one of the packages in this monorepo.
4+
35
inputs:
46
package_name:
57
description: The name of the updated package

.github/path-filters.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# The `&global` anchor defines a set of common paths to include by reference in the other filters.
2+
global: &global
3+
- ".github/path-filters.yml"
4+
- ".github/workflows/ci.yml"
5+
- ".nvmrc"
6+
- "package.json"
7+
- "package-lock.json"
8+
- "scripts/**"
9+
10+
any-workspace:
11+
- *global
12+
- "packages/**"
13+
14+
scratch-svg-renderer:
15+
- *global
16+
- "packages/scratch-svg-renderer/**"
17+
scratch-render:
18+
- *global
19+
- "packages/scratch-render/**"
20+
- "packages/scratch-svg-renderer/**"
21+
scratch-vm:
22+
- *global
23+
- "packages/scratch-render/**"
24+
- "packages/scratch-svg-renderer/**"
25+
- "packages/scratch-vm/**"
26+
scratch-gui:
27+
- *global
28+
- "packages/scratch-gui/**"
29+
- "packages/scratch-render/**"
30+
- "packages/scratch-svg-renderer/**"
31+
- "packages/scratch-vm/**"

.github/workflows/ci.yml

Lines changed: 106 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -12,81 +12,96 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
ci:
16-
name: Detect affected packages, build and test
15+
build:
16+
name: Build
1717
runs-on: ubuntu-latest
18+
outputs:
19+
any-workspace: ${{ steps.filter.outputs.any-workspace }}
20+
packages: ${{ steps.filter.outputs.changes }}
1821
steps:
1922
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
20-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
23+
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
2124
with:
2225
cache: 'npm'
2326
node-version-file: '.nvmrc'
2427
- 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 }}
2531
run: |
2632
cat <<EOF
2733
Scratch environment: ${{ vars.SCRATCH_ENV || '<none>' }}
2834
Node version: $(node --version)
2935
NPM version: $(npm --version)
3036
GitHub ref: ${{ github.ref }}
31-
GitHub head ref: ${{ github.head_ref }}
37+
GitHub head ref: ${GH_HEAD_REF}
3238
Working directory: $(pwd)
3339
EOF
3440
3541
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
3642
id: filter
3743
with:
38-
# Files in the `global` filter affect all workspaces, even if workspace-specific files have not changed.
39-
filters: |
40-
global:
41-
- ".github/workflows/ci.yml"
42-
- "package.json"
43-
- "package-lock.json"
44-
- "scripts/**"
45-
any-workspace:
46-
- "packages/**"
47-
scratch-svg-renderer:
48-
- "packages/scratch-svg-renderer/**"
49-
scratch-render:
50-
- "packages/scratch-render/**"
51-
- "packages/scratch-svg-renderer/**"
52-
scratch-vm:
53-
- "packages/scratch-render/**"
54-
- "packages/scratch-svg-renderer/**"
55-
- "packages/scratch-vm/**"
56-
scratch-gui:
57-
- "packages/scratch-gui/**"
58-
- "packages/scratch-render/**"
59-
- "packages/scratch-svg-renderer/**"
60-
- "packages/scratch-vm/**"
44+
filters: ./.github/path-filters.yml
6145

62-
- if: ${{ steps.filter.outputs.global == 'true' || steps.filter.outputs.any-workspace == 'true' }}
46+
- if: ${{ steps.filter.outputs.any-workspace == 'true' }}
6347
uses: ./.github/actions/install-dependencies
6448

6549
- name: Build packages
66-
if: ${{ steps.filter.outputs.global == 'true' || steps.filter.outputs.any-workspace == 'true' }}
50+
if: ${{ steps.filter.outputs.any-workspace == 'true' }}
6751
run: npm run build
6852

69-
- name: Test scratch-svg-renderer
70-
if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-svg-renderer == 'true') }}
71-
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
7256
with:
73-
package_name: scratch-svg-renderer
74-
- name: Test scratch-render
75-
if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-render == 'true') }}
76-
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
7778
with:
78-
package_name: scratch-render
79-
- name: Test scratch-vm
80-
if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-vm == 'true') }}
81-
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
8283
with:
83-
package_name: scratch-vm
84-
- name: Test scratch-gui
85-
if: ${{ !cancelled() && (steps.filter.outputs.global == 'true' || steps.filter.outputs.scratch-gui == 'true') }}
86-
uses: ./.github/actions/test-package
84+
name: build
85+
path: packages
86+
- uses: ./.github/actions/test-package
8787
with:
88-
package_name: scratch-gui
88+
package_name: ${{ matrix.package }}
8989

90+
preview:
91+
runs-on: ubuntu-latest
92+
needs:
93+
- build
94+
- test
95+
if: ${{ needs.build.outputs.any-workspace == 'true' }}
96+
strategy:
97+
fail-fast: false
98+
matrix:
99+
package: ${{ fromJSON(needs.build.outputs.packages) }}
100+
exclude:
101+
- package: global
102+
- package: any-workspace
103+
name: Preview ${{ matrix.package }} on GH Pages
104+
steps:
90105
- name: Determine GitHub Pages directory name
91106
id: branch_dir_name
92107
run: |
@@ -95,35 +110,55 @@ jobs:
95110
else
96111
echo "result=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}"
97112
fi | tee --append "$GITHUB_OUTPUT"
98-
99-
- name: Deploy scratch-svg-renderer to GitHub Pages
100-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
101-
with:
102-
github_token: ${{ secrets.GITHUB_TOKEN }}
103-
publish_dir: ./packages/scratch-svg-renderer/playground
104-
destination_dir: "${{steps.branch_dir_name.outputs.result}}/scratch-svg-renderer"
105-
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
106-
107-
- name: Deploy scratch-render to GitHub Pages
108-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
113+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
109114
with:
110-
github_token: ${{ secrets.GITHUB_TOKEN }}
111-
publish_dir: ./packages/scratch-render/playground
112-
destination_dir: "${{steps.branch_dir_name.outputs.result}}/scratch-render"
113-
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
114-
115-
- name: Deploy scratch-vm to GitHub Pages
115+
name: build
116+
path: packages
117+
- name: Deploy ${{ matrix.package }} testing playground to GitHub Pages
116118
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
117119
with:
118120
github_token: ${{ secrets.GITHUB_TOKEN }}
119-
publish_dir: ./packages/scratch-vm/playground
120-
destination_dir: "${{steps.branch_dir_name.outputs.result}}/scratch-vm"
121+
publish_dir: ./packages/${{ matrix.package }}/playground
122+
destination_dir: "${{steps.branch_dir_name.outputs.result}}/${{ matrix.package }}"
121123
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
122124

123-
- name: Deploy scratch-gui to GitHub Pages
124-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
125-
with:
126-
github_token: ${{ secrets.GITHUB_TOKEN }}
127-
publish_dir: ./packages/scratch-gui/build
128-
destination_dir: "${{steps.branch_dir_name.outputs.result}}/scratch-gui"
129-
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
125+
results:
126+
name: Results
127+
runs-on: ubuntu-latest
128+
needs:
129+
- test
130+
- preview
131+
if: ${{ always() }}
132+
steps:
133+
- run: |
134+
case "${{ needs.test.result }}" in
135+
success)
136+
echo "Tests passed successfully."
137+
exit 0
138+
;;
139+
skipped)
140+
echo "Tests were unnecessary for these changes, so they were skipped."
141+
echo "If this is unexpected, check the path filters."
142+
exit 0
143+
;;
144+
*)
145+
echo "Tests failed."
146+
exit 1
147+
;;
148+
esac
149+
- run: |
150+
case "${{ needs.preview.result }}" in
151+
success)
152+
echo "GitHub Pages previews published successfully."
153+
exit 0
154+
;;
155+
skipped)
156+
echo "Previews were unnecessary for these changes, so they were skipped."
157+
echo "If this is unexpected, check the path filters."
158+
exit 0
159+
;;
160+
*)
161+
echo "Publishing GitHub Pages previews failed."
162+
exit 1
163+
;;
164+
esac

.github/workflows/commitlint.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: Lint commit messages
22
on: [pull_request]
33

4+
concurrency:
5+
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.sha }}"
6+
47
jobs:
58
commitlint:
69
runs-on: ubuntu-latest
710
steps:
811
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
9-
- uses: wagoid/commitlint-github-action@5ce82f5d814d4010519d15f0552aec4f17a1e1fe # v5
12+
- uses: wagoid/commitlint-github-action@9763196e10f27aef304c9b8b660d31d97fce0f99 # v5

.github/workflows/publish.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,39 @@ jobs:
7272
npm version "$NEW_VERSION" --no-git-tag-version
7373
git add package* && git commit -m "chore(release): $NEW_VERSION [skip ci]"
7474
75-
- name: Build packages
76-
run: npm run build
75+
# Install dependencies after the version update so that
76+
# the build outputs refer to the newest version of inner packages
77+
- uses: ./.github/actions/install-dependencies
7778

7879
- name: Publish scratch-svg-renderer
79-
run: npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-svg-renderer
80+
run: |
81+
npm run build --workspace @scratch/scratch-svg-renderer
82+
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-svg-renderer
8083
env:
8184
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
8285

8386
- name: Publish scratch-render
84-
run: npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-render
87+
run: |
88+
npm run build --workspace @scratch/scratch-render
89+
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-render
8590
env:
8691
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
8792

8893
- name: Publish scratch-vm
89-
run: npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-vm
94+
run: |
95+
npm run build --workspace @scratch/scratch-vm
96+
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-vm
9097
env:
9198
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
9299

93100
- name: Publish scratch-gui
94-
run: npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-gui
101+
run: |
102+
cp ./packages/scratch-gui/package.json ./packages/scratch-gui/package-copy.json
103+
104+
jq 'del(.exports["./standalone"])' ./packages/scratch-gui/package.json | npx sponge ./packages/scratch-gui/package.json
105+
106+
npm run build:dist --workspace @scratch/scratch-gui
107+
npm publish --access=public --tag="${{steps.npm_tag.outputs.npm_tag}}" --workspace=@scratch/scratch-gui
95108
env:
96109
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
97110

.github/workflows/signature-assistant.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
issue_comment:
44
types: [created]
55
pull_request_target:
6-
types: [opened,closed,synchronize]
6+
types: [opened, closed, synchronize]
77

88
permissions:
99
actions: write
@@ -13,19 +13,26 @@ permissions:
1313

1414
jobs:
1515
CLA-Assistant:
16+
if: |
17+
github.event_name == 'pull_request_target' ||
18+
(
19+
github.event.comment.body == 'recheck' ||
20+
github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA'
21+
)
1622
runs-on: ubuntu-latest
1723
steps:
24+
- uses: scratchfoundation/scratch-agreements/.github/actions/cla-allowlist@main
25+
id: cla-allowlist
1826
- name: "CLA Assistant"
19-
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
2027
uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 # v2.6.1
2128
env:
2229
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2330
# the below token should have repo scope and must be manually added by you in the repository's secrets
2431
PERSONAL_ACCESS_TOKEN: ${{ secrets.GHA_AGREEMENTS_PAT }}
2532
with:
26-
remote-organization-name: 'scratchfoundation'
27-
remote-repository-name: 'scratch-agreements'
28-
path-to-signatures: 'signatures/version1/cla.json'
29-
path-to-document: 'https://github.com/scratchfoundation/scratch-agreements/blob/main/CLA.md'
30-
branch: 'main'
31-
allowlist: semantic-release-bot,*[bot]
33+
remote-organization-name: "scratchfoundation"
34+
remote-repository-name: "scratch-agreements"
35+
path-to-signatures: "signatures/version1/cla.json"
36+
path-to-document: "https://github.com/scratchfoundation/scratch-agreements/blob/main/CLA.md"
37+
branch: "main"
38+
allowlist: ${{ steps.cla-allowlist.outputs.allowlist }}

0 commit comments

Comments
 (0)