Repository navigation
239 lines (225 loc) · 8.55 KB
/
Copy pathci.yml
File metadata and controls
239 lines (225 loc) · 8.55 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
name: CI
on:
push:
branches: [develop]
pull_request:
branches: [develop]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
env:
RUST_BACKTRACE: 1
NODE_VERSION: "24"
# Disable husky git hooks in CI — CI runs its own checks
# https://typicode.github.io/husky/how-to.html#ci-server-and-docker
HUSKY: 0
jobs:
check:
name: Check
runs-on: ubuntu-22.04
# Job timeouts: several times the usual run time (check ~2 min, builds
# 3-7 min, tests 5-9 min), so a hung step fails instead of burning
# GitHub's 6-hour default.
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- run: cargo fmt --all --check
- run: cargo clippy --workspace --all-targets --locked -- -D warnings
- run: cargo doc --workspace --no-deps --locked
env:
RUSTDOCFLAGS: -D warnings
build-napi:
name: Build NAPI (${{ matrix.settings.target }})
strategy:
fail-fast: false
matrix:
settings:
- target: aarch64-apple-darwin
os: macos-latest
artifact: apvm-napi.darwin-arm64.node
- target: x86_64-apple-darwin
os: macos-latest
artifact: apvm-napi.darwin-x64.node
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
artifact: apvm-napi.linux-x64-gnu.node
# Vendor OpenSSL to produce a self-contained binary with no runtime libssl dependency.
# https://docs.rs/openssl/latest/openssl/#vendored
features: vendored-openssl
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04
artifact: apvm-napi.linux-arm64-gnu.node
# Vendor OpenSSL from source for cross-compilation (no system libssl-dev:arm64)
# and to produce a self-contained binary with no runtime libssl dependency.
# https://docs.rs/openssl/latest/openssl/#vendored
features: vendored-openssl
- target: x86_64-pc-windows-msvc
os: windows-latest
artifact: apvm-napi.win32-x64-msvc.node
runs-on: ${{ matrix.settings.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.settings.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
# `npm ci`: exactly the committed lockfile (which lists every
# platform's native packages), failing if it drifts from package.json.
- run: npm ci
- name: Build NAPI
run: >
npx napi build --release --platform
--manifest-path crates/napi/Cargo.toml --output-dir .
--target ${{ matrix.settings.target }}
${{ matrix.settings.features && format('--features {0}', matrix.settings.features) || '' }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
AR_aarch64_unknown_linux_gnu: aarch64-linux-gnu-ar
- name: Upload .node artifact
uses: actions/upload-artifact@v7
with:
name: napi-${{ matrix.settings.target }}
path: ${{ matrix.settings.artifact }}
if-no-files-found: error
- name: Upload JS bindings
if: matrix.settings.target == 'x86_64-unknown-linux-gnu'
uses: actions/upload-artifact@v7
with:
name: napi-bindings
path: |
index.js
index.d.ts
if-no-files-found: error
test:
name: Test (${{ matrix.settings.name }})
needs: build-napi
strategy:
fail-fast: false
matrix:
settings:
- name: Linux x64
os: ubuntu-22.04
napi-artifact: napi-x86_64-unknown-linux-gnu
- name: macOS ARM64
os: macos-latest
napi-artifact: napi-aarch64-apple-darwin
- name: Windows x64
os: windows-latest
napi-artifact: napi-x86_64-pc-windows-msvc
runs-on: ${{ matrix.settings.os }}
# Includes real builds of wp-rocket and imagify from GitHub, each test
# allowed 10 min: more room than the other jobs.
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- uses: dtolnay/rust-toolchain@stable
# PHP + Composer (required by wp-rocket and backwpup build steps).
# Use shivammathur/setup-php to get a consistent PHP version on all runners.
# ubuntu-22.04 ships PHP 8.1 (EOL, known allocator bugs causing SIGABRT),
# so we install PHP 8.4 (latest stable with active support) everywhere.
# https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
# fileinfo: required by league/flysystem (transitive dep of wp-rocket via coenjacobs/mozart).
# Bundled by default on Linux/macOS but must be explicitly enabled on Windows.
extensions: fileinfo
tools: composer
coverage: none
env:
fail-fast: true
# Debug: print PHP and Composer info for troubleshooting
- name: PHP & Composer diagnostics
run: |
php -v
php -m
composer --version
composer diagnose || true
- name: Install gulp
run: npm install --global gulp-cli
# Rust tests
- name: Rust tests
run: cargo test --workspace --locked
# Node tests
- name: Download NAPI binary
uses: actions/download-artifact@v8
with:
name: ${{ matrix.settings.napi-artifact }}
# The committed index.js / index.d.ts lag behind this change (the bot
# regenerates them only after merging), so test against the fresh ones.
- name: Download JS bindings
uses: actions/download-artifact@v8
with:
name: napi-bindings
- run: npm ci
# Type-checks the tests against the generated index.d.ts (OS-independent).
- name: TypeScript typecheck
if: runner.os == 'Linux'
run: npm run typecheck
- name: Node tests
run: npm test
env:
# Prevent PHP memory limit issues during Composer autoload generation.
# wp-rocket has 95+ deps; the default 128MB can be insufficient.
# https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors
COMPOSER_MEMORY_LIMIT: "-1"
commit-artifacts:
name: Commit Artifacts
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
needs: [build-napi, test]
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- name: Download all NAPI artifacts
uses: actions/download-artifact@v8
with:
pattern: napi-*
merge-multiple: true
- name: Commit and push artifacts
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -- *.node index.js index.d.ts
git diff --staged --quiet && exit 0
git commit -m "chore: update NAPI binaries"
git pull --rebase
git push
# ── CI gate ──────────────────────────────────────────────────────────────
# Single required check for branch protection. With matrix strategies, job
# names are dynamic (e.g. "Build NAPI (x86_64-unknown-linux-gnu)"). This
# job provides one stable name — "CI" — to configure as a required status
# check, so matrix changes never break branch protection rules.
ci:
name: CI
if: always()
needs: [check, build-napi, test, commit-artifacts]
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Check results
if: >-
needs.check.result != 'success' ||
needs.build-napi.result != 'success' ||
needs.test.result != 'success' ||
(needs.commit-artifacts.result != 'success' &&
needs.commit-artifacts.result != 'skipped')
run: exit 1