-
Notifications
You must be signed in to change notification settings - Fork 1
327 lines (310 loc) Β· 10.5 KB
/
pipeline.yml
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
name: "Pipeline"
on:
workflow_dispatch:
push:
paths-ignore:
- ".github/**"
- "docs/**"
- "e2e/**"
- "**/*.test.ts"
- "README.md"
- "License.md"
- ".gitignore"
- ".prettierignore"
- ".prettierrc.json"
branches:
- main
pull_request:
paths-ignore:
- ".github/**"
- "docs/**"
- "README.md"
- "License.md"
- ".gitignore"
- ".prettierignore"
- ".prettierrc.json"
branches:
- main
# https://stackoverflow.com/questions/74117321/if-condition-in-concurrency-in-gha
# A PR will have workflows in the same group, different PRs will have workflows in different groups, and each main workflow will have different group IDs
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
code_scan:
runs-on: ubuntu-latest
steps:
- name: π Setup repo
uses: actions/checkout@v3
- name: Prettier Check
run: |
npm i [email protected]
npx prettier --check .
- name: Typescript Check
working-directory: sudokuru
run: npx tsc
app_preview_dev:
if: ${{ contains(fromJSON('["pull_request"]'), github.event_name)}}
runs-on: ubuntu-latest
needs: [ code_scan, analyze ]
steps:
- name: π Setup repo
uses: actions/checkout@v3
- name: π Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Setup Changelog
uses: ./.github/workflows/composite-actions/set-changelog-date
- name: π Setup Expo
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: π¦ Install dependencies
run: npm ci
- name: π Publish App preview
uses: expo/expo-github-action/preview@v8
with:
working-directory: sudokuru
command: eas update --branch preview --message "${{ github.event.pull_request.title }}"
- name: Cloudflare dev preview deployment
id: deployment
uses: ./.github/workflows/composite-actions/cloudflare-deployment
with:
project-name: sudokuru-dev
account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- name: Post comment with preview link
uses: KeisukeYamashita/create-comment@v1
with:
check-only-first-line: true
comment: |
Preview Website for PR:
${{ steps.deployment.outputs.url }}
website_test_dev:
runs-on: ubuntu-latest
needs: [ code_scan, analyze ]
steps:
- name: π Setup repo
uses: actions/checkout@v3
- name: π Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: install dependencies
run: npm i
- name: Setup Changelog
uses: ./.github/workflows/composite-actions/set-changelog-date
- uses: JarvusInnovations/background-action@v1
name: Bootstrap System Under Test (SUT)
with:
run: npm run web &
wait-on: http://localhost:8081
wait-for: 5m
log-output-if: true
- name: Install Playwright Browsers
run: npm run playwright:init --with-deps
- name: Playwright run
run: npm run playwright:test:chrome
working-directory: e2e/web
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: e2e/web/playwright-report/results.xml
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: PlaywrightTestResults
path: e2e/web/test-results/*
- name: Upload coverage reports to Codecov
if: always()
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# https://github.com/codacy/codacy-coverage-reporter/issues/506
# codacy does not allow uploading of codacy.json files directly without API endpoint
# - name: Run codacy-coverage-reporter
# if: always()
# uses: codacy/[email protected]
# with:
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# coverage-reports: test-results/coverage/codacy.json
app_build_android:
runs-on: ubuntu-latest
needs: [ code_scan, analyze ]
steps:
- name: π Setup repo
uses: actions/checkout@v3
- name: π Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Setup Changelog
uses: ./.github/workflows/composite-actions/set-changelog-date
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: π Setup Expo and EAS
uses: expo/expo-github-action@v8
with:
expo-version: latest
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: π¦ Install dependencies
run: npm ci
- name: π Build app
run: eas build --non-interactive --platform android --local
working-directory: sudokuru
env:
EAS_LOCAL_BUILD_ARTIFACTS_DIR: Build
- name: Upload binary Artifact
uses: actions/upload-artifact@v3
with:
name: android binary
path: sudokuru/Build/*.apk
app_build_desktop:
strategy:
fail-fast: false
matrix:
platform: [ [linux, ubuntu-20.04], [windows, windows-latest] ]
runs-on: ${{ matrix.platform[1] }}
needs: [ code_scan, analyze ]
steps:
- uses: actions/checkout@v3
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Setup Changelog
uses: ./.github/workflows/composite-actions/set-changelog-date
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: install ubuntu dependencies
if: matrix.platform[1] == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
- name: install frontend dependencies
run: npm ci
- uses: tauri-apps/tauri-action@v0
id: tauri_build
with:
tauriScript: npm run tauri:run
- name: Upload ${{ matrix.platform[0] }} Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.platform[0] }} binary
path: "${{ join(fromJSON(steps.tauri_build.outputs.artifactPaths), '\n') }}"
deploy_app_dev:
name: Deploy Dev app to Itch.io
strategy:
fail-fast: false
matrix:
binary_name: [linux, windows, android]
needs: [ app_build_android, website_test_dev, app_build_desktop ]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Download binary Artifact
uses: actions/download-artifact@v3
with:
name: ${{matrix.binary_name}} binary
path: bundle
- name: Install Butler
run: |
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
unzip butler.zip
chmod +x butler
./butler -V
- name: Update Itch.io ${{matrix.binary_name}} Alpha App
run: ./butler push bundle ${{secrets.ITCH_USERNAME}}/${{secrets.ITCH_GAME_ID}}:alpha-${{matrix.binary_name}}
env:
BUTLER_API_KEY: ${{secrets.BUTLER_API_KEY}}
deploy_app_prod:
name: Deploy Prod app to Itch.io
strategy:
fail-fast: false
matrix:
binary_name: [linux, windows, android]
needs: [ deploy_website_dev, deploy_app_dev ]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Download binary Artifact
uses: actions/download-artifact@v3
with:
name: ${{matrix.binary_name}} binary
path: bundle
- name: Install Butler
run: |
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
unzip butler.zip
chmod +x butler
./butler -V
- name: Update Itch.io ${{matrix.binary_name}} Prod App
run: ./butler push bundle ${{secrets.ITCH_USERNAME}}/${{secrets.ITCH_GAME_ID}}:stable-${{matrix.binary_name}}
env:
BUTLER_API_KEY: ${{secrets.BUTLER_API_KEY}}
deploy_website_dev:
name: Deploy Dev Website
needs: [ app_build_android, website_test_dev, app_build_desktop ]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- run: npm ci
- name: Setup Changelog
uses: ./.github/workflows/composite-actions/set-changelog-date
- name: Cloudflare dev preview deployment
id: deployment
uses: ./.github/workflows/composite-actions/cloudflare-deployment
with:
project-name: sudokuru-dev
account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
deploy_website_prod:
name: Deploy Prod Website
needs: [ deploy_website_dev, deploy_app_dev ]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- run: npm ci
- name: Setup Changelog
uses: ./.github/workflows/composite-actions/set-changelog-date
- name: Cloudflare dev preview deployment
id: deployment
uses: ./.github/workflows/composite-actions/cloudflare-deployment
with:
project-name: sudokuru
account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}