This repository was archived by the owner on May 18, 2026. It is now read-only.
forked from scratchfoundation/scratch-gui
-
-
Notifications
You must be signed in to change notification settings - Fork 16
218 lines (214 loc) · 10.3 KB
/
Copy pathci-cd.yml
File metadata and controls
218 lines (214 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: CI/CD
on:
pull_request: # Runs whenever a pull request is created or updated (including from another fork)
push: # Runs whenever a commit is pushed to the repository...
branches: [main, master, develop, hotfix/*] # ...on any of these branches
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
concurrency:
group: "${{ github.workflow }} @ ${{ github.head_ref || github.ref }}"
cancel-in-progress: true
permissions:
contents: write # publish a GitHub release
pages: write # deploy to GitHub Pages
issues: write # comment on released issues
pull-requests: write # comment on released pull requests
jobs:
test:
runs-on: ubuntu-latest
if: |
(!(
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/main'
))
env:
JEST_JUNIT_OUTPUT_DIR: test-results
NODE_OPTIONS: --max-old-space-size=4000
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/setup-node@26961cf329f22f6837d5f54c3efd76b480300ace # v4
with:
cache: "npm"
node-version-file: ".nvmrc"
- name: Info
run: |
cat <<EOF
Node version: $(node --version)
NPM version: $(npm --version)
GitHub ref: ${{ github.ref }}
GitHub head ref: ${{ github.head_ref }}
EOF
- name: Install Dependencies
run: npm ci
- name: Build scratch-vm for smalruby
run: npm run setup-scratch-vm
- name: Lint
run: npm run test:lint
- name: Run Unit Tests
env:
JEST_JUNIT_OUTPUT_NAME: unit-results.xml
JEST_JUNIT_OUTPUT_DIR: test-results/unit
run: npm run test:unit -- --reporters="default" --reporters="jest-junit" --coverage --coverageReporters=text --coverageReporters=lcov --maxWorkers="2"
- name: Store Test Results
if: always() # Even if tests fail
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: test-output-unit
path: ./test-results/*
build-and-deploy:
runs-on: ubuntu-latest
env:
DETECT_CHROMEDRIVER_VERSION: "true"
JEST_JUNIT_OUTPUT_DIR: test-results
NODE_OPTIONS: --max-old-space-size=4000
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/setup-node@26961cf329f22f6837d5f54c3efd76b480300ace # v4
with:
cache: "npm"
node-version-file: ".nvmrc"
- name: Info
run: |
cat <<EOF
Node version: $(node --version)
NPM version: $(npm --version)
GitHub ref: ${{ github.ref }}
GitHub head ref: ${{ github.head_ref }}
EOF
- name: Install Dependencies
run: npm ci
- name: Build scratch-vm for smalruby
run: npm run setup-scratch-vm
- name: Run Build
env:
NODE_OPTIONS: --max-old-space-size=4000
NODE_ENV: production
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
MESH_GRAPHQL_ENDPOINT: ${{ secrets.MESH_GRAPHQL_ENDPOINT }}
MESH_API_KEY: ${{ secrets.MESH_API_KEY }}
MESH_AWS_REGION: ${{ secrets.MESH_AWS_REGION }}
run: npm run build
- name: Store Build Output
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: build-output
path: ./build
- name: Store Dist Output
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: dist-output
path: ./dist
- name: Check installed browser
if: |
(!(
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/main'
))
run: |
for F in chrome chromium chromedriver; do
which $F && $F --version || echo Not found: $F
done
- name: Run Integration Tests
if: |
(!(
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/main'
))
env:
JEST_JUNIT_OUTPUT_NAME: integration-results.xml
JEST_JUNIT_OUTPUT_DIR: test-results/integration
run: npm run test:integration -- --reporters="default" --reporters="jest-junit"
- name: Store Test Results
if: always() # Even if tests fail
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: test-output-integration
path: ./test-results/*
- run: |
if [[ ${{ contains(github.ref, 'hotfix') }} == 'true' ]]; then
sed -e "s|hotfix/REPLACE|${{ github.ref_name }}|" --in-place release.config.js
fi
- name: Prepare deployment files
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
run: touch build/.nojekyll
- name: Deploy playground to Smalruby.app GitHub Pages
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
with:
deploy_key: ${{ secrets.SMALRUBY_APP_DEPLOY_KEY }}
publish_dir: ./build
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
cname: smalruby.app
external_repository: smalruby/smalruby.app
- name: Rebuild for smalruby3-gui GitHub Pages
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
env:
PUBLIC_PATH: /smalruby3-gui/
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
MESH_GRAPHQL_ENDPOINT: ${{ secrets.MESH_GRAPHQL_ENDPOINT }}
MESH_API_KEY: ${{ secrets.MESH_API_KEY }}
MESH_AWS_REGION: ${{ secrets.MESH_AWS_REGION }}
run: npm exec node ./scripts/postbuild.mjs
- name: Prepare deployment files for smalruby3-gui GitHub Pages
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
run: rm -f build/CNAME
- name: Deploy playground to GitHub Pages
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
- name: Set branch name
id: branch
run: echo "BRANCH_NAME=${{ github.head_ref || github.ref_name }}" >> $GITHUB_OUTPUT
- name: Rebuild for branch GitHub Pages
if: |
(!(
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/hotfix/') ||
startsWith(github.ref, 'refs/heads/dependabot/') ||
startsWith(github.ref, 'refs/heads/renovate/')
))
env:
PUBLIC_PATH: /smalruby3-gui/${{ steps.branch.outputs.BRANCH_NAME }}/
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
MESH_GRAPHQL_ENDPOINT: ${{ secrets.MESH_GRAPHQL_ENDPOINT }}
MESH_API_KEY: ${{ secrets.MESH_API_KEY }}
MESH_AWS_REGION: ${{ secrets.MESH_AWS_REGION }}
run: npm exec node ./scripts/postbuild.mjs
- name: Prepare deployment files for branch GitHub Pages
if: |
(!(
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/hotfix/') ||
startsWith(github.ref, 'refs/heads/dependabot/') ||
startsWith(github.ref, 'refs/heads/renovate/')
))
run: touch build/.nojekyll
- name: Deploy playground to GitHub Pages for branch
if: |
(!(
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/hotfix/') ||
startsWith(github.ref, 'refs/heads/dependabot/') ||
startsWith(github.ref, 'refs/heads/renovate/')
))
uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
full_commit_message: "Build for ${{ steps.branch.outputs.BRANCH_NAME }} (${{ github.sha }}) ${{ github.event.head_commit.message }}"
destination_dir: ${{ steps.branch.outputs.BRANCH_NAME }}
keep_files: true