-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (95 loc) · 2.7 KB
/
build-and-test.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
name: Build, test, and publish
on:
workflow_call:
inputs:
fetch-depth:
required: true
type: number
pre-run-function:
required: false
type: string
default: |
tyras_pre_run ()
{
echo 'No pre-run.'
}
post-run-function:
required: false
type: string
default: |
tyras_post_run ()
{
cd "$1"
cp ../LICENSE ./LICENSE.txt
# Note - yarn doesn't have functionality to install package without saving it to package.json (!)
# So we use global install instead.
yarn global add "@jsdevtools/npm-publish@$(cat ../versions/npm-publish)"
npm-publish --dry-run --access public
}
secrets:
npm-publish-token:
required: false
jobs:
build_and_test:
strategy:
matrix:
dir:
- endpoint
- endpoint-spec
- server
- server-test-support
- state
runs-on: ubuntu-latest
name: Build and test ${{ matrix.dir }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: ${{ inputs.fetch-depth }}
- id: prepare
name: Prepare ${{ matrix.dir }}
shell: bash
run: |
set -e
${{ inputs.pre-run-function }}
tyras_pre_run '${{ matrix.dir }}'
- id: install
name: Install dependencies of ${{ matrix.dir }}
shell: bash
run: |
set -e
./scripts/install.sh '${{ matrix.dir }}' --frozen-lockfile
- id: test
name: Test ${{ matrix.dir }}
shell: bash
run: |
set -e
./scripts/test.sh '${{ matrix.dir }}' coverage
# Run build *after* tests - since tests no longer require transpiled JS to run
# We still want to run build to catch any TS error possibly lurking somewhere.
- id: compile
name: Compile ${{ matrix.dir }}
shell: bash
run: |
set -e
./scripts/build.sh '${{ matrix.dir }}' ci
- id: lint
name: Lint ${{ matrix.dir }}
shell: bash
run: |
set -e
./scripts/lint.sh '${{ matrix.dir }}'
- id: coverage
name: Upload coverage for '${{ matrix.dir }}'
uses: codecov/codecov-action@v3
with:
flags: ${{ matrix.dir }}
directory: ${{ matrix.dir }}
- id: finalize
name: Finalize ${{ matrix.dir }}
shell: bash
run: |
set -e
${{ inputs.post-run-function }}
tyras_post_run '${{ matrix.dir }}'
env:
NPM_PUBLISH_TOKEN: ${{ secrets.npm-publish-token }}