-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (89 loc) · 3.06 KB
/
ci.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
#
# GitHub Action Workflow
# reference: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
#
# useful example: https://github.com/mikeal/bundle-size-action/blob/master/.github/workflows/mikeals-workflow.yml
#
name: Build and Test
on:
# see also https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662
push:
branches:
- main
- next
pull_request:
branches:
- main
env:
# TODO: forces AVA (and other) to print colorized output, better solution?
FORCE_COLOR: true
jobs:
build:
name: Unit tests
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
node-version: [ 20.x ]
runs-on: ${{ matrix.os }}
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
# https://github.com/actions/setup-node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# consider built-in cache feature
# see https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data
- name: Cache node_modules
# https://github.com/actions/cache
# TODO: https://github.com/actions/cache/blob/main/examples.md#node---npm
# TODO: https://github.com/actions/cache/blob/main/examples.md#node---yarn
uses: actions/cache@v3
id: cache
with:
path: |
node_modules
key: ${{ runner.os }}-node-${{ matrix.node-version }}-node_modules-${{ hashFiles('yarn.lock') }}
- name: Install dependencies
# skip if cache was restored
# see https://github.com/actions/cache#skipping-steps-based-on-cache-hit
if: steps.cache.outputs.cache-hit != 'true'
# note: Yarn in pre-installed in the VM image
# (see https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md)
run: yarn --frozen-lockfile
- name: Run unit tests
# https://askubuntu.com/a/731237
run: |
mkdir -p temp
yarn test |& tee temp/ava-test-output.txt
shell: bash
- name: Run ESLint
if: ${{ success() || failure() }}
run: |
mkdir -p temp
yarn lint |& tee temp/eslint-output.txt
shell: bash
- name: Run tsc for main code
if: ${{ success() || failure() }}
run: |
mkdir -p temp
yarn tsc |& tee temp/tsc-root-output.txt
shell: bash
- name: Run tsc for sw code
if: ${{ success() || failure() }}
run: |
mkdir -p temp
yarn tsc -p app/sw/ |& tee temp/tsc-sw-output.txt
shell: bash
- name: Store test results
if: ${{ success() || failure() }}
# https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v3
with:
name: test-results
path: |
temp/ava-test-output.txt
temp/eslint-output.txt
temp/tsc-output.txt