-
-
Notifications
You must be signed in to change notification settings - Fork 3
161 lines (159 loc) · 4.32 KB
/
build-status.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
name: Build Status
on:
push:
branches:
- main
- next-*
- fix-v*
tags:
- v**
pull_request:
branches:
- main
- next-*
- fix-v*
jobs:
warmup_yarn_cache:
name: 'Warm up Yarn cache'
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Using Node v18.x
uses: actions/setup-node@v4
id: yarn-cache
with:
node-version: '18.x'
cache: 'yarn'
- name: Update Yarn cache
if: steps.yarn-cache.outputs.cache-hit != 'true'
env:
# Using PNP linker for better performance
YARN_NODE_LINKER: pnp
run: yarn install --immutable
format:
name: 'Format'
needs: warmup_yarn_cache
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Using Node v18.x
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Check format
run: yarn format:check
test:
name: 'Test'
needs: warmup_yarn_cache
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/[email protected]
- name: Using Node v${{matrix.node-version}}
uses: actions/setup-node@v4
with:
node-version: ${{matrix.node-version}}
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Build production package
run: yarn build:prod-ci
- name: Unit tests
run: yarn test
- name: Codecov
uses: codecov/codecov-action@v4
with:
name: unit-tests-${{matrix.node-version}}-${{runner.os}}
flags: unit-tests, unit-tests-${{matrix.node-version}}-${{runner.os}}
fail_ci_if_error: false # default: false
verbose: false # default: false
test_package_quality:
name: 'Test package quality'
needs: warmup_yarn_cache
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Using Node v18.x
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'yarn'
- name: Check package score using skypack
run: yarn dlx @skypack/package-check
production_package:
name: 'Build production package'
needs: warmup_yarn_cache
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Using Node v18.x
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Build production package
run: yarn build:prod-ci
- name: Create bundle
run: yarn pack
- name: Upload production package
uses: actions/upload-artifact@v4
with:
name: bundle
path: package.tgz
if-no-files-found: error
retention-days: 1
test_legacy:
name: 'Test legacy'
needs: production_package
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Using Node 0.12
shell: bash -l {0}
run: nvm install 0.12
- name: Download production package
uses: actions/download-artifact@v4
with:
name: bundle
- name: Untar the published package
run: |
tar -zxvf package.tgz
mv package/lib lib
- name: Test
run: node test/legacy/main.js
publish_package:
name: 'Publish package'
needs:
- production_package
- format
- test
- test_legacy
- test_package_quality
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Using Node v18.x
uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Install latest npm version
run: npm install -g npm
- name: Download production package
uses: actions/download-artifact@v4
with:
name: bundle
- name: Publish package
run: npm publish --provenance --access public package.tgz
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}