-
Notifications
You must be signed in to change notification settings - Fork 11
559 lines (472 loc) · 18 KB
/
main.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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
name: Node CI
env:
UPDATE_RESOURCES: true
REPOSITORY: ${{ github.repository }}
REF: ${{ github.ref }}
on:
push:
branches:
- master
- develop
- release-*
- sandbox-*
pull_request:
branches:
- master
- develop
- release-*
- sandbox-*
jobs:
test:
name: Test
runs-on: ubuntu-latest
container: photonomad/github_build:latest
# the Dockerfile used to create this image is here: ./.github/workflows/docker/Dockerfile
env:
CI: true
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write
steps:
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: echo "$GITHUB_CONTEXT"
- uses: actions/setup-node@v1
with:
node-version: '16.14.2'
- name: Get versions
run: |
echo "node --version"
node --version
echo "npm --version"
npm --version
echo "git --version"
git --version
echo "pwd"
pwd
# - uses: actions/checkout@v2
# - name: Checkout submodules
# shell: bash
# run: |
# auth_header="$(git config --local --get http.https://github.com/.extraheader)"
# git submodule sync --recursive
# git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Checkout codebase
uses: actions/checkout@v3
with:
submodules: recursive
persist-credentials: true
- name: npm install
run: npm ci
- name: List permissions
run: |
set -x
# create output folder with permission for tests to use for temp results
echo "mkdir ./src/__tests__/output"
mkdir ./src/__tests__/output
echo "chmod -R a+rwx ./src/__tests__/output"
chmod -R a+rwx ./src/__tests__/output
echo "remove git owner error"
git config --global --add safe.directory /__w/translationCore/translationCore
- name: npm test
run: npm run ci-test
- name: Upload coverage
run: ./node_modules/.bin/codecov -t ${{ secrets.CODECOV_TOKEN }}
- name: Run lint
run: npm run lint
- name: Parsing jsdocs
run: |
set -x
# remove jsdocs folder so it can be recreated
echo "rm -rf ./docs/translationCore"
rm -rf ./docs/translationCore
# give permission for jsdocs to be recreated in docs folder
echo "chmod -R a+rwx ./docs"
chmod -R a+rwx ./docs
ls -als ./docs
# update jsdocs
npm run doc
echo "ls -als ./docs/translationCore"
ls -als ./docs/translationCore
# - name: Update jsdocs in branch
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# file_pattern: 'docs/*'
# commit_message: Apply jsdocs update
# skip_fetch: true
# skip_checkout: true
- uses: actions/upload-artifact@v4
name: Upload jsdocs
with:
name: jsdocs
path: docs/
build-linux:
name: Build Linux
strategy:
matrix:
trim: [ 0, 1 ]
needs: test
runs-on: ubuntu-latest
container: photonomad/github_build:latest
env:
TC_HELP_DESK_TOKEN: ${{ secrets.TC_HELP_DESK_TOKEN }}
TC_HELP_DESK_EMAIL: ${{ secrets.TC_HELP_DESK_EMAIL }}
APP_NAME: tC
CI: true
TRIM: ${{ matrix.trim }}
steps:
- uses: actions/setup-node@v1
with:
node-version: '16.14.2'
- name: TRIM setting
run: echo "Trim value is $TRIM"
- name: Get version
run: |
echo "node --version"
node --version
echo "npm --version"
npm --version
echo "git --version"
git --version
echo "pwd"
pwd
# - uses: actions/checkout@v2
# - name: Checkout submodules
# shell: bash
# run: |
# auth_header="$(git config --local --get http.https://github.com/.extraheader)"
# git submodule sync --recursive
# git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Checkout codebase
uses: actions/checkout@v1
with:
submodules: recursive
- name: Read version and commit sha
run: |
echo "HASH=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
echo "APP_VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
- name: Bundle environment variables
run: |
# work around for linux permissions restrictions: save to .env.tmp and tC build script (update_env.js) will look for that file if .env is not defined
touch .env.tmp
echo "TC_HELP_DESK_TOKEN=$TC_HELP_DESK_TOKEN" >> .env.tmp
echo "TC_HELP_DESK_EMAIL=$TC_HELP_DESK_EMAIL" >> .env.tmp
echo "BUILD=$HASH" >> .env.tmp
- name: npm install
run: npm ci
- name: Download latest language names
if: env.UPDATE_RESOURCES
run: |
# TODO: remove this fix for expired certs on uw website - hack for curl crash on invalid certs, added --insecure param
curl --insecure https://td.unfoldingword.org/exports/langnames.json > src/assets/langnames.json
- name: Before Update resources - save original manifest
run: cp tcResources/source-content-updater-manifest.json source-content-updater-manifest.json.orig
- name: Update resources
if: env.UPDATE_RESOURCES
# add automatic retry
uses: nick-invision/retry@v2
with:
timeout_minutes: 20
max_attempts: 3
retry_on: error
command: npm run update-resources
# restore original manifest before retry
on_retry_command: cp source-content-updater-manifest.json.orig tcResources/source-content-updater-manifest.json
- name: Trim resources
if: ${{ env.TRIM == '1' }}
run: npm run minimal-resources
- name: build linux
id: build
run: |
echo "Building $APP_VERSION-$HASH"
npm run build-linux
# arm64
- name: Set arm64 MAX artifact name
run: echo "ARTIFACT_ARM64=$(echo "$APP_NAME-linux-arm64-$APP_VERSION-MAX-$HASH.deb")" >> $GITHUB_ENV
- name: Set arm64 LITE artifact name
if: ${{ env.TRIM == '1' }}
run: echo "ARTIFACT_ARM64=$(echo "$APP_NAME-linux-arm64-$APP_VERSION-LITE-$HASH.deb")" >> $GITHUB_ENV
- name: bundle arm64 linux
run: ./node_modules/.bin/gulp release-linux-deb-arm64 --out=artifacts/arm64/$ARTIFACT_ARM64
- uses: actions/upload-artifact@v4
name: Upload arm64 artifacts
with:
name: ${{ env.ARTIFACT_ARM64 }}
path: artifacts/arm64/
# x64
- name: Set x64 MAX artifact name
run: echo "ARTIFACT_X64=$(echo "$APP_NAME-linux-x64-$APP_VERSION-MAX-$HASH.deb")" >> $GITHUB_ENV
- name: Set x64 LITE artifact name
if: ${{ env.TRIM == '1' }}
run: echo "ARTIFACT_X64=$(echo "$APP_NAME-linux-x64-$APP_VERSION-LITE-$HASH.deb")" >> $GITHUB_ENV
- name: bundle x64 linux
run: ./node_modules/.bin/gulp release-linux-deb --out=artifacts/x64/$ARTIFACT_X64
- uses: actions/upload-artifact@v4
name: Upload x64 artifacts
with:
name: ${{ env.ARTIFACT_X64 }}
path: artifacts/x64/
build-windows:
name: Build Windows
strategy:
matrix:
trim: [ 0, 1 ]
needs: test
runs-on: windows-2019
env:
TC_HELP_DESK_TOKEN: ${{ secrets.TC_HELP_DESK_TOKEN }}
TC_HELP_DESK_EMAIL: ${{ secrets.TC_HELP_DESK_EMAIL }}
APP_NAME: tC
CI: true
TRIM: ${{ matrix.trim }}
steps:
- uses: actions/setup-node@v1
with:
node-version: '16.14.2'
- name: TRIM setting
run: echo "Trim value is $TRIM"
shell: bash
- name: Node version
run: |
node --version
npm --version
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Read version and commit sha
run: |
echo "HASH=$(node -p -e "'${{ github.sha }}'.substring(0, 7)")" >> $GITHUB_ENV
echo "APP_VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
shell: bash
- name: Bundle environment variables
run: |
touch .env
echo "TC_HELP_DESK_TOKEN=${{ env.TC_HELP_DESK_TOKEN }}" >> .env
echo "TC_HELP_DESK_EMAIL=${{ env.TC_HELP_DESK_EMAIL }}" >> .env
echo "BUILD=${{ env.HASH }}" >> .env
- name: npm install
run: |
npm ci
npm run update-env
shell: bash
- name: Download latest language names
if: env.UPDATE_RESOURCES
run: curl https://td.unfoldingword.org/exports/langnames.json > src/assets/langnames.json
- name: Before Update resources - save original manifest
shell: bash
run: cp tcResources/source-content-updater-manifest.json source-content-updater-manifest.json.orig
- name: Update resources
if: env.UPDATE_RESOURCES
# add automatic retry
uses: nick-invision/retry@v2
with:
timeout_minutes: 20
max_attempts: 3
retry_on: error
shell: bash
command: npm run update-resources
# restore original manifest before retry
on_retry_command: cp source-content-updater-manifest.json.orig tcResources/source-content-updater-manifest.json
- name: Trim resources
if: ${{ env.TRIM == '1' }}
run: npm run minimal-resources
shell: bash
- name: build windows
run: |
echo "Building $APP_VERSION-$HASH"
npm run build-win
# x64
- name: Set x64 MAX artifact name
run: echo "ARTIFACT_X64=$(echo "${{ env.APP_NAME }}-win-x64-${{ env.APP_VERSION }}-MAX-${{ env.HASH }}.exe")" >> $GITHUB_ENV
shell: bash
- name: Set x64 LITE artifact name
if: ${{ env.TRIM == '1' }}
run: echo "ARTIFACT_X64=$(echo "${{ env.APP_NAME }}-win-x64-${{ env.APP_VERSION }}-LITE-${{ env.HASH }}.exe")" >> $GITHUB_ENV
shell: bash
- name: bundle x64 windows
run: |
echo "Generating executable artifacts/x64/${{ env.ARTIFACT_X64 }}"
./node_modules/.bin/gulp release-win64 --out=artifacts/x64/${{ env.ARTIFACT_X64 }}
# - name: list directories
# run: |
# dir .
# dir ../
# dir ../artifacts
- uses: actions/upload-artifact@v4
name: Upload x64 artifacts
with:
name: ${{ env.ARTIFACT_X64 }}
path: artifacts/x64/
# x32
- name: Set x32 MAX artifact name
run: echo "ARTIFACT_X32=$(echo "${{ env.APP_NAME }}-win-x32-${{ env.APP_VERSION }}-MAX-${{ env.HASH }}.exe")" >> $GITHUB_ENV
shell: bash
- name: Set x32 LITE artifact name
if: ${{ env.TRIM == '1' }}
run: echo "ARTIFACT_X32=$(echo "${{ env.APP_NAME }}-win-x32-${{ env.APP_VERSION }}-LITE-${{ env.HASH }}.exe")" >> $GITHUB_ENV
shell: bash
- name: bundle x32 windows
run: |
echo "Generating executable artifacts/x32/${{ env.ARTIFACT_X32 }}"
./node_modules/.bin/gulp release-win32 --out=artifacts/x32/${{ env.ARTIFACT_X32 }}
- uses: actions/upload-artifact@v4
name: Upload x32 artifacts
with:
name: ${{ env.ARTIFACT_X32 }}
path: artifacts/x32/
build-macos:
name: Build macOS
strategy:
matrix:
trim: [ 0, 1 ]
needs: test
runs-on: macos-latest
env:
TC_HELP_DESK_TOKEN: ${{ secrets.TC_HELP_DESK_TOKEN }}
TC_HELP_DESK_EMAIL: ${{ secrets.TC_HELP_DESK_EMAIL }}
APP_NAME: tC
CI: true
TRIM: ${{ matrix.trim }}
steps:
- uses: actions/setup-node@v1
with:
node-version: '16.14.2'
- name: TRIM setting
run: echo "Trim value is $TRIM"
- name: add Delay
if: ${{ env.TRIM == '1' }}
run: sleep 60
shell: bash
- name: Node version
run: |
node --version
npm --version
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
# - name: Checkout codebase
# uses: actions/checkout@v1
# with:
# submodules: recursive
- name: Read version and commit sha
run: |
echo "HASH=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
echo "APP_VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
- name: Bundle environment variables
run: |
touch .env
echo "TC_HELP_DESK_TOKEN=$TC_HELP_DESK_TOKEN" >> .env
echo "TC_HELP_DESK_EMAIL=$TC_HELP_DESK_EMAIL" >> .env
echo "BUILD=$HASH" >> .env
- name: npm install
run: |
npm ci
npm run update-env
- name: Download latest language names
if: env.UPDATE_RESOURCES
run: curl https://td.unfoldingword.org/exports/langnames.json > src/assets/langnames.json
- name: Before Update resources - save original manifest
run: cp tcResources/source-content-updater-manifest.json source-content-updater-manifest.json.orig
- name: Update resources
if: env.UPDATE_RESOURCES
# add automatic retry
uses: nick-invision/retry@v2
with:
timeout_minutes: 20
max_attempts: 3
retry_on: error
command: npm run update-resources
# restore original manifest before retry
on_retry_command: cp source-content-updater-manifest.json.orig tcResources/source-content-updater-manifest.json
- name: Trim resources
if: ${{ env.TRIM == '1' }}
run: npm run minimal-resources
- name: build macOS
id: build
run: |
echo "Building $APP_VERSION-$HASH"
npm run build-macos
# x64
- name: Set x64 MAX artifact name
run: echo "ARTIFACT_X64=$(echo "$APP_NAME-macos-x64-$APP_VERSION-MAX-$HASH.dmg")" >> $GITHUB_ENV
- name: Set x64 LITE artifact name
if: ${{ env.TRIM == '1' }}
run: echo "ARTIFACT_X64=$(echo "$APP_NAME-macos-x64-$APP_VERSION-LITE-$HASH.dmg")" >> $GITHUB_ENV
- name: bundle x64 macOS
run: ./node_modules/.bin/gulp release-macos --out=artifacts/x64/$ARTIFACT_X64
- uses: actions/upload-artifact@v4
name: Upload x64 artifacts
with:
name: ${{ env.ARTIFACT_X64 }}
path: artifacts/x64/
# universal build
- name: Set universal MAX artifact name
run: echo "ARTIFACT_UNIV=$(echo "$APP_NAME-macos-universal-$APP_VERSION-MAX-$HASH.dmg")" >> $GITHUB_ENV
- name: Set universal LITE artifact name
if: ${{ env.TRIM == '1' }}
run: echo "ARTIFACT_UNIV=$(echo "$APP_NAME-macos-universal-$APP_VERSION-LITE-$HASH.dmg")" >> $GITHUB_ENV
- name: bundle universal macOS
run: ./node_modules/.bin/gulp release-macos-universal --out=artifacts/universal/$ARTIFACT_UNIV
- uses: actions/upload-artifact@v4
name: Upload universal artifacts
with:
name: ${{ env.ARTIFACT_UNIV }}
path: artifacts/universal/
notify:
name: Notify
needs: [build-macos, build-windows, build-linux]
runs-on: ubuntu-latest
steps:
- name: Get short hash
run: |
echo "SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: echo "$GITHUB_CONTEXT"
- name: Notify Zulip of pull request
if: github.event_name == 'pull_request'
env:
TOKEN: ${{ secrets.ZULIP_TOKEN }}
USER: [email protected]
ORG: unfoldingword
CHANNEL: SOFTWARE - UR/github
SUBJECT: tC builds
PR_NUMBER: ${{ github.event.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
curl -o /dev/null -s -X POST https://$ORG.zulipchat.com/api/v1/messages \
-u $USER:$TOKEN \
-d "type=stream" \
-d "to=$CHANNEL" \
-d "subject=$SUBJECT" \
-d "content=Pull request [$PR_TITLE #$PR_NUMBER](https://github.com/$REPOSITORY/pull/$PR_NUMBER) has new builds based on [$SHORT_SHA](https://github.com/$REPOSITORY/pull/$PR_NUMBER/commits/$GITHUB_SHA).
You can view logs and download artifacts from the [Checks](https://github.com/$REPOSITORY/pull/$PR_NUMBER/checks?sha=$GITHUB_SHA) tab."
- name: Get branch name
if: github.event_name == 'push'
run: echo "BRANCH=$(node -p -e "'$REF'.substr(11)")" >> $GITHUB_ENV # strips off "refs/heads/"
- name: Notify Zulip of push
if: github.event_name == 'push'
env:
TOKEN: ${{ secrets.ZULIP_TOKEN }}
USER: [email protected]
ORG: unfoldingword
CHANNEL: SOFTWARE - UR/github
SUBJECT: tC builds
run: |
curl -o /dev/null -s -X POST https://$ORG.zulipchat.com/api/v1/messages \
-u $USER:$TOKEN \
-d "type=stream" \
-d "to=$CHANNEL" \
-d "subject=$SUBJECT" \
-d "content=Branch [$BRANCH](https://github.com/$REPOSITORY/tree/$BRANCH) has new builds based on [$SHORT_SHA](https://github.com/$REPOSITORY/commit/$GITHUB_SHA).
You can view logs and download artifacts from the [Actions](https://github.com/$REPOSITORY/commit/$GITHUB_SHA/checks) tab."