Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 194 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,44 @@ env:
CARGO_TERM_COLOR: always

jobs:
# ------------------------------------------------------------------
# Unchanged drift guard from a clean checkout: the committed artifacts
# must stay byte-identical to the root-docs/ source units. This job
# NEVER relaxes during release preparation; the regenerated candidate
# artifacts travel separately (docs job below) until a maintainer
# reviews and commits them.
# ------------------------------------------------------------------
docs-check:
name: Docs (byte-identical drift guard)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'
- run: npm ci
- name: Generated docs are byte-identical to their source units
run: node scripts/build-docs.mjs --check

# ------------------------------------------------------------------
# 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.
# generated by @ktav-lang/polydoc from the root-docs/ unit trees.
# During the 0.9.0 release-candidate preparation the source units are
# edited first, so this job runs the STOCK generator (never a hand
# edit of artifacts) and delivers the regenerated files as a
# NON-PRIVILEGED artifact for review: no git write, no token with
# write access, no publication. The drift report travels inside the
# artifact; a maintainer reviews it and commits the regenerated files
# explicitly.
# ------------------------------------------------------------------
docs:
name: Docs (generated markdown)
name: Docs (stock generator artifact delivery)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: actions/setup-node@v4
with:
Expand All @@ -35,13 +61,43 @@ jobs:
- name: Install Node dependencies
run: npm ci

- name: Generated docs are byte-identical to their source units
run: node scripts/build-docs.mjs --check
- name: Regenerate docs with the stock generator
run: node scripts/build-docs.mjs

- name: Report drift against the committed artifacts
run: |
set -euo pipefail
mkdir -p docs-delivery
{
git diff --stat -- README.md CHANGELOG.md docs
echo
git diff -- README.md CHANGELOG.md docs || true
} > docs-delivery/drift.diff
head -50 docs-delivery/drift.diff || true

- uses: actions/upload-artifact@v4
with:
name: generated-docs
path: |
README.md
CHANGELOG.md
docs/CONTRIBUTING.md
docs/SECURITY.md
docs/ru/README.ru.md
docs/ru/CHANGELOG.ru.md
docs/ru/CONTRIBUTING.ru.md
docs/ru/SECURITY.ru.md
docs/zh/README.zh.md
docs/zh/CHANGELOG.zh.md
docs/zh/CONTRIBUTING.zh.md
docs/zh/SECURITY.zh.md
docs-delivery/drift.diff
if-no-files-found: error

# ------------------------------------------------------------------
# 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.
# `spec/versions/0.9/tests`) — no env wiring needed.
# ------------------------------------------------------------------
test:
name: ${{ matrix.os }} / JDK ${{ matrix.jdk }}
Expand Down Expand Up @@ -82,10 +138,12 @@ jobs:
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'
expected_source = 'git+https://github.com/ktav-lang/rust?rev=c1d569f60b7f64fe94b5f022082a52c0bcac194e#c1d569f60b7f64fe94b5f022082a52c0bcac194e'
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')
if core[0].get('version') != '0.9.0':
raise SystemExit(f"expected ktav core 0.9.0; found {core[0].get('version')!r}")
print('generated lockfile resolves ktav 0.9.0 from the pinned core revision')
PY

- name: Verify required native ABI symbols
Expand Down Expand Up @@ -121,6 +179,105 @@ jobs:
path: lib/build/reports/tests/test
retention-days: 7

# ------------------------------------------------------------------
# Install the REAL candidate package (0.9.0) into a host consumer via
# publishToMavenLocal — no external publish, no secrets. The consumer
# build resolves ONLY the installed artifact, requires the exact
# 0.9.0 coordinate, and runs it end to end (parse/edit/round-trip).
# ------------------------------------------------------------------
install-consumer:
name: install real package into a host consumer (no publish)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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: Stage this PR's native artifact for the consumer
run: cargo build --release -p ktav-cabi
- name: Install the candidate package into an isolated maven repo
run: |
set -euo pipefail
# ONLY download errors (Maven Central HTTP 429) are retried
# with growing backoff; any other failure (tests, signing,
# assertions) fails immediately. The rate limit is respected:
# versions and signing policy are untouched.
attempt=1
while true; do
if ./gradlew :lib:publishToMavenLocal \
-Dmaven.repo.local="$RUNNER_TEMP/maven-local" \
-Pktav.candidateInstall=true --no-daemon --stacktrace \
2>&1 | tee "$RUNNER_TEMP/install-attempt.log"; then
exit 0
fi
grep -Eq "Received status code 429|Too Many Requests" "$RUNNER_TEMP/install-attempt.log" \
|| { echo 'non-download Gradle failure is not retried' >&2; exit 1; }
if [ "$attempt" -ge 4 ]; then
echo 'download still rate limited after retries' >&2
exit 1
fi
sleep $((attempt * 20))
attempt=$((attempt + 1))
done
- name: Installed 0.9.0 artifact is exactly the built jar
run: |
set -euo pipefail
repo="$RUNNER_TEMP/maven-local"
pom="$repo/io/github/ktav-lang/ktav/0.9.0/ktav-0.9.0.pom"
jar="$repo/io/github/ktav-lang/ktav/0.9.0/ktav-0.9.0.jar"
test -s "$pom"
test -s "$jar"
python3 - "$pom" <<'PY'
import sys
import xml.etree.ElementTree as ET
pom = ET.parse(sys.argv[1]).getroot()
ns = {"m": "http://maven.apache.org/POM/4.0.0"}
assert pom.findtext("m:version", namespaces=ns) == "0.9.0", "installed POM is not 0.9.0"
expected = {("net.java.dev.jna", "jna"): {None, "compile"},
("com.fasterxml.jackson.core", "jackson-core"): {"runtime"}}
deps = pom.find("m:dependencies", ns)
seen = set()
for dep in (deps if deps is not None else []):
key = (dep.findtext("m:groupId", namespaces=ns), dep.findtext("m:artifactId", namespaces=ns))
assert key in expected, "unexpected dependency in installed POM: %s" % (key,)
assert dep.findtext("m:scope", namespaces=ns) in expected[key], "unexpected scope for %s" % (key,)
seen.add(key)
assert seen == set(expected), "installed POM dependency set differs: %s" % (seen,)
print("installed 0.9.0 POM verified: exact version, known dependency set")
PY
# The installed jar must be byte-identical to the jar this
# candidate just built — not a stale 0.8.1 leftover.
test "$(sha256sum < "$jar" | cut -d' ' -f1)" = "$(sha256sum < lib/build/libs/ktav-0.9.0.jar | cut -d' ' -f1)"
echo "installed jar is byte-identical to the built candidate jar"
- name: Host consumer resolves and runs the installed package via the project wrapper
run: |
set -euo pipefail
checksum="$(sha256sum < "$RUNNER_TEMP/maven-local/io/github/ktav-lang/ktav/0.9.0/ktav-0.9.0.jar" | cut -d' ' -f1)"
# Same download-only 429 backoff as the install step above;
# consumer assertion failures are never retried.
attempt=1
while true; do
if ./gradlew -p ci/host-consumer verifyResolved run \
-Dmaven.repo.local="$RUNNER_TEMP/maven-local" \
-PinstalledJarChecksum="$checksum" \
-PktavNativeLib="$GITHUB_WORKSPACE/target/release/libktav_cabi.so" --no-daemon --stacktrace \
2>&1 | tee "$RUNNER_TEMP/consumer-attempt.log"; then
exit 0
fi
grep -Eq "Received status code 429|Too Many Requests" "$RUNNER_TEMP/consumer-attempt.log" \
|| { echo 'non-download Gradle failure is not retried' >&2; exit 1; }
if [ "$attempt" -ge 4 ]; then
echo 'download still rate limited after retries' >&2
exit 1
fi
sleep $((attempt * 20))
attempt=$((attempt + 1))
done

lint-rust:
name: rust clippy + fmt
runs-on: ubuntu-latest
Expand Down Expand Up @@ -215,7 +372,7 @@ jobs:
- 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
run: java -cp "lib/build/libs/ktav-0.9.0.jar:lib/build/libs/ktav-0.9.0-pure-check.jar" lang.ktav.PureSmokeMain

# ------------------------------------------------------------------
# CI-only verification of the GENERATED POM and Gradle Module
Expand Down Expand Up @@ -311,12 +468,31 @@ jobs:
rustc --version
cargo --version
java -version
for round in 1 2 3 4 5; do
bench_gradle() {
local side="$1" attempt=1 log
# ONLY download errors (HTTP 429) are retried; benchmark
# assertion failures fail immediately.
log="$(mktemp)"
while true; do
if 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 \
2>&1 | tee "$log"; then
return 0
fi
grep -Eq "Received status code 429|Too Many Requests" "$log" || return 1
if [ "$attempt" -ge 4 ]; then
echo 'download still rate limited after retries' >&2
return 1
fi
sleep $((attempt * 20))
attempt=$((attempt + 1))
done
}
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
bench_gradle "$side"
done
done
} 2>&1 | tee source-edit-benchmark.log
Expand Down Expand Up @@ -371,10 +547,12 @@ jobs:
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'
expected_source = 'git+https://github.com/ktav-lang/rust?rev=c1d569f60b7f64fe94b5f022082a52c0bcac194e#c1d569f60b7f64fe94b5f022082a52c0bcac194e'
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')
if core[0].get('version') != '0.9.0':
raise SystemExit(f"expected ktav core 0.9.0; found {core[0].get('version')!r}")
print('generated lockfile resolves ktav 0.9.0 from the pinned core revision')
PY

- name: Empty-input tests against the real debug artifact
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/licenses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ jobs:
- name: Verify settings plugin and reviewed source license
run: |
set -euo pipefail
printf '%s %s\n' 25feb033cedd1d724cdbe0dce5e8148f4734518e1db325b1b3c8b95ade92ef90 settings.gradle.kts | sha256sum --check
printf '%s %s\n' 4a2014dc8c905824163ebc3fd396d24b9fbdf33bf30d050e79f8643a3432ae20 settings.gradle.kts | sha256sum --check
curl -fsSL https://plugins.gradle.org/m2/org/gradle/toolchains/foojay-resolver-convention/org.gradle.toolchains.foojay-resolver-convention.gradle.plugin/0.9.0/org.gradle.toolchains.foojay-resolver-convention.gradle.plugin-0.9.0.pom > "$RUNNER_TEMP/foojay-marker.pom"
printf '%s %s\n' db7cf11bee6884efb28904139f62c00f8b45853e60c0f41715cf69576b6bfdf0 "$RUNNER_TEMP/foojay-marker.pom" | sha256sum --check
curl -fsSL https://raw.githubusercontent.com/gradle/foojay-toolchains/f4575ddf844fcfd4ad9e758d2040cfd50b59f173/LICENSE > "$RUNNER_TEMP/foojay-LICENSE"
printf '%s %s\n' c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 "$RUNNER_TEMP/foojay-LICENSE" | sha256sum --check
- name: Check all Gradle configurations and buildscript dependencies
run: ./gradlew --no-daemon --no-parallel -I ci/license-init.gradle checkLicense
run: >
./gradlew --no-daemon --no-parallel -I ci/license-init.gradle
:lib:generatePomFileForMavenPublication checkLicense
- name: Build JARs and verify license files
shell: bash
run: |
Expand Down
26 changes: 25 additions & 1 deletion .github/workflows/native-distribution-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,31 @@ permissions:
contents: read

jobs:
# Bind the exact PR HEAD commit (not the synthetic merge commit): the
# distribution below must be built from the reviewed candidate source.
bind-source:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- name: Checked-out source is the exact PR head commit
run: |
expected="${{ github.event.pull_request.head.sha }}"
test -n "$expected" || { echo 'pull request head SHA is unavailable' >&2; exit 1; }
actual="$(git rev-parse HEAD)"
test "$actual" = "$expected" || { echo "checkout HEAD $actual != expected PR head $expected" >&2; exit 1; }
echo "candidate source bound to $actual"

native-distribution:
needs: bind-source
uses: ./.github/workflows/native-distribution.yml
with:
source-ref: b252ccfaed66505952ad63a99663e8b6ff530d62
# Current candidate HEAD: the PR's exact head commit, verified by
# bind-source and by the rev-parse guards inside the reusable
# workflow. The historical 0.8.1 binding source
# b252ccfaed66505952ad63a99663e8b6ff530d62 stays valid as a
# historical proof in past runs/releases; it must not be reused as
# the 0.9.0 candidate source.
source-ref: ${{ github.event.pull_request.head.sha }}
18 changes: 12 additions & 6 deletions .github/workflows/native-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,19 @@ jobs:
with:
tool: cargo-zigbuild

- name: Verify published Rust core provenance
- name: Verify candidate core git provenance
shell: bash
run: |
set -euo pipefail
# The 0.9.0 candidate consumes the core STRICTLY from the pinned
# git revision (it is not published on crates.io). Verify the
# exact git-source URL, the exact full resolved SHA, and the
# core package version in the lockfile that the --locked builds
# below actually use — identity of the built source without any
# invented registry checksum.
grep -F 'rev = "c1d569f60b7f64fe94b5f022082a52c0bcac194e"' Cargo.toml \
|| { echo 'workspace does not pin the reviewed core revision' >&2; exit 1; }
cargo generate-lockfile
cargo update -p ktav --precise 0.8.1
python3 - <<'PY'
import tomllib
with open('Cargo.lock', 'rb') as source:
Expand All @@ -160,14 +167,13 @@ jobs:
if len(core) != 1:
raise SystemExit('expected exactly one ktav core')
expected = {
'version': '0.8.1',
'source': 'registry+https://github.com/rust-lang/crates.io-index',
'checksum': '7140dfe2fa6c320e74768cd6a637828c2d26f81746254f4fcd805f3993bd3fd5',
'version': '0.9.0',
'source': 'git+https://github.com/ktav-lang/rust?rev=c1d569f60b7f64fe94b5f022082a52c0bcac194e#c1d569f60b7f64fe94b5f022082a52c0bcac194e',
}
for field, value in expected.items():
if core[0].get(field) != value:
raise SystemExit(f'ktav {field} mismatch: {core[0].get(field)!r}')
print('published ktav 0.8.1 core provenance verified')
print('candidate ktav 0.9.0 core resolved from the exact pinned git revision')
PY

- uses: taiki-e/install-action@v2
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
test "$GITHUB_REF_NAME" = v0.8.1 || { echo 'tag does not match package version' >&2; exit 1; }
test "$GITHUB_REF_NAME" = v0.9.0 || { echo 'tag does not match package version' >&2; exit 1; }
target="$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_REF_NAME" --jq '.sha')"
test "$target" = "$GITHUB_SHA" || { echo 'tag does not match the built commit' >&2; exit 1; }
accepted="$(gh run list --repo "$GITHUB_REPOSITORY" --workflow ci.yml \
Expand Down Expand Up @@ -73,17 +73,17 @@ jobs:
run: |
set -euo pipefail
bash scripts/check-publish-metadata.sh
for jar in ktav-0.8.1.jar ktav-0.8.1-sources.jar lib-maven-javadoc-0.8.1-javadoc.jar; do
for jar in ktav-0.9.0.jar ktav-0.9.0-sources.jar lib-maven-javadoc-0.9.0-javadoc.jar; do
test -s "lib/build/libs/$jar" || { echo "missing JAR: $jar" >&2; exit 1; }
done

- uses: actions/upload-artifact@v4
with:
name: jars
path: |
lib/build/libs/ktav-0.8.1.jar
lib/build/libs/ktav-0.8.1-sources.jar
lib/build/libs/lib-maven-javadoc-0.8.1-javadoc.jar
lib/build/libs/ktav-0.9.0.jar
lib/build/libs/ktav-0.9.0-sources.jar
lib/build/libs/lib-maven-javadoc-0.9.0-javadoc.jar
if-no-files-found: error

# ------------------------------------------------------------------
Expand Down
Loading
Loading