Repository navigation
395 lines (351 loc) · 14.7 KB
/
Copy pathci.yml
File metadata and controls
395 lines (351 loc) · 14.7 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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
# ------------------------------------------------------------------
# README/CHANGELOG/CONTRIBUTING/SECURITY (all three languages) are
# generated by @ktav-lang/polydoc from the root-docs/ unit trees. This
# job fails when a committed artifact drifts from its source — which is
# what a hand-edit of the artifact looks like. Fix the source and
# re-run the generator; never patch the artifact.
# ------------------------------------------------------------------
docs:
name: Docs (generated markdown)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'
- name: Install Node dependencies
run: npm ci
- name: Generated docs are byte-identical to their source units
run: node scripts/build-docs.mjs --check
# ------------------------------------------------------------------
# Build native library + run Java tests in one job per OS. The test
# suite hardcodes both paths (cabi at `target/release/...`, spec at
# `spec/versions/0.8/tests`) — no env wiring needed.
# ------------------------------------------------------------------
test:
name: ${{ matrix.os }} / JDK ${{ matrix.jdk }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
jdk: ["17", "21"]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.jdk }}
- uses: gradle/actions/setup-gradle@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Build native library
run: cargo build --release -p ktav-cabi
- name: Verify generated lockfile uses the pinned core revision
shell: bash
run: |
python - <<'PY'
import tomllib
with open('Cargo.lock', 'rb') as source:
packages = tomllib.load(source)['package']
core = [package for package in packages if package['name'] == 'ktav']
expected_source = 'git+https://github.com/ktav-lang/rust?rev=8b6b45ffbd9e50e1588e8ab6b1ae5d422bbe8910#8b6b45ffbd9e50e1588e8ab6b1ae5d422bbe8910'
if len(core) != 1 or core[0].get('source') != expected_source:
raise SystemExit(f'expected exactly one ktav from pinned git revision; found {core!r}')
print('generated lockfile resolves ktav from the pinned core revision')
PY
- name: Verify required native ABI symbols
if: runner.os == 'Linux'
shell: bash
run: |
set -euo pipefail
nm -D --defined-only target/release/libktav_cabi.so | awk '{print $3}' | python -c '
import sys
required = {
"ktav_loads", "ktav_loads_strict", "ktav_dumps", "ktav_dumps_force_strings",
"ktav_emit_canonical", "ktav_format", "ktav_canonical_from_source",
"ktav_edit_value", "ktav_edit_value_segments", "ktav_insert_value",
"ktav_insert_value_segments", "ktav_remove_value", "ktav_remove_value_segments",
"ktav_rename_key", "ktav_rename_key_segments", "ktav_free", "ktav_version",
"ktav_abi_version",
}
exported = set(sys.stdin.read().split())
missing = sorted(required - exported)
if missing:
raise SystemExit("missing native ABI symbols: " + ", ".join(missing))
print("required native ABI symbols are exported")
'
- name: Gradle test
run: ./gradlew :lib:test --no-daemon --stacktrace
- name: Upload test reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.os }}-jdk${{ matrix.jdk }}
path: lib/build/reports/tests/test
retention-days: 7
lint-rust:
name: rust clippy + fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all --check
- run: cargo clippy --release -p ktav-cabi -- -D warnings
build-jar:
name: build library JAR (no native)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: gradle/actions/setup-gradle@v4
# vanniktech maven-publish renames javadocJar → mavenPlainJavadocJar.
- run: ./gradlew :lib:jar :lib:sourcesJar :lib:mavenPlainJavadocJar --no-daemon
- name: Upload JARs
uses: actions/upload-artifact@v4
with:
name: ktav-jars
path: |
lib/build/libs/*.jar
retention-days: 14
# ------------------------------------------------------------------
# Pure-Java backend: full corpus + API/negative/regression tests run
# with NO cargo build step at all — proving lang.ktav.pure never
# loads or downloads the native library. Gradle fails when a --tests
# filter matches nothing, so a missing pure suite is RED here, not
# skipped. CrossBackendTest deliberately stays out: it needs the
# built cabi and runs in the `test` job.
# ------------------------------------------------------------------
test-pure:
name: pure backend (no native build)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: gradle/actions/setup-gradle@v4
- name: Pure-backend tests (no cargo)
run: >
./gradlew :lib:test --no-daemon --stacktrace
--tests "lang.ktav.PureConformanceTest"
--tests "lang.ktav.PureApiTest"
--tests "lang.ktav.PureNegativeTest"
--tests "lang.ktav.PureRegressionTest"
--tests "lang.ktav.PureNoNativeTest"
--tests "lang.ktav.CorpusGuardMutationTest"
--tests "lang.ktav.PureWhitespaceTest"
--tests "lang.ktav.PureInsertValueTest"
--tests "lang.ktav.PureRemoveRenameTest"
--tests "lang.ktav.PureMutationSourceFirstReuseTest"
- name: Upload test reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-reports-pure
path: lib/build/reports/tests/test
retention-days: 7
# Packaged pure backend: build the library and checker jars, then run
# without Jackson, JNA, JUnit, or loose main-output directories.
packaged-pure:
name: packaged jar pure smoke (no native/dependency classpath)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: gradle/actions/setup-gradle@v4
- name: Build jars and run packaged pure smoke
run: ./gradlew :lib:jar :lib:pureCheckJar :lib:pureJarTest --no-daemon --stacktrace
- name: Direct Java run with explicit jars
env:
KTAV_LIB_PATH: /nonexistent/ktav-native-guard
run: java -cp "lib/build/libs/ktav-0.8.1.jar:lib/build/libs/ktav-0.8.1-pure-check.jar" lang.ktav.PureSmokeMain
# ------------------------------------------------------------------
# CI-only verification of the GENERATED POM and Gradle Module
# Metadata — no publish, no signing, no secrets. Gradle's own dependency
# resolution of build tooling uses the network as normal; the guarantee is
# only: no publish, no secrets, zero external pure runtime deps.
#
# Task-name contract (source-verified at 0.30.0): vanniktech maven-publish
# hardcodes the publication name as
# `private const val PUBLICATION_NAME = "maven"`
# (plugin/src/main/kotlin/com/vanniktech/maven/publish/Platform.kt), so
# Gradle's standard maven-publish task names apply:
# :lib:generatePomFileForMavenPublication and
# :lib:generateMetadataFileForMavenPublication writing to
# lib/build/publications/maven/. If a task name ever changes, this job
# goes RED; verify with `./gradlew :lib:tasks --all` and adjust the job.
# ------------------------------------------------------------------
metadata:
name: generated POM/module metadata (no publish)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: gradle/actions/setup-gradle@v4
- name: Generate POM + module metadata and build jars
run: >
./gradlew :lib:generatePomFileForMavenPublication
:lib:generateMetadataFileForMavenPublication
:lib:jar :lib:pureJarTest --no-daemon --stacktrace
- name: Check generated metadata (no publish)
run: |
# 1) self-test: negative controls against scripts/metadata-fixtures/
python3 scripts/check_publish_metadata.py --self-test
# 2) the actual gate on generated artifacts
bash scripts/check-publish-metadata.sh
- name: Upload generated publication metadata
uses: actions/upload-artifact@v4
with:
name: generated-publication-metadata
path: lib/build/publications/maven/
retention-days: 14
source-edit-benchmark:
name: source edit benchmark (base vs candidate)
if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
path: candidate
submodules: recursive
- uses: actions/checkout@v4
with:
ref: ad96c71e75ecb683b5698d6af6d82efd700c8de0
path: baseline
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: gradle/actions/setup-gradle@v4
- name: Build native libraries in isolated workspaces
shell: bash
run: |
set -euo pipefail
cargo build --manifest-path baseline/Cargo.toml --release -p ktav-cabi --target-dir baseline/target
cargo build --manifest-path candidate/Cargo.toml --release -p ktav-cabi --target-dir candidate/target
- name: Run identical harness in alternating independent JVMs
shell: bash
run: |
set -euo pipefail
cp candidate/lib/src/test/java/lang/ktav/SourceEditBenchmark.java baseline/lib/src/test/java/lang/ktav/SourceEditBenchmark.java
{
echo "baseline_sha=ad96c71e75ecb683b5698d6af6d82efd700c8de0"
echo "candidate_sha=${GITHUB_SHA}"
echo "runner_os=${RUNNER_OS}"
echo "runner_arch=${RUNNER_ARCH}"
echo "run_id=${GITHUB_RUN_ID}"
echo "run_attempt=${GITHUB_RUN_ATTEMPT}"
echo "event_name=${GITHUB_EVENT_NAME}"
echo "ref=${GITHUB_REF}"
rustc --version
cargo --version
java -version
for round in 1 2 3 4 5; do
if (( round % 2 == 1 )); then first=baseline; second=candidate; else first=candidate; second=baseline; fi
for side in "$first" "$second"; do
echo "===== round=${round} side=${side} ====="
JAVA_TOOL_OPTIONS='-Dktav.bench.repeats=1' KTAV_LIB_PATH="$GITHUB_WORKSPACE/$side/target/release/libktav_cabi.so" \
./"$side"/gradlew -p "$side" :lib:sourceEditBenchmark --no-daemon --stacktrace
done
done
} 2>&1 | tee source-edit-benchmark.log
- name: Upload benchmark measurements and output
if: always()
uses: actions/upload-artifact@v4
with:
name: source-edit-benchmark
path: source-edit-benchmark.log
if-no-files-found: warn
retention-days: 14
# ------------------------------------------------------------------
# DEBUG-cabi empty-input ABI check. Rust debug builds assert slice
# pointer validity, so a Pointer.NULL empty source fails here while
# release builds silently hide it. We build WITHOUT --release (that
# IS the debug artifact at target/debug/libktav_cabi.so) and pin it
# via KTAV_LIB_PATH — no cache/release fallback is possible because
# the file did not exist before this build produced it.
# ------------------------------------------------------------------
native-debug-empty-abi:
name: debug cabi / empty-input ABI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: gradle/actions/setup-gradle@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Build DEBUG native library
run: cargo build -p ktav-cabi
- name: Verify generated lockfile uses the pinned core revision
shell: bash
run: |
python - <<'PY'
import tomllib
with open('Cargo.lock', 'rb') as source:
packages = tomllib.load(source)['package']
core = [package for package in packages if package['name'] == 'ktav']
expected_source = 'git+https://github.com/ktav-lang/rust?rev=8b6b45ffbd9e50e1588e8ab6b1ae5d422bbe8910#8b6b45ffbd9e50e1588e8ab6b1ae5d422bbe8910'
if len(core) != 1 or core[0].get('source') != expected_source:
raise SystemExit(f'expected exactly one ktav from pinned git revision; found {core!r}')
print('generated lockfile resolves ktav from the pinned core revision')
PY
- name: Empty-input tests against the real debug artifact
env:
KTAV_LIB_PATH: ${{ github.workspace }}/target/debug/libktav_cabi.so
KTAV_DEBUG_CABI: debug
run: >
./gradlew :lib:test --no-daemon --stacktrace
--tests "lang.ktav.NativeEmptyInputTest"
--tests "lang.ktav.NativeByteInputTest"
- name: Upload test reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-reports-native-debug-empty-abi
path: lib/build/reports/tests/test
retention-days: 7