-
Notifications
You must be signed in to change notification settings - Fork 1.1k
207 lines (200 loc) · 6.9 KB
/
ci.yml
File metadata and controls
207 lines (200 loc) · 6.9 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
name: Locutus CI
on:
pull_request:
push:
branches: [main]
tags: ['*']
jobs:
ci:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: 22.x
registry-url: 'https://registry.npmjs.org'
- name: Engine bump guardrail
run: |
node scripts/check-engine-bump.ts
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v5
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
.yarn
website/.yarn
dist/.yarn
.cache
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies
run: |
corepack yarn
- name: Install Browser Runtime
run: |
corepack yarn browser:install
- name: Lint
run: |
corepack yarn lint
- name: TypeScript Check
run: |
corepack yarn lint:ts
- name: TypeScript Strict-Next Check
run: |
corepack yarn lint:ts:strict-next
- name: Type Debt Policy Check
run: |
corepack yarn lint:ts:debt:policy
- name: API Signature Snapshot Check
run: |
corepack yarn lint:api:snapshot
- name: Header Format Check
run: |
corepack yarn lint:headers
- name: No Stray JS Check
run: |
corepack yarn lint:no-stray-js
- name: Build
run: |
corepack yarn build
- name: Test
run: |
corepack yarn test
- name: Browser Test
run: |
corepack yarn browser:test
- name: Select parity targets
if: github.event_name == 'pull_request'
id: parity-targets
run: |
corepack yarn select:parity --base-ref origin/${{ github.event.pull_request.base.ref }} --github-output "$GITHUB_OUTPUT"
- name: Upstream surface inventory (selective)
if: github.event_name == 'pull_request' && steps.parity-targets.outputs.upstream_surface_languages != ''
run: |
mapfile -t languages < <(printf '%s\n' "${{ steps.parity-targets.outputs.upstream_surface_languages }}" | sed '/^$/d')
printf 'Running upstream surface inventory checks on %s languages\n' "${#languages[@]}"
printf ' %s\n' "${languages[@]}"
corepack yarn test:upstream-surface "${languages[@]}"
- name: Upstream surface inventory (full)
if: github.event_name != 'pull_request'
run: |
corepack yarn test:upstream-surface
- name: Parity tests (selective)
if: github.event_name == 'pull_request'
run: |
printf '%s\n' "${{ steps.parity-targets.outputs.summary }}"
if [ "${{ steps.parity-targets.outputs.mode }}" = "full" ]; then
corepack yarn test:parity
exit 0
fi
mapfile -t targets < <(printf '%s\n' "${{ steps.parity-targets.outputs.targets }}" | sed '/^$/d')
printf 'Running selective parity on %s targets\n' "${#targets[@]}"
printf ' %s\n' "${targets[@]}"
corepack yarn test:parity "${targets[@]}"
- name: Parity tests (full)
if: github.event_name != 'pull_request'
run: |
corepack yarn test:parity
- name: Upload release artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
if-no-files-found: error
- name: Prepare release notes artifact
if: startsWith(github.ref, 'refs/tags/')
run: |
node scripts/extract-release-notes.ts --version "${GITHUB_REF_NAME}" > release-notes.md
- name: Upload release notes artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: release-notes
path: release-notes.md
if-no-files-found: error
- name: Website Build
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
run: |
corepack yarn website:ci
- name: Upload website artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: website-public
path: website/public
if-no-files-found: error
release:
if: startsWith(github.ref, 'refs/tags/')
needs: ci
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/setup-node@v6
with:
node-version: 22.x
registry-url: 'https://registry.npmjs.org'
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- uses: actions/download-artifact@v4
with:
name: release-notes
path: .
- name: Publish package and create GitHub release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
PACKAGE_NAME=$(node -p "require('./dist/package.json').name")
PACKAGE_VERSION=$(node -p "require('./dist/package.json').version")
EXPECTED_TAG="v${PACKAGE_VERSION}"
if [ "$EXPECTED_TAG" != "${GITHUB_REF_NAME}" ]; then
echo "Tag/version mismatch: expected $EXPECTED_TAG from dist/package.json, got ${GITHUB_REF_NAME}" >&2
exit 1
fi
npm install -g npm@^11.5.1
SHOULD_CREATE_GITHUB_RELEASE=0
if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then
echo "GitHub release already exists: ${GITHUB_REF_NAME}"
else
SHOULD_CREATE_GITHUB_RELEASE=1
fi
if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version >/dev/null 2>&1; then
echo "npm package already published: ${PACKAGE_NAME}@${PACKAGE_VERSION}"
else
cd dist/
npm publish --access public --provenance
cd ..
fi
if [ "$SHOULD_CREATE_GITHUB_RELEASE" = "1" ]; then
gh release create "${GITHUB_REF_NAME}" --title "${GITHUB_REF_NAME}" --notes-file release-notes.md
fi
website-deploy:
if: github.ref == 'refs/heads/main'
needs: ci
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: website-public
path: website/public
- name: Website Deploy 🚀
run: |
./scripts/deploy-gh-pages.sh