Skip to content

Commit 2a0897d

Browse files
authored
Merge pull request #365 from smalruby/merge/scratch-gui
feat: merge upstream scratch-gui updates
2 parents e2e572f + 1e53e09 commit 2a0897d

File tree

72 files changed

+12854
-7594
lines changed

Some content is hidden

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

72 files changed

+12854
-7594
lines changed

.github/workflows/ci-cd.yml

Lines changed: 39 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: CI/CD
22

33
on:
4-
workflow_dispatch:
5-
push:
4+
pull_request: # Runs whenever a pull request is created or updated (including from another fork)
5+
push: # Runs whenever a commit is pushed to the repository...
6+
branches: [main, master, develop, hotfix/*] # ...on any of these branches
7+
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
68
concurrency:
79
group: "${{ github.workflow }} @ ${{ github.head_ref || github.ref }}"
810
cancel-in-progress: true
@@ -14,7 +16,7 @@ permissions:
1416
pull-requests: write # comment on released pull requests
1517

1618
jobs:
17-
setup:
19+
ci-cd:
1820
runs-on: ubuntu-latest
1921
env:
2022
DETECT_CHROMEDRIVER_VERSION: "true"
@@ -40,214 +42,75 @@ jobs:
4042
run: npm run setup-scratch-vm
4143
- name: Lint
4244
run: npm run test:lint
43-
- name: Cache node_modules
44-
id: cache-nodemodules
45-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
46-
with:
47-
path:
48-
node_modules
49-
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
50-
- name: Cache src/generated
51-
id: cache-generated
52-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
53-
with:
54-
path:
55-
src/generated
56-
key: ${{ runner.os }}-generated-${{ hashFiles('package-lock.json') }}
57-
- name: Cache static/microbit
58-
id: cache-static
59-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
60-
with:
61-
path:
62-
static/microbit
63-
key: ${{ runner.os }}-microbit-${{ hashFiles('package-lock.json') }}
64-
test-unit:
65-
needs: setup
66-
runs-on: ubuntu-latest
67-
env:
68-
JEST_JUNIT_OUTPUT_NAME: unit-results.xml
69-
JEST_JUNIT_OUTPUT_DIR: test-results/unit
70-
steps:
71-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
72-
- name: Cache NPM dependencies
73-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
74-
with:
75-
path:
76-
node_modules
77-
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
7845
- name: Run Unit Tests
46+
env:
47+
JEST_JUNIT_OUTPUT_NAME: unit-results.xml
48+
JEST_JUNIT_OUTPUT_DIR: test-results/unit
7949
run: npm run test:unit -- --reporters="default" --reporters="jest-junit" --coverage --coverageReporters=text --coverageReporters=lcov --maxWorkers="2"
80-
- name: Store Unit Test Results
81-
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
82-
with:
83-
name: unit-test-output
84-
path: ./test-results/*
85-
build:
86-
needs: [setup, test-unit]
87-
env:
88-
NODE_OPTIONS: --max-old-space-size=4000
89-
runs-on: ubuntu-latest
90-
steps:
91-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
92-
- uses: actions/setup-node@26961cf329f22f6837d5f54c3efd76b480300ace # v4
93-
with:
94-
cache: "npm"
95-
node-version-file: ".nvmrc"
96-
- name: Retrieve node_modules
97-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
98-
with:
99-
path:
100-
node_modules
101-
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
102-
- name: Retrieve src/generated
103-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
104-
with:
105-
path:
106-
src/generated
107-
key: ${{ runner.os }}-generated-${{ hashFiles('package-lock.json') }}
108-
- name: Retireve static/microbit
109-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
110-
with:
111-
path:
112-
static/microbit
113-
key: ${{ runner.os }}-microbit-${{ hashFiles('package-lock.json') }}
11450
- name: Run Build
11551
env:
52+
NODE_OPTIONS: --max-old-space-size=4000
11653
NODE_ENV: production
11754
run: npm run build
118-
- name: Cache Build Directory
119-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
120-
with:
121-
path:
122-
./build
123-
key: ${{ runner.os }}-build-${{ github.sha }}
124-
- name: Cache Dist Directory
125-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
126-
with:
127-
path:
128-
./dist
129-
key: ${{ runner.os }}-dist-${{ github.sha }}
13055
- name: Store Build Output
131-
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
56+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
13257
with:
13358
name: build-output
13459
path: ./build
13560
- name: Store Dist Output
136-
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
61+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
13762
with:
13863
name: dist-output
13964
path: ./dist
140-
test-integration:
141-
needs: build
142-
runs-on: ubuntu-latest
143-
env:
144-
JEST_JUNIT_OUTPUT_NAME: results.txt
145-
JEST_JUNIT_OUTPUT_DIR: test-results/integration
146-
steps:
147-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
148-
- name: Retrieve npm dependencies
149-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
150-
with:
151-
path:
152-
node_modules
153-
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
154-
- name: Retrieve Build
155-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
156-
with:
157-
path:
158-
./build
159-
key: ${{ runner.os }}-build-${{ github.sha }}
16065
- run: |
16166
for F in chrome chromium chromedriver; do
16267
which $F && $F --version || echo Not found: $F
16368
done
16469
- name: Run Integration Tests
70+
env:
71+
JEST_JUNIT_OUTPUT_NAME: integration-results.xml
72+
JEST_JUNIT_OUTPUT_DIR: test-results/integration
16573
run: npm run test:integration -- --reporters="default" --reporters="jest-junit"
166-
- name: Store Integration Test Results
167-
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
74+
- name: Store Test Results
75+
if: always() # Even if tests fail
76+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
16877
with:
169-
name: integration-test-output
170-
path: ./test-results/*
171-
deploy-gh-pages:
172-
needs: [test-integration, test-unit]
173-
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/hotfix/'))
174-
runs-on: ubuntu-latest
175-
steps:
176-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
177-
- name: Retrieve npm dependencies
178-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
179-
with:
180-
path:
181-
node_modules
182-
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
183-
- name: Retrieve Build Directory
184-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
185-
with:
186-
path:
187-
./build
188-
key: ${{ runner.os }}-build-${{ github.sha }}
78+
name: test-output
79+
path: ./test-results/* # Both unit and integration test results
80+
- run: |
81+
if [[ ${{ contains(github.ref, 'hotfix') }} == 'true' ]]; then
82+
sed -e "s|hotfix/REPLACE|${{ github.ref_name }}|" --in-place release.config.js
83+
fi
18984
- name: Deploy playground to GitHub Pages
190-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
85+
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3
86+
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
19187
with:
19288
github_token: ${{ secrets.GITHUB_TOKEN }}
19389
publish_dir: ./build
19490
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
195-
deploy-gh-pages-smalruby-app:
196-
needs: [test-integration, test-unit]
197-
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/hotfix/'))
198-
runs-on: ubuntu-latest
199-
steps:
200-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
201-
- name: Retrieve npm dependencies
202-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
203-
with:
204-
path:
205-
node_modules
206-
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
207-
- name: Retrieve Build Directory
208-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
209-
with:
210-
path:
211-
./build
212-
key: ${{ runner.os }}-build-${{ github.sha }}
21391
- name: Deploy playground to Smalruby.app GitHub Pages
214-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
92+
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3
93+
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
21594
with:
21695
deploy_key: ${{ secrets.SMALRUBY_APP_DEPLOY_KEY }}
21796
publish_dir: ./build
21897
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
21998
cname: smalruby.app
22099
external_repository: smalruby/smalruby.app
221-
deploy-gh-pages-branch:
222-
needs: [test-integration, test-unit]
223-
if: |
224-
(!(
225-
github.ref == 'refs/heads/master' ||
226-
github.ref == 'refs/heads/develop' ||
227-
startsWith(github.ref, 'refs/heads/hotfix/') ||
228-
startsWith(github.ref, 'refs/heads/dependabot/') ||
229-
startsWith(github.ref, 'refs/heads/renovate/')
230-
))
231-
runs-on: ubuntu-latest
232-
steps:
233-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
234-
- name: Retrieve npm dependencies
235-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
236-
with:
237-
path:
238-
node_modules
239-
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
240-
- name: Retrieve Build Directory
241-
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
242-
with:
243-
path:
244-
./build
245-
key: ${{ runner.os }}-build-${{ github.sha }}
246100
- name: Set branch name
247101
id: branch
248-
run: echo "::set-output name=BRANCH_NAME::${GITHUB_REF##*/}"
249-
- name: Deploy playground to GitHub Pages
250-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
102+
run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
103+
- name: Deploy playground to GitHub Pages for branch
104+
if: |
105+
(!(
106+
github.ref == 'refs/heads/develop' ||
107+
github.ref == 'refs/heads/master' ||
108+
github.ref == 'refs/heads/main' ||
109+
startsWith(github.ref, 'refs/heads/hotfix/') ||
110+
startsWith(github.ref, 'refs/heads/dependabot/') ||
111+
startsWith(github.ref, 'refs/heads/renovate/')
112+
))
113+
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3
251114
with:
252115
github_token: ${{ secrets.GITHUB_TOKEN }}
253116
publish_dir: ./build

.github/workflows/commitlint.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Lint commit messages
2+
on: [pull_request]
3+
4+
concurrency:
5+
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.sha }}"
6+
7+
jobs:
8+
commitlint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
12+
- uses: wagoid/commitlint-github-action@5ce82f5d814d4010519d15f0552aec4f17a1e1fe # v5

0 commit comments

Comments
 (0)