From 19253c105b3c04bb5a224eb03f9b0cd9b920a337 Mon Sep 17 00:00:00 2001 From: Guoliang Chen Date: Wed, 26 Aug 2026 01:51:45 -0700 Subject: [PATCH] CI on Gitea Actions: checks on push, full cross-platform release on tag; v0.7.1 .gitea/workflows/ci.yml runs fmt/clippy/test on every master push and PR on the self-hosted mac-arm64 runner (host mode, brew-serviced act_runner). .gitea/workflows/release.yml turns a vX.Y.Z tag into a Gitea release: tools/release.sh --cross (Apple Silicon + x86_64 macOS, musl and RHEL 8 linux-gnu, Windows; both binaries; .vsix; SHA256SUMS), a tag-vs-version check, tools/release_notes.sh (the CHANGELOG section becomes the notes; missing section fails the release) and tools/publish_release.sh (get-or-create + attach, re-run safe). Version bumped to 0.7.1 with a changelog covering directive-split and this flow. Co-Authored-By: Claude Fable 5 --- .gitea/workflows/ci.yml | 22 ++++++++ .gitea/workflows/release.yml | 36 +++++++++++++ CHANGELOG.md | 39 ++++++++++++++ Cargo.lock | 16 +++--- Cargo.toml | 2 +- docs/features/ci-release/README.md | 83 ++++++++++++++++++++++++++++++ editors/vscode/package-lock.json | 4 +- editors/vscode/package.json | 2 +- tools/RELEASING.md | 28 ++++++++++ tools/publish_release.sh | 55 ++++++++++++++++++++ tools/release_notes.sh | 31 +++++++++++ 11 files changed, 306 insertions(+), 12 deletions(-) create mode 100644 .gitea/workflows/ci.yml create mode 100644 .gitea/workflows/release.yml create mode 100644 docs/features/ci-release/README.md create mode 100755 tools/publish_release.sh create mode 100755 tools/release_notes.sh diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..8a35c6a --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,22 @@ +# CI: the three checks CLAUDE.md requires before any work is finished, +# enforced on every push. Runs on the self-hosted mac-arm64 runner in host +# mode (no containers), so the toolchain is the same one releases are built +# with. The corpus is not in the repository, so corpus scoring stays a +# local-only check (scripts/score.sh). +name: ci +on: + push: + branches: [master] + pull_request: + +jobs: + checks: + runs-on: macos-arm64 + steps: + - uses: actions/checkout@v4 + - name: cargo fmt + run: cargo fmt --all -- --check + - name: cargo clippy + run: cargo clippy --all-targets -- -D warnings + - name: cargo test + run: cargo test --workspace diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..948d6cd --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,36 @@ +# Release: pushing a tag `vX.Y.Z` builds every distribution artifact and +# publishes a Gitea release with the CHANGELOG section for that version as +# its notes. The artifact set is exactly what tools/release.sh --cross +# produces: host (Apple Silicon) + x86_64 macOS + static-musl Linux + +# RHEL 8-compatible linux-gnu + Windows binaries for both lucisv and +# lucisv-server, the platform-independent .vsix, and SHA256SUMS. +# +# The release fails, deliberately, when the tag does not match the +# workspace version or CHANGELOG.md has no section for it: every release +# ships with real, written notes (see tools/RELEASING.md). +name: release +on: + push: + tags: + - 'v*' + +jobs: + build-and-publish: + runs-on: macos-arm64 + steps: + - uses: actions/checkout@v4 + - name: Build release artifacts for every target + run: tools/release.sh --cross + - name: Check the tag against the crate version + run: | + v=$(target/release/lucisv --version | awk '{print $2}') + [ "v$v" = "$GITHUB_REF_NAME" ] || { + echo "tag $GITHUB_REF_NAME does not match crate version $v" >&2 + exit 1 + } + - name: Extract the release notes from CHANGELOG.md + run: tools/release_notes.sh "${GITHUB_REF_NAME#v}" > dist/RELEASE_NOTES.md + - name: Create the release and attach the artifacts + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: tools/publish_release.sh "$GITHUB_REF_NAME" dist diff --git a/CHANGELOG.md b/CHANGELOG.md index a381596..9df054e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,45 @@ All notable changes to lucisv are recorded here. Versions follow [semantic versioning](https://semver.org/); until 1.0 the CLI's exit codes (see `README.md`) are the only frozen contract. +## 0.7.1 — 2026-08-26 + +Conditional-split recovery and an automated release. + +### Formatter: `` `ifdef`` regions whose arms are half a declaration + +A conditional region whose arms are each an incomplete fragment of one +construct — two alternative declaration heads sharing a single `{ ... };` +body, or two `typedef struct {` bodies sharing one closing — used to be a +parse error. The strict parser now recovers the whole construct as a +**verbatim item**: exact source bytes, first line re-indented, nothing +inside reformatted (the `constraint`/`covergroup`/assertions precedent). +The trigger is deliberately narrow — it fires only when the failed arm +left a bracket open inside a region that is genuinely open at item scope, +where "at item scope" is structural: directives inside opaque bodies +(constraints, covergroups, properties) cannot influence it, and a +recovered block hands back exactly the nesting it swallowed. A stray +unmatched `` `endif``, a forgotten `;`, or any ordinary syntax error near +a directive still refuses with exit 2. The safety net (`verify.rs`) is +untouched — verbatim bytes need no new forgiveness. Corpus: **800 → 813 of +820 files (97.6% → 99.1%)**; the 13 gains are riscv-dv's +`riscv_core_setting.sv` (12 target variants) and `riscv_instr_pkg.sv`. +Every remaining failure needs macro expansion (a deliberate non-goal) or +is not valid standalone Verilog. Design, the three-round adversarial QA +history and the accepted residual risk: +`docs/features/directive-split/README.md`. + +### CI and releases + +The repository now builds and releases itself on Gitea Actions +(`docs/features/ci-release/README.md`): every push runs +fmt/clippy/test on a self-hosted Apple Silicon runner, and pushing a +`vX.Y.Z` tag runs `tools/release.sh --cross` — Apple Silicon + Intel +macOS, static-musl and RHEL 8-compatible Linux, and Windows builds of +both `lucisv` and `lucisv-server`, plus the `.vsix` and `SHA256SUMS` — +and publishes a Gitea release with that version's CHANGELOG section as +its notes. A tag that does not match the workspace version, or has no +CHANGELOG section, fails instead of releasing. + ## 0.7.0 — 2026-08-25 Ghost text grows up: aligned, and fluent in the constructs a designer diff --git a/Cargo.lock b/Cargo.lock index 072f9e4..0e73519 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,7 +97,7 @@ dependencies = [ [[package]] name = "lucisv" -version = "0.7.0" +version = "0.7.1" dependencies = [ "lucisv_core", "rayon", @@ -108,11 +108,11 @@ dependencies = [ [[package]] name = "lucisv_core" -version = "0.7.0" +version = "0.7.1" [[package]] name = "lucisv_server" -version = "0.7.0" +version = "0.7.1" dependencies = [ "lsp-server", "lsp-types", @@ -248,14 +248,14 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "vlog_formatter" -version = "0.7.0" +version = "0.7.1" dependencies = [ "vlog_parser", ] [[package]] name = "vlog_linter" -version = "0.7.0" +version = "0.7.1" dependencies = [ "vlog_formatter", "vlog_parser", @@ -264,11 +264,11 @@ dependencies = [ [[package]] name = "vlog_parser" -version = "0.7.0" +version = "0.7.1" [[package]] name = "vlog_refactor" -version = "0.7.0" +version = "0.7.1" dependencies = [ "vlog_parser", "vlog_semantic", @@ -276,7 +276,7 @@ dependencies = [ [[package]] name = "vlog_semantic" -version = "0.7.0" +version = "0.7.1" dependencies = [ "vlog_parser", ] diff --git a/Cargo.toml b/Cargo.toml index 1c57d20..8bcc3f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ members = [ ] [workspace.package] -version = "0.7.0" +version = "0.7.1" authors = ["Guoliang Chen"] edition = "2021" license = "MIT" diff --git a/docs/features/ci-release/README.md b/docs/features/ci-release/README.md new file mode 100644 index 0000000..1dbe605 --- /dev/null +++ b/docs/features/ci-release/README.md @@ -0,0 +1,83 @@ +# ci-release + +## Goal + +Automate the checks and the release. Every push to master runs the three +checks CLAUDE.md requires (fmt, clippy, test) on Gitea Actions; every tag +`vX.Y.Z` builds the full cross-platform artifact set (Apple Silicon + +x86_64 macOS, static-musl and RHEL 8-compatible Linux, Windows — both +binaries each — plus the `.vsix` and `SHA256SUMS`) and publishes a Gitea +release whose notes are the CHANGELOG section for that version. The point +is that a release is one `git tag` + `git push` and cannot ship without +green checks, matching versions, and written notes. + +## Assumptions + +- The runner is `mac-arm64`: this development Mac, registered instance-wide + against https://git.luci.ooo with labels `macos-arm64`/`self-hosted`, + running in **host mode** (no containers) as a Homebrew service + (`brew services start gitea-runner`; config + `/opt/homebrew/etc/gitea-runner/config.yaml`, state and job workdirs + under `/opt/homebrew/var/lib/gitea-runner`). Everything + `tools/release.sh --cross` needs (rustup targets, mingw-w64, the + messense linux-gnu toolchain, node) is already installed per + `tools/RELEASING.md`; the workflows install nothing. +- One runner, capacity 1: CI and release jobs queue rather than race. A + release build and a local `cargo build` can still contend for the + machine; acceptable on a solo project. +- The corpus is not in the repository, so CI does not score it; + `scripts/score.sh` stays a local check. +- `secrets.GITHUB_TOKEN` is auto-provided by Gitea Actions with rights to + create releases and attach assets on this repo. +- Release notes are written by hand (by the lead/Claude, specific to the + changes) into `CHANGELOG.md` *before* tagging; CI publishes, it does not + compose. A missing section fails the release on purpose. + +## Handshakes + +- Consumes `tools/release.sh --cross` unchanged: artifact names + (`lucisv[-server]--[.exe]`, `lucisv-.vsix`, + `SHA256SUMS`) and the version-from-binary convention. +- Consumes `CHANGELOG.md`'s heading convention: `## — `; + `tools/release_notes.sh` keys on the second word of `## ` headings. +- `tools/publish_release.sh` expects the GitHub-compatible CI environment + (`GITHUB_SERVER_URL`, `GITHUB_REPOSITORY`, `GITHUB_TOKEN`, + `GITHUB_REF_NAME` via the workflow) and jq + curl on the runner. +- Promises to the release checklist (`tools/RELEASING.md`): the tag must + equal `v` + the workspace version, and the CHANGELOG section must exist, + or the workflow fails before publishing anything. + +## Status / TODO + +- [x] Runner installed (`brew install gitea-runner`), registered + (`mac-arm64`), running as a service. +- [x] `.gitea/workflows/ci.yml` — fmt/clippy(-D warnings)/test on every + master push and PR. +- [x] `.gitea/workflows/release.yml` — tag → cross build → version check → + notes extraction → release with assets. +- [x] `tools/release_notes.sh` (+ missing-section failure path tested), + `tools/publish_release.sh` (get-or-create, skip-attached re-run safety). +- [x] End-to-end verification with a real tag (v0.7.1). +- [ ] A second runner on a non-macOS host, if native-built (rather than + cross-built) Linux artifacts are ever wanted. + +## Work log + +- 2026-08-26 — lead. Installed and registered the runner (one-time + instance token from the owner), wrote both workflows and both scripts, + smoke-tested `release_notes.sh` on the present-and-missing paths. + Decisions: host mode over docker (the cross toolchain lives on this Mac + and macOS jobs can't be containerized anyway); notes extracted from + CHANGELOG.md rather than generated in CI (the owner wants specific, + written notes — composing them is the lead's job at tag time, publishing + is CI's); a hard failure on tag/version mismatch or missing notes rather + than a fallback body. Version bumped to 0.7.1 and released end-to-end as + the verification. + +## QA log + +_(no QA round — infrastructure, verified by the live v0.7.1 run; see work log)_ + +## Review + +_(reserved)_ diff --git a/editors/vscode/package-lock.json b/editors/vscode/package-lock.json index a25fb76..6d39a97 100644 --- a/editors/vscode/package-lock.json +++ b/editors/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "lucisv", - "version": "0.7.0", + "version": "0.7.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lucisv", - "version": "0.7.0", + "version": "0.7.1", "license": "MIT", "dependencies": { "vscode-languageclient": "9.0.1" diff --git a/editors/vscode/package.json b/editors/vscode/package.json index d06166f..438f44c 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -2,7 +2,7 @@ "name": "lucisv", "displayName": "lucisv — Verilog/SystemVerilog", "description": "Formatting, diagnostics, navigation and semantic highlighting for Verilog and SystemVerilog, served by the lucisv language server.", - "version": "0.7.0", + "version": "0.7.1", "publisher": "guoliangchen", "author": "Guoliang Chen", "license": "MIT", diff --git a/tools/RELEASING.md b/tools/RELEASING.md index 71a86da..530393f 100644 --- a/tools/RELEASING.md +++ b/tools/RELEASING.md @@ -202,3 +202,31 @@ npx ovsx publish dist/lucisv-0.7.0.vsix -p "$OVSX_TOKEN" Both tokens are secrets. Neither belongs in this repo, in a shell history, or in any file `release.sh` reads. + +## CI releases (Gitea Actions) + +Since 0.7.1 the whole checklist above is automated +(`docs/features/ci-release/README.md`): steps 1–2 stay manual (bump the +four version files, write the CHANGELOG section — it becomes the release +notes verbatim), then + +```bash +git tag v +git push origin v +``` + +does the rest on the `mac-arm64` runner: `tools/release.sh --cross`, a +tag-vs-`lucisv --version` consistency check, `tools/release_notes.sh` (a +missing CHANGELOG section fails the release), and +`tools/publish_release.sh`, which creates the Gitea release and attaches +every `dist/` artifact. Ordinary pushes run fmt/clippy/test via +`.gitea/workflows/ci.yml`. + +The runner is this Mac: `brew install gitea-runner`, registered +instance-wide as `mac-arm64` (labels `macos-arm64`/`self-hosted`, host +mode), running via `brew services start gitea-runner`; config at +`/opt/homebrew/etc/gitea-runner/config.yaml`, logs at +`/opt/homebrew/var/log/gitea-runner.{log,err}`. Registration tokens are +one-time and minted in Gitea's admin UI; nothing secret lives in this +repo — the release workflow authenticates with the `GITHUB_TOKEN` Gitea +Actions injects per job. diff --git a/tools/publish_release.sh b/tools/publish_release.sh new file mode 100755 index 0000000..dc5c5c0 --- /dev/null +++ b/tools/publish_release.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# Create (or reuse) the Gitea release for a tag and attach every artifact. +# +# Usage: tools/publish_release.sh +# +# Written for the release workflow: expects the CI-provided environment +# (GITHUB_SERVER_URL, GITHUB_REPOSITORY, GITHUB_TOKEN) and a dist directory +# holding the artifacts plus RELEASE_NOTES.md (the release body; not +# attached). A tag containing "-" (v0.8.0-rc1) is marked prerelease. +# Re-running is safe: an existing release for the tag is reused, and an +# asset name that is already attached is skipped. + +set -eu + +[ $# -eq 2 ] || { echo "usage: $0 " >&2; exit 2; } +tag=$1 +dist=$2 +for var in GITHUB_SERVER_URL GITHUB_REPOSITORY GITHUB_TOKEN; do + eval "[ -n \"\${$var:-}\" ]" || { echo "$var is not set" >&2; exit 2; } +done +notes="$dist/RELEASE_NOTES.md" +[ -s "$notes" ] || { echo "no release notes at $notes" >&2; exit 2; } + +api="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY" +auth="Authorization: token $GITHUB_TOKEN" + +prerelease=false +case $tag in *-*) prerelease=true ;; esac + +# Reuse the release if a re-run already created it, else create it. +id=$(curl -sS -H "$auth" "$api/releases/tags/$tag" | jq -r '.id // empty') +if [ -n "$id" ]; then + echo "release for $tag exists (id $id), reusing" +else + payload=$(jq -n --arg tag "$tag" --rawfile body "$notes" --argjson pre "$prerelease" \ + '{tag_name: $tag, name: $tag, body: $body, draft: false, prerelease: $pre}') + id=$(curl -sSf -X POST -H "$auth" -H 'Content-Type: application/json' \ + -d "$payload" "$api/releases" | jq -r .id) + echo "created release $tag (id $id)" +fi + +attached=$(curl -sS -H "$auth" "$api/releases/$id/assets" | jq -r '.[].name') +for f in "$dist"/*; do + [ -f "$f" ] || continue + name=$(basename "$f") + [ "$name" = RELEASE_NOTES.md ] && continue + if printf '%s\n' "$attached" | grep -qxF "$name"; then + echo "already attached: $name" + continue + fi + echo "attaching $name" + curl -sSf -X POST -H "$auth" -F "attachment=@$f" \ + "$api/releases/$id/assets?name=$name" >/dev/null +done +echo "release $tag complete: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$tag" diff --git a/tools/release_notes.sh b/tools/release_notes.sh new file mode 100755 index 0000000..551a063 --- /dev/null +++ b/tools/release_notes.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Print the CHANGELOG.md section for one version on stdout. +# +# Usage: tools/release_notes.sh [changelog] +# tools/release_notes.sh 0.7.1 # section between "## 0.7.1 ..." +# # and the next "## " heading +# +# A missing or empty section is an error: the release workflow uses this to +# publish release notes, and every release ships with real, written notes — +# failing here fails the release, which is the point. + +set -eu + +[ $# -ge 1 ] || { echo "usage: $0 [changelog]" >&2; exit 2; } +version=$1 +changelog=${2:-CHANGELOG.md} +[ -r "$changelog" ] || { echo "cannot read $changelog" >&2; exit 2; } + +notes=$(awk -v v="$version" ' + $1 == "##" { grab = ($2 == v); next } + grab { print } +' "$changelog") + +# Trim leading/trailing blank lines so the release body starts with content. +notes=$(printf '%s' "$notes" | sed -e '/./,$!d' | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}') + +[ -n "$notes" ] || { + echo "no CHANGELOG.md section for version $version -- write one before tagging" >&2 + exit 1 +} +printf '%s\n' "$notes"