generated from JS-DevTools/template-node-typescript
-
Notifications
You must be signed in to change notification settings - Fork 81
262 lines (217 loc) · 6.91 KB
/
ci-cd.yaml
File metadata and controls
262 lines (217 loc) · 6.91 KB
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
name: CI-CD
on:
pull_request:
branches:
- main
push:
branches:
- main
# run CI every Monday at 12:25 UTC
schedule:
- cron: "25 12 * * 1"
jobs:
test:
name: Unit tests / Node.js ${{ matrix.node-version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
node-version:
- "20"
- "22"
- "24"
steps:
- name: Checkout source
uses: actions/checkout@v6
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: pnpm install
- name: Run tests
run: pnpm coverage
- name: Send code coverage results to Coveralls
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
parallel: true
flag-name: Node.js ${{ matrix.node-version }} / ${{ matrix.os }}
fail-on-error: false
coverage:
name: Code Coverage
runs-on: ubuntu-latest
timeout-minutes: 10
needs: test
steps:
- name: Let Coveralls know that all tests have finished
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
with:
parallel-finished: true
fail-on-error: false
build:
name: Build and lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout source
uses: actions/checkout@v6
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- name: Install development dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Verify no un-staged changes
run: |
git status --porcelain
git diff-files --quiet
- name: Run lints
run: pnpm lint
- name: Upload publish artifact
uses: actions/upload-artifact@v7
with:
name: publish-artifact
path: lib
e2e:
name: E2E tests / Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
timeout-minutes: 10
needs: build
strategy:
fail-fast: false
matrix:
node-version:
- "20"
- "22"
- "24"
services:
verdaccio:
image: verdaccio/verdaccio:5
ports:
- 4873:4873
steps:
- name: Checkout source
uses: actions/checkout@v6
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- name: Install production dependencies
run: pnpm install --production
- name: Download publish artifact
uses: actions/download-artifact@v8
with:
name: publish-artifact
path: lib
- id: setup
name: Login to local registry and set up fixture package
shell: bash
run: |
echo "token=$(./e2e/00-login.sh)" >> "$GITHUB_OUTPUT"
echo "package=$(./e2e/01-setup-package.sh ./e2e/fixture/cool\ package 0.0.1)" >> "$GITHUB_OUTPUT"
- name: Run CLI end-to-end test
shell: bash
env:
TOKEN: ${{ steps.setup.outputs.token }}
PACKAGE: ${{ steps.setup.outputs.package }}
run: |
./e2e/02-publish.sh "${PACKAGE}" ${TOKEN}
./e2e/03-verify.sh "${PACKAGE}"
./e2e/02-publish.sh "${PACKAGE}" ${TOKEN}
./e2e/01-setup-package.sh "${PACKAGE}" 0.0.2
./e2e/02-publish.sh "${PACKAGE}" ${TOKEN}
./e2e/03-verify.sh "${PACKAGE}"
- id: action-no-publish
name: Publish with already published version
uses: ./
with:
registry: http://localhost:4873
package: ${{ steps.setup.outputs.package }}/package.json
token: ${{ steps.setup.outputs.token }}
- name: Check action output
if: ${{ steps.action-no-publish.outputs.type }}
run: |
echo "::error::Expected release type to be '', got '${{ steps.action-no-publish.outputs.type }}'"
exit 1
- name: Create new version for Action end-to-end test
shell: bash
run: ./e2e/01-setup-package.sh "${{ steps.setup.outputs.package }}" 0.0.3
- id: action-publish-dry-before
name: Publish a dry run before publish
uses: ./
with:
registry: http://localhost:4873
package: ${{ steps.setup.outputs.package }}/package.json
token: ${{ steps.setup.outputs.token }}
dry-run: true
- name: Check release output
if: ${{ steps.action-publish-dry-before.outputs.type != 'patch' }}
run: |
echo "::error::Expected release type to be 'patch', got '${{ steps.action-publish-dry-before.outputs.type }}'"
exit 1
- id: action-publish
name: Publish a new version
uses: ./
with:
registry: http://localhost:4873
package: ${{ steps.setup.outputs.package }}/package.json
token: ${{ steps.setup.outputs.token }}
- name: Check release output
if: ${{ steps.action-publish.outputs.type != 'patch' }}
run: |
echo "::error::Expected release type to be 'patch', got '${{ steps.action-publish.outputs.type }}'"
exit 1
- id: action-publish-dry-after
name: Publish a dry run after publish
uses: ./
with:
registry: http://localhost:4873
package: ${{ steps.setup.outputs.package }}/package.json
token: ${{ steps.setup.outputs.token }}
dry-run: true
- name: Check release output
if: ${{ steps.action-publish-dry-after.outputs.type }}
run: |
echo "::error::Expected release type to be '', got '${{ steps.action-publish-dry-after.outputs.type }}'"
exit 1
deploy:
if: ${{ github.ref == 'refs/heads/main' }}
name: Publish
runs-on: ubuntu-latest
environment: npm
timeout-minutes: 10
permissions:
contents: read
id-token: write
needs:
- test
- build
- e2e
steps:
- name: Checkout source
uses: actions/checkout@v6
- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
package-manager-cache: false
- name: Download publish artifact
uses: actions/download-artifact@v8
with:
name: publish-artifact
path: lib
- name: Publish to NPM
uses: ./