forked from actions-rs-plus/clippy-check
-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (178 loc) · 4.88 KB
/
build.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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
checks: write
issues: write
packages: read
concurrency:
group: "${{ github.workflow }} @ ${{ github.ref_name }}"
cancel-in-progress: true
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check if we actually made changes
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50
id: filter
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: .github/file-filters.yml
warm-up-cache:
name: Warm up the cache
runs-on: ubuntu-latest
needs:
- changes
if: ${{ needs.changes.outputs.code == 'true' }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
with:
cache: "npm"
cache-dependency-path: package-lock.json
node-version-file: ".nvmrc"
registry-url: https://npm.pkg.github.com
- name: Download dependencies
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm ci
npm-build:
name: Build the code
runs-on: ubuntu-latest
needs:
- warm-up-cache
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "npm"
cache-dependency-path: package-lock.json
- name: Download dependencies from cache
shell: bash
run: |
npm ci --offline
- name: Run build
shell: bash
run: |
npm run build
npm-lint:
name: Lint the code
runs-on: ubuntu-latest
needs:
- warm-up-cache
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "npm"
cache-dependency-path: package-lock.json
- name: Download dependencies from cache
shell: bash
run: |
npm ci --offline
- name: Run lint
shell: bash
run: |
npm run lint -- --format=json --output-file reports/lint-report.json
continue-on-error: true
- name: Annotate Code Linting Results
uses: ataylorme/eslint-annotate-action@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
report-json: reports/lint-report.json
npm-test:
name: Test the code
runs-on: ubuntu-latest
needs:
- warm-up-cache
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "npm"
cache-dependency-path: package-lock.json
- name: Download dependencies from cache
shell: bash
run: |
npm ci --offline
- name: Run tests
env:
JEST_JUNIT_OUTPUT_DIR: reports/
JEST_JUNIT_OUTPUT_NAME: unit-tests-report.xml
run: |
npm run test:ci -- --coverage --testLocationInResults --reporters=default --reporters=jest-junit
continue-on-error: true
npm-dependencies:
name: Validate dependencies
runs-on: ubuntu-latest
needs:
- warm-up-cache
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "npm"
cache-dependency-path: package-lock.json
- name: Download dependencies from cache
shell: bash
run: |
npm ci --offline
- name: Check dependencies
shell: bash
run: |
npm run deps:ci
all-done:
name: All done
# this is the job that should be marked as required on GitHub. It's the only one that'll reliably trigger
# when any upstream fails: success
# when all upstream skips: pass
# when all upstream success: success
# combination of upstream skip and success: success
runs-on: ubuntu-latest
needs:
- npm-build
- npm-dependencies
- npm-lint
- npm-test
if: ${{ always() }}
steps:
- name: Fail!
shell: bash
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: |
echo "One / more upstream failed or was cancelled. Failing job..."
exit 1
- name: Success!
shell: bash
run: |
echo "Great success!"