Set up Forgejo CI/CD policy
ober
a40ea41a95afecdd961e11fef3f32f1e019cc6e0
new file mode 100755 --- /dev/null +++ b/.forgejo/ci-required.sh @@ -0,0 +1,68 @@ +#!/bin/sh +set -eu + +has_target() { + target=$1 + [ -f Makefile ] && grep -Eq "^${target}[[:space:]]*:" Makefile +} + +if has_target verify; then + make verify +else + ran=0 + for target in security test check build; do + if has_target "$target"; then + make "$target" + ran=1 + fi + done + [ "$ran" = 1 ] || { + echo "ERROR: no verify, test, check, or build target is available" >&2 + exit 1 + } +fi + +if ! has_target binary; then + echo "No standalone binary target; full repository verification passed." + exit 0 +fi + +make binary + +if has_target binary-smoke; then + make binary-smoke + exit 0 +fi +if has_target smoke; then + make smoke + exit 0 +fi + +binary_list=$(mktemp) +trap 'rm -f "$binary_list"' EXIT HUP INT TERM +find . -maxdepth 2 -type f -perm -111 \ + ! -path './.git/*' ! -path './.jerboa/*' ! -path './vendor/*' \ + ! -path './test/*' ! -path './tests/*' \ + -exec file {} \; | + awk -F: '/(ELF .*executable|Mach-O .*executable)/ { print $1 }' > "$binary_list" + +[ -s "$binary_list" ] || { + echo "ERROR: make binary succeeded but produced no runnable ELF executable" >&2 + exit 1 +} + +while IFS= read -r binary; do + echo "Smoke-checking $binary" + if timeout 30 env QT_QPA_PLATFORM=offscreen \ + QTWEBENGINE_CHROMIUM_FLAGS=--disable-gpu "$binary" --version >/dev/null 2>&1; then + continue + fi + if timeout 30 env QT_QPA_PLATFORM=offscreen \ + QTWEBENGINE_CHROMIUM_FLAGS=--disable-gpu "$binary" --help >/dev/null 2>&1; then + continue + fi + echo "ERROR: $binary failed both --version and --help runtime smoke checks" >&2 + exit 1 +done < "$binary_list" + +echo "Full verification, binary build, and runtime smoke checks passed." new file mode 100755 --- /dev/null +++ b/.forgejo/require-version-bump.sh @@ -0,0 +1,50 @@ +#!/bin/sh +set -eu + +version_file=${VERSION_FILE:-VERSION} +test -f "$version_file" || { + echo "ERROR: $version_file is required" >&2 + exit 1 +} + +new_version=$(tr -d '[:space:]' < "$version_file") +printf '%s\n' "$new_version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || { + echo "ERROR: VERSION must be semantic MAJOR.MINOR.PATCH, got: $new_version" >&2 + exit 1 +} + +if [ -f jpkg.sexp ]; then + manifest_version=$(awk -F'"' '/\(version "/ { print $2; exit }' jpkg.sexp) + [ "$manifest_version" = "$new_version" ] || { + echo "ERROR: jpkg.sexp version $manifest_version must match VERSION $new_version" >&2 + exit 1 + } +fi + +if [ "${FORGEJO_EVENT_NAME:-}" != pull_request ]; then + echo "VERSION $new_version is valid" + exit 0 +fi + +base_ref=${FORGEJO_BASE_REF:?FORGEJO_BASE_REF is required for pull requests} +old_version=$(git show "origin/$base_ref:$version_file" 2>/dev/null | tr -d '[:space:]' || true) +old_version=${old_version:-0.0.0} +printf '%s\n' "$old_version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || { + echo "ERROR: target branch VERSION is malformed: $old_version" >&2 + exit 1 +} + +if ! awk -F. -v old="$old_version" -v new="$new_version" 'BEGIN { + split(old, o, ".") + split(new, n, ".") + for (i = 1; i <= 3; i++) { + if ((n[i] + 0) > (o[i] + 0)) exit 0 + if ((n[i] + 0) < (o[i] + 0)) exit 1 + } + exit 1 +}'; then + echo "ERROR: VERSION must advance beyond $old_version; got $new_version" >&2 + exit 1 +fi + +echo "VERSION advances: $old_version -> $new_version" new file mode 100644 --- /dev/null +++ b/.forgejo/workflows/ci.yaml @@ -0,0 +1,67 @@ +name: required-ci + +on: + pull_request: + branches: [main] + push: + branches: [main] + tags: ['v*'] + workflow_dispatch: + +jobs: + required: + runs-on: docker + container: + image: debian:stable + steps: + - name: Install system dependencies + run: | + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + bash build-essential ca-certificates curl file git liblz4-dev \ + libncurses-dev libssl-dev libx11-dev make pkg-config tar zlib1g-dev + - name: Check out jerboa-jmap + uses: https://code.forgejo.org/actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + persist-credentials: false + - name: Install Rust + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | + sh -s -- -y --profile minimal --default-toolchain 1.94.1 + echo "$HOME/.cargo/bin" >> "$FORGEJO_PATH" + - name: Fetch and build Jerboa + run: | + mkdir ../jerboa + git -C ../jerboa init + git -C ../jerboa remote add origin https://git.jerboa.sh/ober/jerboa.git + git -C ../jerboa fetch --depth 1 origin 6a5230800b3599147f04bd5b1493bc996047506a + git -C ../jerboa checkout --detach FETCH_HEAD + test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 6eb4710558222c4e2ef9b076491f7db5af5e3748 + . "$HOME/.cargo/env" + CARGO_BUILD_JOBS=1 make -C ../jerboa jerboa \ + CHEZ_CONFIGURE_EXTRA=--disable-x11 JERBOA_NATIVE_FEATURES=tls \ + JERBOA_CC_OPT=-O0 + - name: Build, test, and smoke-check + run: | + . "$HOME/.cargo/env" + PATH="$PWD/../jerboa/dist:$PATH" \ + JERBUILD="$PWD/../jerboa/dist/jerbuild" \ + sh .forgejo/ci-required.sh + - name: Verify and pack package + run: | + version=$(cat VERSION) + J="$PWD/../jerboa/dist/jerboa" + mkdir -p "$HOME/.cache" + chmod -R go-w "$HOME/.cache" + "$J" pkg verify + "$J" pkg policy + "$J" pkg build + "$J" pkg pack --output "$PWD/jerboa-jmap-$version.jpkg" + "$J" pkg verify "$PWD/jerboa-jmap-$version.jpkg" + "$J" pkg verify --reproduce + - name: Upload package + uses: https://code.forgejo.org/actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3 + with: + name: jerboa-jmap-package + path: jerboa-jmap-*.jpkg + if-no-files-found: error new file mode 100644 --- /dev/null +++ b/.forgejo/workflows/version-policy.yaml @@ -0,0 +1,23 @@ +name: version-policy + +on: + pull_request: + branches: [main] + +jobs: + required: + runs-on: docker + container: + image: debian:stable + steps: + - name: Install Git + run: | + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git ca-certificates + - name: Check out full history + uses: https://code.forgejo.org/actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + fetch-depth: 0 + persist-credentials: false + - name: Require semantic version advancement + run: sh .forgejo/require-version-bump.sh new file mode 100644 --- /dev/null +++ b/.gitsafeignore @@ -0,0 +1,5 @@ +.forgejo/workflows/ci.yaml:high-entropy-hex:24 +.forgejo/workflows/ci.yaml:high-entropy-hex:37 +.forgejo/workflows/ci.yaml:high-entropy-hex:39 +.forgejo/workflows/ci.yaml:high-entropy-hex:63 +.forgejo/workflows/version-policy.yaml:high-entropy-hex:18 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,3 +1,21 @@ +## STOP: Forgejo Pull Requests Are Mandatory + +Every change to this repository must use the Forgejo pull-request workflow. + +1. Start from the current remote default branch and create a dedicated feature, fix, or chore branch **before editing**. +2. Make only the scoped changes on that branch. +3. Run every repository-required test and build. If the repository produces binaries, build them and run a meaningful smoke check (such as the documented startup, `--help`, or `--version`). Do not commit while any required check fails. +4. Commit the verified changes on the feature branch and push that branch to `origin`. +5. Open a pull request on `git.jerboa.sh` targeting the default branch. A human must review, approve, and merge it. + +Absolute bans: never commit or push directly to `main` or `master`; never self-approve or self-merge; never bypass branch protection; and never leave completed changes only in a local branch. Release work and urgent fixes follow the same branch-and-PR process. + +### Every PR Must Advance the Version + +`VERSION` is the authoritative repository version. Every pull request must change it to a strictly greater semantic version (`MAJOR.MINOR.PATCH`). Use a patch increment for fixes and maintenance, a minor increment for backward-compatible features, and a major increment for breaking changes. Keep package manifests, generated version constants, release artifact names, and user-visible version output synchronized with `VERSION`. + +Forgejo CI compares the proposed `VERSION` with the target branch and rejects an unchanged, malformed, or lower version. + ## STOP: Editing `.ss`/`.sls` Files — Mandatory Rules These rules exist because local-model sessions have lost **hours** fighting @@ -386,18 +404,17 @@ through the git.jerboa.sh release mechanism for the tagged release; do not reintroduce SourceHut (`hut`, `git.sr.ht`) or GitHub release paths. Common sibling repos that exist but must NOT be touched without explicit instruction: -- `~/mine/jerboa-mcp` — Legacy node MCP, superseded. The active MCP server now lives in THIS repo at `mcp/` + `data/`. Don't modify the legacy repo unless told. -- `~/mine/jerboa-shell` — Only modify when user explicitly says to work there. -- `~/mine/gerbil-mcp` — **NEVER touch**. Deprecated. -- `~/mine/gerbil-orig` — Read-only reference for upstream Gerbil. Never modify. +- the legacy Jerboa MCP sibling checkout — Legacy node MCP, superseded. The active MCP server now lives in THIS repo at `mcp/` + `data/`. Don't modify the legacy repo unless told. +- the Jerboa shell sibling checkout — Only modify when user explicitly says to work there. +- the deprecated Gerbil MCP sibling checkout — **NEVER touch**. Deprecated. +- the upstream Gerbil reference checkout — Read-only reference for upstream Gerbil. Never modify. If a user instruction mentions a file path, use EXACTLY that path. Do not substitute a similar-looking path from another repo. ### Never Reference Sibling Checkouts in Build Files Build files (Makefile, shell scripts, CI config) must **never** resolve a -dependency via a relative sibling path (`../jerboa-foo`) or an absolute -`~/mine/jerboa-foo` path. That layout is specific to this one machine — +dependency via a relative sibling path (`..`-relative) or an absolute machine-specific sibling path. That layout is specific to this one machine — other users and CI do not have it. Always vendor instead: fetch/clone the dependency into `vendor/` (or this repo's equivalent) at build time, or use a pinned-release fetch script, so the build is reproducible without @@ -407,7 +424,7 @@ A sibling-path fallback is not just a portability bug: it can silently substitute a full alternate source tree (build config, embedded data, secrets) for the vendored one, with no equivalent safety default, changing what actually gets built without any indication. If you find one -(`grep -rn '\.\./jerboa\|~/mine/jerboa'` over Makefiles/scripts), remove it +(for example, any sibling-checkout reference in Makefiles or scripts), remove it and vendor properly instead. --- new file mode 100644 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.1 --- a/continue +++ b/continue @@ -898,7 +898,7 @@ Let me read the key READMEs and AGENTS.mds now. I'll read several in parallel. 101: 102: ## Build & test 103: -104: Requires [`jerbuild`](https://git.sr.ht/~lisp) on `PATH`. The differential lane +104: Requires [`jerbuild`](https://git.jerboa.sh/ober) on `PATH`. The differential lane 105: additionally requires the `../jerboa-sqlite-ffi` reference checkout (a C compiler + 106: system `libsqlite3`); it is skipped if that checkout is absent. 107: @@ -2567,7 +2567,7 @@ Found 9 matches Line 378: `hut git -r ~lisp/jerboa artifact upload <file> --rev <tag>` (normally through - Line 380: `https://git.sr.ht/~lisp/jerboa/refs/download/<tag>/<artifact>`. + Line 380: `https://git.jerboa.sh/ober/jerboa/releases/download/<tag>/<artifact>`. Line 382: Do not add a GitHub mirror or fallback when SourceHut delivery needs work; @@ -2618,7 +2618,7 @@ Found 9 matches 377: files on a versioned SourceHut git tag. Publish them with 378: `hut git -r ~lisp/jerboa artifact upload <file> --rev <tag>` (normally through 379: `make release-upload`) and download them from -380: `https://git.sr.ht/~lisp/jerboa/refs/download/<tag>/<artifact>`. +380: `https://git.jerboa.sh/ober/jerboa/releases/download/<tag>/<artifact>`. 381: 382: Do not add a GitHub mirror or fallback when SourceHut delivery needs work; 383: repair or configure the SourceHut release path instead. See the SourceHut @@ -2653,7 +2653,7 @@ This AGENTS.md appears to be copied from the jerboa repo (it references "THIS re { "filePath": "/Users/user/mine/jerboa-jmap/AGENTS.md", "newString": "### Git Hosting & Release Distribution: git.jerboa.sh Only\n\n**Never use SourceHut or GitHub** — not for remotes, not for release\nartifacts, not for dependency fetches, not as a fallback. All jerboa repos\nare hosted on `git.jerboa.sh` with remotes of the form:\n\n```\nssh://git@git.jerboa.sh:2222/ober/<repo>.git\n```\n\nPin dependencies to exact commits from that host (via `jpkg.sexp`/`jpkg.lock`\nor a `support/fetch-deps.sh` vendor script). Release artifacts are published\nthrough the git.jerboa.sh release mechanism for the tagged release; do not\nreintroduce SourceHut (`hut`, `git.sr.ht`) or GitHub release paths.", - "oldString": "### Release Distribution: SourceHut Only\n\n**Never use GitHub Releases, GitHub release URLs, or GitHub as a fallback for\nJerboa release artifacts.** Jerboa's sole official release channel is attached\nfiles on a versioned SourceHut git tag. Publish them with\n`hut git -r ~lisp/jerboa artifact upload <file> --rev <tag>` (normally through\n`make release-upload`) and download them from\n`https://git.sr.ht/~lisp/jerboa/refs/download/<tag>/<artifact>`.\n\nDo not add a GitHub mirror or fallback when SourceHut delivery needs work;\nrepair or configure the SourceHut release path instead. See the SourceHut\nmanual: <https://man.sr.ht/git.sr.ht/#attaching-files-to-releases>." + "oldString": "### Release Distribution: SourceHut Only\n\n**Never use GitHub Releases, GitHub release URLs, or GitHub as a fallback for\nJerboa release artifacts.** Jerboa's sole official release channel is attached\nfiles on a versioned SourceHut git tag. Publish them with\n`hut git -r ~lisp/jerboa artifact upload <file> --rev <tag>` (normally through\n`make release-upload`) and download them from\n`https://git.jerboa.sh/ober/jerboa/releases/download/<tag>/<artifact>`.\n\nDo not add a GitHub mirror or fallback when SourceHut delivery needs work;\nrepair or configure the SourceHut release path instead. See the SourceHut\nmanual: <https://man.sr.ht/git.sr.ht/#attaching-files-to-releases>." } ``` @@ -4573,7 +4573,7 @@ Let me reference the sibling repos for build patterns. 3: (version "0.1.0") 4: (description "SMTP server and client for Jerboa") 5: (license "MIT") -6: (source "https://git.sr.ht/~lisp/jerboa-smtp") +6: (source "https://git.jerboa.sh/ober/jerboa-smtp") 7: (jerboa ">=0.2.0") 8: (modules ((root "."))) 9: (dependencies ()) @@ -4741,7 +4741,7 @@ Let me check: 3: (version "0.1.0") 4: (description "SQLite implementation for Jerboa") 5: (license "MIT") -6: (source "https://git.sr.ht/~lisp/jerboa-sqlite") +6: (source "https://git.jerboa.sh/ober/jerboa-sqlite") 7: (jerboa ">=0.2.0") 8: (modules ((root "."))) 9: (dependencies ()) @@ -7502,4 +7502,3 @@ Phase 0 acceptance gate passed — `make build` produces a working binary. Let m ## Assistant (Build · DeepSeek Pro mac2 · 221.2s) --- - --- a/jpkg.sexp +++ b/jpkg.sexp @@ -1,6 +1,6 @@ (package (name "@ober/jerboa-jmap") - (version "0.1.0") + (version "0.1.1") (description "Zero-knowledge JMAP email-fetch server") (license "Apache-2.0") (source "https://git.jerboa.sh/ober/jerboa-jmap")