Skip to content

Commit b45154d

Browse files
dfa1claude
andcommitted
ci: smoke-test published releases on every supported OS/arch
Add a manually-triggered workflow that pulls a released version from Maven Central and runs a JBang smoke test on one GitHub-hosted runner per native classifier: linux-x86_64 (ubuntu-latest), linux-aarch64 (ubuntu-24.04-arm), osx-x86_64 (macos-13), osx-aarch64 (macos-14), windows-x86_64 (windows-latest), windows-aarch64 (windows-11-arm). The smoke (.github/smoke/Smoke.java) exercises a core compress/decompress round-trip plus a dictionary train + round-trip, so it proves the bundled native library actually loads and works on real hardware for each arch — not a source build (no zig, no submodule), exactly what users consume. Verified locally end-to-end on osx-aarch64 against 0.6 (core 40000 -> 38 bytes, dictionary round-trip passed, zstd 1.5.7). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent bdc7758 commit b45154d

2 files changed

Lines changed: 107 additions & 0 deletions

File tree

.github/smoke/Smoke.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//JAVA 25
3+
//RUNTIME_OPTIONS --enable-native-access=ALL-UNNAMED
4+
// Dependencies are supplied at run time via `jbang --deps ...` so the workflow
5+
// can pin the released version and the per-arch native jar from the matrix.
6+
7+
import io.github.dfa1.zstd.Zstd;
8+
import io.github.dfa1.zstd.ZstdCompressCtx;
9+
import io.github.dfa1.zstd.ZstdDecompressCtx;
10+
import io.github.dfa1.zstd.ZstdDictionary;
11+
12+
import java.util.ArrayList;
13+
import java.util.Arrays;
14+
import java.util.List;
15+
16+
/// Smoke test for a published zstd-java release: proves the bundled native
17+
/// library loads on the host OS/arch and the core + dictionary paths work.
18+
/// Run against a release from Maven Central, one arch per CI matrix leg.
19+
public class Smoke {
20+
21+
public static void main(String[] args) {
22+
String platform = System.getProperty("os.name") + "/" + System.getProperty("os.arch");
23+
24+
// 1. Core round-trip — proves the native library loaded and compress/decompress work.
25+
byte[] original = "the quick brown fox ".repeat(2000).getBytes();
26+
byte[] compressed = Zstd.compress(original, 9);
27+
byte[] restored = Zstd.decompress(compressed);
28+
if (!Arrays.equals(original, restored)) {
29+
throw new AssertionError("core round-trip mismatch on " + platform);
30+
}
31+
if (compressed.length >= original.length) {
32+
throw new AssertionError("expected compression to shrink the input on " + platform);
33+
}
34+
35+
// 2. Dictionary round-trip — exercises the ZDICT training path (the library's differentiator).
36+
List<byte[]> samples = new ArrayList<>();
37+
for (int i = 0; i < 2000; i++) {
38+
samples.add(("{\"id\":" + i + ",\"user\":\"user_" + (i % 100) + "\",\"event\":\"click\"}").getBytes());
39+
}
40+
ZstdDictionary dict = ZstdDictionary.train(samples, 8 * 1024);
41+
try (ZstdCompressCtx cctx = new ZstdCompressCtx();
42+
ZstdDecompressCtx dctx = new ZstdDecompressCtx()) {
43+
byte[] message = samples.get(7);
44+
byte[] dictCompressed = cctx.compress(message, dict);
45+
byte[] dictRestored = dctx.decompress(dictCompressed, message.length, dict);
46+
if (!Arrays.equals(message, dictRestored)) {
47+
throw new AssertionError("dictionary round-trip mismatch on " + platform);
48+
}
49+
}
50+
51+
System.out.println("OK " + platform
52+
+ " | zstd " + Zstd.version()
53+
+ " | core " + original.length + " -> " + compressed.length + " bytes"
54+
+ " | dictionary round-trip passed");
55+
}
56+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release smoke test
2+
3+
# Verifies a PUBLISHED release on Maven Central actually loads and runs on every
4+
# supported OS/arch — one runner per native classifier. Pulls the release jars
5+
# from Central (no source build, no submodule, no zig), so it tests exactly what
6+
# users consume. Trigger manually and pass the version to check.
7+
8+
on:
9+
workflow_dispatch:
10+
inputs:
11+
version:
12+
description: Released version to smoke-test (as published to Maven Central)
13+
required: true
14+
default: "0.6"
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
smoke:
21+
name: ${{ matrix.classifier }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
include:
26+
- { os: ubuntu-latest, classifier: linux-x86_64 }
27+
- { os: ubuntu-24.04-arm, classifier: linux-aarch64 }
28+
- { os: macos-13, classifier: osx-x86_64 }
29+
- { os: macos-14, classifier: osx-aarch64 }
30+
- { os: windows-latest, classifier: windows-x86_64 }
31+
- { os: windows-11-arm, classifier: windows-aarch64 }
32+
runs-on: ${{ matrix.os }}
33+
steps:
34+
- name: Checkout (smoke sources only)
35+
uses: actions/checkout@v4
36+
37+
- name: Set up JDK 25
38+
uses: actions/setup-java@v4
39+
with:
40+
distribution: temurin
41+
java-version: '25'
42+
43+
- name: Set up JBang
44+
uses: jbangdev/setup-jbang@main
45+
46+
- name: Smoke-test ${{ inputs.version }} on ${{ matrix.classifier }}
47+
shell: bash
48+
run: |
49+
jbang --java 25 \
50+
--deps "io.github.dfa1.zstd:zstd:${{ inputs.version }},io.github.dfa1.zstd:zstd-native-${{ matrix.classifier }}:${{ inputs.version }}" \
51+
.github/smoke/Smoke.java

0 commit comments

Comments
 (0)