Repository navigation
285 lines (258 loc) · 11 KB
/
Copy pathserver-linux.yml
File metadata and controls
285 lines (258 loc) · 11 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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
name: Linux server archive
on:
workflow_dispatch:
inputs:
source_sha:
description: 'Exact 40-character source commit (empty uses the dispatched commit)'
required: false
type: string
pull_request:
paths:
- '.github/workflows/server-linux.yml'
- '.github/workflows/ci.yml'
- 'src/**'
- 'server/**'
- 'shared/**'
- 'native/**'
- 'scripts/**'
- 'public/**'
- 'packaging/systemd/**'
- 'docker/**'
- 'package*.json'
- '*config*'
- '.npmrc'
- 'index.html'
- 'LICENSE'
- 'NOTICE'
- 'docs/SELF-HOST.md'
- 'docs/INSTALL.md'
- 'docs/SERVER-LINUX-ACCEPTANCE.md'
push:
branches: [main]
paths:
- '.github/workflows/server-linux.yml'
- '.github/workflows/ci.yml'
- 'src/**'
- 'server/**'
- 'shared/**'
- 'native/**'
- 'scripts/**'
- 'public/**'
- 'packaging/systemd/**'
- 'docker/**'
- 'package*.json'
- '*config*'
- '.npmrc'
- 'index.html'
- 'LICENSE'
- 'NOTICE'
- 'docs/SELF-HOST.md'
- 'docs/INSTALL.md'
- 'docs/SERVER-LINUX-ACCEPTANCE.md'
permissions:
contents: read
concurrency:
group: server-linux-${{ github.workflow }}-${{ inputs.source_sha || github.event.pull_request.head.sha || github.sha }}
cancel-in-progress: true
# Acceptance/build artifacts only. Source verification is the separate CI gate.
# No release environment, signing/provider credentials, publication or dispatch.
jobs:
build:
name: Build Linux x64 Node 22 archive (glibc 2.35)
runs-on: ubuntu-22.04
timeout-minutes: 45
env:
SOURCE_SHA: ${{ inputs.source_sha || github.event.pull_request.head.sha || github.sha }}
outputs:
source_sha: ${{ steps.metadata.outputs.source_sha }}
asset_name: ${{ steps.metadata.outputs.asset_name }}
steps:
- name: Require an immutable source commit
run: |
set -euo pipefail
[[ "$SOURCE_SHA" =~ ^[0-9a-f]{40}$ ]]
- name: Checkout exact source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ env.SOURCE_SHA }}
persist-credentials: false
- name: Set up pinned Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '22.22.2'
architecture: x64
cache: npm
- name: Check source and build host
id: metadata
run: |
set -euo pipefail
test "$(git rev-parse HEAD)" = "$SOURCE_SHA"
test "$(uname -s)" = Linux
test "$(uname -m)" = x86_64
test "$(getconf GNU_LIBC_VERSION)" = "glibc 2.35"
test "$(node --version)" = v22.22.2
VERSION="$(node -p "require('./package.json').version")"
echo "source_sha=$SOURCE_SHA" >> "$GITHUB_OUTPUT"
echo "asset_name=gajae-app-server-${VERSION}-linux-x64-node22.tar.gz" >> "$GITHUB_OUTPUT"
echo "SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)" >> "$GITHUB_ENV"
- name: Install native build prerequisites
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y build-essential python3 pkg-config libssl-dev binutils git ca-certificates
- name: Set up Rust
run: |
set -euo pipefail
rustup toolchain install 1.85.1 --profile minimal
rustup default 1.85.1
rustup target add x86_64-unknown-linux-gnu
- name: Seed verified ripgrep install cache
run: node scripts/release/prime-ripgrep-cache.mjs
- name: Install dependencies
run: npm ci
- name: Fetch and check pinned Bun runtime
run: |
set -euo pipefail
node scripts/fetch-bun.mjs
test "$(dist-native/bun --version)" = 1.4.0
- name: Check smoke harness regressions
run: node --test scripts/release/packaged-server-paths.test.mjs scripts/release/server-archive-smoke.test.mjs
- name: Build canonical server archive
run: npm run server:bundle
- name: Verify canonical assets and record source provenance
env:
ASSET_NAME: ${{ steps.metadata.outputs.asset_name }}
run: |
set -euo pipefail
test "$(git rev-parse HEAD)" = "$SOURCE_SHA"
git diff --exit-code
shopt -s nullglob dotglob
assets=(release/server/*)
test "${#assets[@]}" -eq 2
test -f "release/server/$ASSET_NAME"
test -f "release/server/$ASSET_NAME.sha256"
(cd release/server && sha256sum --check "$ASSET_NAME.sha256")
mkdir -p "$RUNNER_TEMP/server-acceptance"
node --input-type=module <<'NODE'
import { readFileSync, writeFileSync } from 'node:fs';
import path from 'node:path';
const asset = process.env.ASSET_NAME;
const sha256 = readFileSync(`release/server/${asset}.sha256`, 'utf8').split(/\s+/)[0];
const evidence = { sourceSha: process.env.SOURCE_SHA, asset, sha256, node: process.versions.node, glibc: process.report.getReport().header.glibcVersionRuntime, sourceDateEpoch: process.env.SOURCE_DATE_EPOCH };
writeFileSync(path.join(process.env.RUNNER_TEMP, 'server-acceptance', 'build.json'), JSON.stringify(evidence, null, 2) + '\n');
NODE
cat "$RUNNER_TEMP/server-acceptance/build.json" >> "$GITHUB_STEP_SUMMARY"
- name: Upload canonical archive and checksum
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: gajae-app-server-linux-${{ steps.metadata.outputs.source_sha }}
path: release/server/*
if-no-files-found: error
compression-level: 0
retention-days: 14
- name: Upload build provenance
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: gajae-server-linux-provenance-${{ steps.metadata.outputs.source_sha }}
path: ${{ runner.temp }}/server-acceptance/build.json
if-no-files-found: error
retention-days: 14
archive-smoke:
name: Accept server archive on ${{ matrix.os }}
needs: build
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
glibc: '2.35'
- os: ubuntu-24.04
glibc: '2.39'
env:
SOURCE_SHA: ${{ needs.build.outputs.source_sha }}
ASSET_NAME: ${{ needs.build.outputs.asset_name }}
EXPECTED_GLIBC: ${{ matrix.glibc }}
steps:
- name: Checkout smoke harness at the build source commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.build.outputs.source_sha }}
persist-credentials: false
- name: Set up pinned host Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '22.22.2'
architecture: x64
- name: Check validation host
run: |
set -euo pipefail
test "$(git rev-parse HEAD)" = "$SOURCE_SHA"
test "$(uname -s)" = Linux
test "$(uname -m)" = x86_64
test "$(getconf GNU_LIBC_VERSION)" = "glibc $EXPECTED_GLIBC"
test "$(node --version)" = v22.22.2
# Intentionally no npm install in validation: resolve only shipped deps.
test ! -e node_modules
ARCHIVE_ROOT="$RUNNER_TEMP/gajae-server-archive"
EVIDENCE_ROOT="$RUNNER_TEMP/server-acceptance"
echo "ARCHIVE_ROOT=$ARCHIVE_ROOT" >> "$GITHUB_ENV"
echo "EVIDENCE_ROOT=$EVIDENCE_ROOT" >> "$GITHUB_ENV"
mkdir -p "$EVIDENCE_ROOT"
printf 'source=%s\nhost=%s\nnode=%s\n' "$SOURCE_SHA" "$(getconf GNU_LIBC_VERSION)" "$(node --version)" > "$EVIDENCE_ROOT/host.txt"
- name: Download the build archive
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: gajae-app-server-linux-${{ needs.build.outputs.source_sha }}
path: ${{ runner.temp }}/server-assets
- name: Download build provenance
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: gajae-server-linux-provenance-${{ needs.build.outputs.source_sha }}
path: ${{ runner.temp }}/server-acceptance
- name: Verify and extract the same archive outside the checkout
run: |
set -euo pipefail
shopt -s nullglob dotglob
assets=("$RUNNER_TEMP/server-assets/"*)
test "${#assets[@]}" -eq 2
test -f "$RUNNER_TEMP/server-assets/$ASSET_NAME"
test -f "$RUNNER_TEMP/server-assets/$ASSET_NAME.sha256"
(cd "$RUNNER_TEMP/server-assets" && sha256sum --check "$ASSET_NAME.sha256")
node --input-type=module <<'NODE'
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import path from 'node:path';
const evidence = JSON.parse(readFileSync(path.join(process.env.EVIDENCE_ROOT, 'build.json'), 'utf8'));
const checksum = readFileSync(path.join(process.env.RUNNER_TEMP, 'server-assets', `${process.env.ASSET_NAME}.sha256`), 'utf8').split(/\s+/)[0];
assert.equal(evidence.sourceSha, process.env.SOURCE_SHA);
assert.equal(evidence.asset, process.env.ASSET_NAME);
assert.equal(evidence.sha256, checksum);
assert.equal(evidence.node, '22.22.2');
assert.equal(evidence.glibc, '2.35');
NODE
mkdir "$ARCHIVE_ROOT"
tar -xzf "$RUNNER_TEMP/server-assets/$ASSET_NAME" -C "$ARCHIVE_ROOT"
VERSION="$(node -p "require('./package.json').version")"
ARCHIVE_VERSION="$(node -p 'require(process.env.ARCHIVE_ROOT + "/package.json").version')"
test "$ARCHIVE_VERSION" = "$VERSION"
- name: Check authenticated startup, native closure, worker, abort and replay
run: |
set -euo pipefail
node scripts/release/smoke-packaged-server.mjs --server-archive-root "$ARCHIVE_ROOT" 2>&1 | tee "$EVIDENCE_ROOT/standard.log"
- name: Check data survival across graceful shutdown and restart
run: |
set -euo pipefail
node scripts/release/smoke-packaged-server.mjs --server-archive-root "$ARCHIVE_ROOT" --data-survival 2>&1 | tee "$EVIDENCE_ROOT/data-survival.log"
- name: Record acceptance
run: |
set -euo pipefail
printf 'Accepted %s on %s (glibc %s), source %s\n' "$ASSET_NAME" "$RUNNER_OS" "$EXPECTED_GLIBC" "$SOURCE_SHA" >> "$GITHUB_STEP_SUMMARY"
- name: Upload acceptance evidence
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: gajae-server-linux-evidence-${{ matrix.os }}-${{ needs.build.outputs.source_sha }}
path: ${{ runner.temp }}/server-acceptance/
if-no-files-found: warn
retention-days: 14