-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (157 loc) · 4.85 KB
/
lint-build-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
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
name: Lint, Build, and Test
on:
workflow_call:
secrets:
CODECOV_TOKEN:
required: true
jobs:
prepare:
name: Prepare
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18.x]
os: [ubuntu-latest, macOS-latest, windows-latest]
outputs:
child-workspace-package-names: ${{ steps.workspace-package-names.outputs.child-workspace-package-names }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn --immutable
- name: Fetch workspace package names
id: workspace-package-names
run: |
echo "child-workspace-package-names=$(yarn child-workspace-package-names-as-json)" >> "$GITHUB_OUTPUT"
shell: bash
lint:
name: Lint
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn --immutable --immutable-cache
- run: yarn lint
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
validate-changelog:
name: Validate changelog
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
node-version: [18.x]
package-name: ${{ fromJson(needs.prepare.outputs.child-workspace-package-names) }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn --immutable --immutable-cache
- run: yarn workspace ${{ matrix.package-name }} lint:changelog
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
build:
name: Build
runs-on: ${{ matrix.os }}
needs: prepare
strategy:
matrix:
node-version: [18.x]
os: [macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn --immutable --immutable-cache
- run: yarn build
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
test:
name: Test
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
node-version: [18.x]
package-name: ${{ fromJson(needs.prepare.outputs.child-workspace-package-names) }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn --immutable --immutable-cache
- run: yarn build
- run: yarn workspace ${{ matrix.package-name }} run test:ci
- name: Get coverage folder
id: get-coverage-folder
run: |
echo "Package Name: ${{ matrix.package-name }}"
echo "stub" >> stub
echo "coverage-folder=$(yarn workspaces list --json | grep "\"name\":\"${{ matrix.package-name }}\"" | jq -r '.location')/coverage" >> "$GITHUB_OUTPUT"
shell: bash
- name: Upload coverage artifact
if: ${{ matrix.node-version == '18.x' }}
uses: actions/upload-artifact@v3
with:
name: coverage
path: |
stub
${{ steps.get-coverage-folder.outputs.coverage-folder }}/**/coverage-final.json
if-no-files-found: warn
retention-days: 1
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
upload-coverage:
name: Upload coverage to Codecov
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- name: Download coverage artifact
uses: actions/download-artifact@v3
with:
name: coverage
- name: Upload coverage results
uses: codecov/codecov-action@6d798873df2b1b8e5846dba6fb86631229fbcb17
with:
files: packages/**/coverage-final.json
token: ${{ secrets.CODECOV_TOKEN }}