Skip to content

Commit aaefda3

Browse files
sunnylqmclaude
andcommitted
ci: add tarball smoke test, glibc ceiling check, and engines-floor job
- Install the npm pack tarball in a clean directory on every platform and load it without build/Release, pinning the prebuilds naming contract. - Fail Linux builds whose prebuilds require glibc symbols above 2.33. - Run the full test suite on Node 14.17 (engines floor) against an addon built with the Node 24 toolchain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent fdfb607 commit aaefda3

2 files changed

Lines changed: 88 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ on:
66
pull_request:
77

88
jobs:
9+
# engines 声明 >=14.17.0:用新工具链构建(N-API 8,ABI 稳定),
10+
# 再切到最低支持的 Node 运行时跑完整测试,保证契约真实被测过
11+
engines-floor:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v5
15+
with:
16+
submodules: recursive
17+
- uses: actions/setup-node@v6
18+
with:
19+
node-version: 24
20+
- uses: oven-sh/setup-bun@v2
21+
with:
22+
bun-version: latest
23+
- run: bun install --ignore-scripts
24+
- run: bun run prebuild
25+
- uses: actions/setup-node@v6
26+
with:
27+
node-version: 14.17.0
28+
- run: node --version && node test/test.js
29+
930
test:
1031
strategy:
1132
fail-fast: false
@@ -37,3 +58,36 @@ jobs:
3758
- run: bun run prebuild
3859
- run: node test/test.js
3960
- run: bun ./test/test.js
61+
# 与 publish 一致:固定 Linux prebuild 的 glibc 符号版本上限
62+
- name: Check glibc symbol ceiling
63+
if: runner.os == 'Linux'
64+
run: |
65+
set -euo pipefail
66+
ceiling="2.33"
67+
max=$(objdump -T prebuilds/*/*.node | grep -o 'GLIBC_[0-9.]*' | sed 's/GLIBC_//' | sort -Vu | tail -1)
68+
test -n "$max"
69+
echo "max required glibc: $max (ceiling: $ceiling)"
70+
if [ "$(printf '%s\n%s\n' "$max" "$ceiling" | sort -V | tail -1)" != "$ceiling" ]; then
71+
echo "::error::prebuild requires GLIBC_$max which exceeds the GLIBC_$ceiling ceiling"
72+
exit 1
73+
fi
74+
# 安装 npm pack 产物并在无 build/Release 的环境加载,验证 prebuilds
75+
# 命名契约与 files 白名单
76+
- name: Smoke test packed tarball
77+
run: |
78+
set -euo pipefail
79+
npm pack
80+
mkdir -p "$RUNNER_TEMP/smoke"
81+
cp node-hdiffpatch-*.tgz "$RUNNER_TEMP/smoke/"
82+
cd "$RUNNER_TEMP/smoke"
83+
npm init -y > /dev/null
84+
npm install ./node-hdiffpatch-*.tgz
85+
node -e "
86+
const assert = require('assert');
87+
const h = require('node-hdiffpatch');
88+
const o = Buffer.from('hello world hello world');
89+
const n = Buffer.from('hello brave new world!!');
90+
const d = h.diff(o, n);
91+
assert.deepStrictEqual(h.patch(o, d), n);
92+
console.log('tarball smoke test ok');
93+
"

.github/workflows/publish.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,40 @@ jobs:
4343
- run: bun run prebuild
4444
- run: node test/test.js
4545
- run: bun ./test/test.js
46+
# 曾发生过 Ubuntu 24.04 构建把最低要求抬到 GLIBC_2.38、导致
47+
# Ubuntu 22.04/Debian 12 无法加载的回归;此处固定符号版本上限
48+
- name: Check glibc symbol ceiling
49+
if: runner.os == 'Linux'
50+
run: |
51+
set -euo pipefail
52+
ceiling="2.33"
53+
max=$(objdump -T prebuilds/*/*.node | grep -o 'GLIBC_[0-9.]*' | sed 's/GLIBC_//' | sort -Vu | tail -1)
54+
test -n "$max"
55+
echo "max required glibc: $max (ceiling: $ceiling)"
56+
if [ "$(printf '%s\n%s\n' "$max" "$ceiling" | sort -V | tail -1)" != "$ceiling" ]; then
57+
echo "::error::prebuild requires GLIBC_$max which exceeds the GLIBC_$ceiling ceiling"
58+
exit 1
59+
fi
60+
# 用打包后的 tarball 独立验证:安装产物只含 prebuilds/,不得依赖
61+
# 仓库里的 build/Release,同时钉死静态 require 的产物命名契约
62+
- name: Smoke test packed tarball
63+
run: |
64+
set -euo pipefail
65+
npm pack
66+
mkdir -p "$RUNNER_TEMP/smoke"
67+
cp node-hdiffpatch-*.tgz "$RUNNER_TEMP/smoke/"
68+
cd "$RUNNER_TEMP/smoke"
69+
npm init -y > /dev/null
70+
npm install ./node-hdiffpatch-*.tgz
71+
node -e "
72+
const assert = require('assert');
73+
const h = require('node-hdiffpatch');
74+
const o = Buffer.from('hello world hello world');
75+
const n = Buffer.from('hello brave new world!!');
76+
const d = h.diff(o, n);
77+
assert.deepStrictEqual(h.patch(o, d), n);
78+
console.log('tarball smoke test ok');
79+
"
4680
- uses: actions/upload-artifact@v7.0.1
4781
with:
4882
name: prebuilds-${{ matrix.os }}-${{ matrix.arch }}

0 commit comments

Comments
 (0)