Skip to content

Commit 10b7c9c

Browse files
DRMacIverclaude
andcommitted
Add GitHub Actions CI (hegeldev conventions)
ci.yml: lint (fmt check + zizmor), test across a Java 22/25 matrix staging libhegel from the matching hegel-rust release into HEGEL_LIBHEGEL_PATH and enforcing 100% coverage via `just coverage`, and a docs (javadoc) job. check-release.yml: requires a well-formed RELEASE.md when source changes (self-contained; bypass with the 'skip release' label). Plus RELEASE-sample.md and an install-tools composite action. Follows org conventions: permissions {}, persist-credentials false, SHA-pinned actions, concurrency cancellation. The org's release-publishing automation (app token + release.py) is left out as it depends on org-level secrets and infrastructure. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 081bcdb commit 10b7c9c

4 files changed

Lines changed: 197 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Install tools
2+
inputs:
3+
tools:
4+
required: true
5+
runs:
6+
using: composite
7+
steps:
8+
- id: parse
9+
env:
10+
TOOLS: ${{ inputs.tools }}
11+
# The allowlist below doubles as input validation. Adding a new tool
12+
# means extending the case-statement AND adding a matching install step.
13+
run: |
14+
for tool in $TOOLS; do
15+
case "$tool" in
16+
just) echo "$tool=true" >> "$GITHUB_OUTPUT" ;;
17+
*) echo "::error::Unknown tool: $tool"; exit 1 ;;
18+
esac
19+
done
20+
shell: bash
21+
- if: steps.parse.outputs.just == 'true' && runner.os == 'Linux'
22+
run: sudo apt-get update && sudo apt-get install -y just
23+
shell: bash
24+
- if: steps.parse.outputs.just == 'true' && runner.os == 'Windows'
25+
run: choco install just -y --no-progress
26+
shell: pwsh
27+
- if: steps.parse.outputs.just == 'true' && runner.os == 'macOS'
28+
run: brew install just
29+
shell: bash
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Check release
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
types: [opened, synchronize, reopened, labeled, unlabeled]
7+
8+
permissions: {}
9+
10+
jobs:
11+
check-release:
12+
name: check release
13+
if: "!contains(github.event.pull_request.labels.*.name, 'skip release')"
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
steps:
18+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
19+
with:
20+
fetch-depth: 0
21+
persist-credentials: false
22+
23+
- name: Require RELEASE.md when source changes
24+
env:
25+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
26+
run: |
27+
set -euo pipefail
28+
if git diff --name-only "$BASE_SHA"...HEAD | grep -qE '^(src/|pom\.xml$)'; then
29+
if [ ! -f RELEASE.md ]; then
30+
echo "::error::Source files changed but RELEASE.md is missing." \
31+
"Add one (see RELEASE-sample.md) or label the PR 'skip release'."
32+
exit 1
33+
fi
34+
first=$(head -n1 RELEASE.md)
35+
case "$first" in
36+
"RELEASE_TYPE: major"|"RELEASE_TYPE: minor"|"RELEASE_TYPE: patch") ;;
37+
*)
38+
echo "::error::RELEASE.md must start with" \
39+
"'RELEASE_TYPE: major|minor|patch', got: $first"
40+
exit 1
41+
;;
42+
esac
43+
echo "RELEASE.md present and well-formed ($first)."
44+
else
45+
echo "No source changes; RELEASE.md not required."
46+
fi

‎.github/workflows/ci.yml‎

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions: {}
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
lint:
17+
name: lint
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
steps:
22+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
23+
with:
24+
persist-credentials: false
25+
26+
- uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
27+
with:
28+
distribution: temurin
29+
java-version: "25"
30+
cache: maven
31+
32+
- uses: ./.github/actions/install-tools
33+
with:
34+
tools: just
35+
36+
- name: Lint
37+
run: just lint
38+
39+
- name: Install zizmor
40+
run: pip install zizmor==1.23.1
41+
- name: Run zizmor
42+
run: zizmor --format plain .github/
43+
44+
test:
45+
name: "test (java ${{ matrix.java-version }})"
46+
runs-on: ubuntu-latest
47+
permissions:
48+
contents: read
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
java-version: ["22", "25"]
53+
steps:
54+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
55+
with:
56+
persist-credentials: false
57+
58+
- uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
59+
with:
60+
distribution: temurin
61+
java-version: ${{ matrix.java-version }}
62+
cache: maven
63+
64+
- uses: ./.github/actions/install-tools
65+
with:
66+
tools: just
67+
68+
- name: Stage libhegel from the matching GitHub release
69+
id: libhegel
70+
run: |
71+
set -euo pipefail
72+
VERSION=$(grep -oP 'LIBHEGEL_VERSION = "\K[^"]+' src/main/java/dev/hegel/LibraryLoader.java)
73+
ASSET="libhegel-linux-amd64.so"
74+
URL_BASE="https://github.com/hegeldev/hegel-rust/releases/download/v${VERSION}"
75+
DEST="${RUNNER_TEMP}/libhegel.so"
76+
curl -fsSL -o "${DEST}" "${URL_BASE}/${ASSET}"
77+
curl -fsSL -o "${DEST}.sha256" "${URL_BASE}/${ASSET}.sha256"
78+
# The published .sha256 file is GNU sha256sum style: <digest> <asset>.
79+
WANT=$(awk '{print $1}' "${DEST}.sha256")
80+
echo "${WANT} ${DEST}" | sha256sum -c -
81+
echo "path=${DEST}" >> "$GITHUB_OUTPUT"
82+
83+
- name: Test with 100% coverage enforcement
84+
env:
85+
# An explicit path disables the auto-downloader; the engine runs in-process.
86+
HEGEL_LIBHEGEL_PATH: ${{ steps.libhegel.outputs.path }}
87+
run: just coverage
88+
89+
docs:
90+
name: docs
91+
runs-on: ubuntu-latest
92+
permissions:
93+
contents: read
94+
steps:
95+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
96+
with:
97+
persist-credentials: false
98+
99+
- uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
100+
with:
101+
distribution: temurin
102+
java-version: "25"
103+
cache: maven
104+
105+
- uses: ./.github/actions/install-tools
106+
with:
107+
tools: just
108+
109+
- name: Build Javadoc
110+
run: just docs

‎RELEASE-sample.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
RELEASE_TYPE: patch
2+
3+
A short, user-facing description of the change, written for the CHANGELOG.
4+
5+
Copy this file to `RELEASE.md` in any pull request that changes source. The first line must be
6+
`RELEASE_TYPE: major`, `RELEASE_TYPE: minor`, or `RELEASE_TYPE: patch`:
7+
8+
- `patch` — bug fixes
9+
- `minor` — new, backwards-compatible features
10+
- `major` — breaking changes (maintainers only)
11+
12+
Label a PR `skip release` to bypass this requirement (e.g. for docs/CI-only changes).

0 commit comments

Comments
 (0)