Skip to content

Commit 6ac7514

Browse files
committed
Merge branch 'develop' of github.com:scratchfoundation/scratch-editor into UEPR-56-UEPR-282
2 parents 23d8f54 + c1151ee commit 6ac7514

Some content is hidden

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

75 files changed

+5188
-4019
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@ runs:
1919
- name: Test
2020
working-directory: ./packages/${{ inputs.package_name }}
2121
shell: bash
22+
env:
23+
TAP_REPORTER: "junit"
24+
TAP_REPORTER_FILE: "test-results/junit.xml"
2225
run: |
2326
mkdir -p test-results
24-
npm run test | tee -a ./test-results/${{ inputs.package_name }}-test-results.txt
27+
npm run test
28+
- name: Publish test reports
29+
if: ${{ !cancelled() }}
30+
uses: EnricoMi/publish-unit-test-result-action@v2
31+
with:
32+
files: "./packages/${{ inputs.package_name }}/test-results/**/*"
33+
check_name: "Test report for ${{ inputs.package_name }}"
34+
test_file_prefix: "+packages/${{ inputs.package_name }}/"
2535
- name: Store Test Results
2636
if: ${{ !cancelled() }}
2737
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4

.github/workflows/ci.yml

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ jobs:
2727
- name: Debug info
2828
# https://docs.github.com/en/actions/reference/security/secure-use#use-an-intermediate-environment-variable
2929
env:
30-
GH_HEAD_REF: ${{ github.head_ref }}
30+
# `env:` values are printed to the log even without using them in `run:`
31+
GH_CONTEXT: ${{ toJson(github) }}
3132
run: |
3233
cat <<EOF
33-
Scratch environment: ${{ vars.SCRATCH_ENV || '<none>' }}
34+
Working directory: $(pwd)
3435
Node version: $(node --version)
3536
NPM version: $(npm --version)
36-
GitHub ref: ${{ github.ref }}
37-
GitHub head ref: ${GH_HEAD_REF}
38-
Working directory: $(pwd)
37+
Scratch environment: ${{ vars.SCRATCH_ENV || '<none>' }}
3938
EOF
4039
4140
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
@@ -87,11 +86,65 @@ jobs:
8786
with:
8887
package_name: ${{ matrix.package }}
8988

89+
preview:
90+
runs-on: ubuntu-latest
91+
needs: build
92+
# We don't want to give forks free reign to publish to our GitHub Pages, so run this job only if both:
93+
# - any workspace changed (otherwise there's no work to do)
94+
# - and either
95+
# - this is not a PR (so it's some other event that happened in our fork, like a push or merge group)
96+
# - or it's a PR from our fork (not some other fork)
97+
# - and
98+
# - it's not a Renovate branch (just to reduce noise)
99+
if: ${{
100+
(needs.build.outputs.any-workspace == 'true') &&
101+
(
102+
(!github.event.pull_request) ||
103+
(github.event.pull_request.head.repo.full_name == github.repository)
104+
) &&
105+
(!startsWith(github.ref_name, 'renovate/'))
106+
}}
107+
name: Publish preview playgrounds to GitHub Pages
108+
steps:
109+
- name: Determine GitHub Pages directory name
110+
id: branch_dir_name
111+
# even `develop` should be published to a subdirectory
112+
# that way each branch can be updated or cleaned up independently
113+
run: |
114+
echo "result=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" | tee --append "$GITHUB_OUTPUT"
115+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
116+
with:
117+
name: build
118+
path: packages
119+
- name: Prepare playgrounds for GitHub Pages
120+
working-directory: ./packages
121+
run: |
122+
mkdir -p ../pages/
123+
for pkg in *; do
124+
if [ -d "${pkg}/playground" ]; then
125+
# using symlinks is quick and artifact generation will dereference them
126+
# if the GitHub Pages action stops dereferencing these links, we'll need to copy the files instead
127+
ln -s "../packages/${pkg}/playground" "../pages/${pkg}"
128+
fi
129+
done
130+
131+
# scratch-gui doesn't follow the pattern above
132+
ln -s "../packages/scratch-gui/build" "../pages/scratch-gui"
133+
134+
ls -l ../pages/
135+
- name: Deploy playgrounds to GitHub Pages
136+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
137+
with:
138+
github_token: ${{ secrets.GITHUB_TOKEN }}
139+
publish_dir: ./pages
140+
destination_dir: "${{steps.branch_dir_name.outputs.result}}"
141+
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
142+
90143
results:
91-
name: Results
144+
name: Test Results
92145
runs-on: ubuntu-latest
93146
needs: test
94-
if: ${{ always() }}
147+
if: ${{ !cancelled() }}
95148
steps:
96149
- run: |
97150
case "${{ needs.test.result }}" in

.github/workflows/gha-debug.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: GitHub Actions debug info
2+
3+
on:
4+
branch_protection_rule:
5+
check_run:
6+
check_suite:
7+
create:
8+
delete:
9+
deployment:
10+
deployment_status:
11+
discussion:
12+
discussion_comment:
13+
fork:
14+
gollum: # Wiki page activity
15+
issue_comment:
16+
issues:
17+
label:
18+
merge_group:
19+
milestone:
20+
page_build:
21+
public:
22+
pull_request:
23+
# pull_request_comment: # use issue_comment instead
24+
pull_request_review:
25+
pull_request_review_comment:
26+
pull_request_target:
27+
push:
28+
registry_package:
29+
release:
30+
repository_dispatch:
31+
schedule:
32+
- cron: '37 9 * * 1' # Every Monday at 9:37 UTC = 4:37 AM EST / 5:37 AM EDT
33+
status:
34+
watch:
35+
workflow_call:
36+
workflow_dispatch:
37+
workflow_run:
38+
workflows: ["CI"]
39+
40+
jobs:
41+
info:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Output debug info
45+
env:
46+
github: ${{ toJson(github) }}
47+
run: |
48+
echo 'GitHub Actions debug info'
49+
echo 'See also the `env:` section above'
50+
echo "Working directory: $(pwd)"
51+
date
52+
echo ""
53+
(
54+
reportVersion() {
55+
label="$1"
56+
shift
57+
# Some tools report their version on stdout, and some on stderr
58+
# If the command is not found, stderr will be like "foo: command not found"
59+
# This should capture all of these cases
60+
version="$($@ 2>&1 | head -n 1)"
61+
echo "$label|$version"
62+
}
63+
64+
reportVersion "Tool" echo "Version"
65+
reportVersion "---" echo "---"
66+
reportVersion "Chrome" google-chrome --version
67+
reportVersion "Chromium" chromium-browser --version
68+
reportVersion "Chromedriver" chromedriver --version
69+
reportVersion "Docker" docker --version
70+
reportVersion "Docker Compose" docker compose version
71+
reportVersion "GitHub CLI" gh --version
72+
reportVersion "Git" git --version
73+
reportVersion "Go" go version
74+
reportVersion "Java" java -version
75+
reportVersion "jq" jq --version
76+
reportVersion "Node.js" node --version
77+
reportVersion "npm" npm --version
78+
reportVersion "pkg-config" pkg-config --version
79+
reportVersion "Python" python --version
80+
reportVersion "Ruby" ruby --version
81+
reportVersion "Rust" rustc --version
82+
reportVersion "Yarn" yarn --version
83+
) | column --table --separator="|"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: GitHub Pages Cleanup
2+
3+
on:
4+
schedule:
5+
- cron: 0 0 * * 6 # midnight on Saturdays
6+
workflow_dispatch:
7+
8+
jobs:
9+
cleanup:
10+
permissions:
11+
contents: write
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out GitHub Pages branch
15+
uses: actions/checkout@v4
16+
with:
17+
# replace `fetch-depth` with `shallow-since` if and when actions/checkout#619 (or an equivalent) gets merged
18+
# then remove the "Fetch a bit more history" step below
19+
fetch-depth: 1
20+
ref: gh-pages
21+
- name: Fetch a bit more history
22+
run: git fetch --update-shallow --shallow-since="32 days ago" origin gh-pages
23+
- name: Mark stale directories for removal
24+
run: |
25+
for dir in */; do
26+
[ -L "${dir%/}" ] && continue # skip symlinks (trim trailing slash for test)
27+
if [ -z "$(git log -n 1 --since "1 month ago" -- "$dir")" ]; then
28+
echo "Removing stale directory: $dir"
29+
git rm --quiet -r "$dir"
30+
fi
31+
done
32+
- name: Configure git user
33+
run: |
34+
git config user.name 'github-actions[bot]'
35+
git config user.email 'github-actions[bot]@users.noreply.github.com'
36+
- name: Commit
37+
run: |
38+
if git diff --staged --quiet; then
39+
echo 'No stale directories were found. Nothing to commit.'
40+
else
41+
git commit -m 'chore: remove stale GitHub Pages branches'
42+
fi
43+
- name: Push
44+
run: "git push"

.github/workflows/publish.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -145,35 +145,3 @@ jobs:
145145
run: |
146146
git tag -f "${{github.event.release.tag_name}}" HEAD
147147
git push -f origin "refs/tags/${{github.event.release.tag_name}}"
148-
149-
- name: Deploy scratch-svg-renderer to GitHub Pages
150-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
151-
with:
152-
github_token: ${{ secrets.GITHUB_TOKEN }}
153-
publish_dir: ./packages/scratch-svg-renderer/playground
154-
destination_dir: scratch-svg-renderer
155-
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
156-
157-
- name: Deploy scratch-render to GitHub Pages
158-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
159-
with:
160-
github_token: ${{ secrets.GITHUB_TOKEN }}
161-
publish_dir: ./packages/scratch-render/playground
162-
destination_dir: scratch-render
163-
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
164-
165-
- name: Deploy scratch-vm to GitHub Pages
166-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
167-
with:
168-
github_token: ${{ secrets.GITHUB_TOKEN }}
169-
publish_dir: ./packages/scratch-vm/playground
170-
destination_dir: scratch-vm
171-
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
172-
173-
- name: Deploy scratch-gui to GitHub Pages
174-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
175-
with:
176-
github_token: ${{ secrets.GITHUB_TOKEN }}
177-
publish_dir: ./packages/scratch-gui/build
178-
destination_dir: scratch-gui
179-
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.19.4
1+
20.19.5

0 commit comments

Comments
 (0)