commit 364a0c810162475d8fa27aac126e3d17589c6e3e
parent 1808331741b8b964db4ff99edd5f7fd75df336ed
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Fri, 11 Sep 2026 22:16:43 +0530
parent 1808331741b8b964db4ff99edd5f7fd75df336ed
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Fri, 11 Sep 2026 22:16:43 +0530
Use capital handoff and Jobfile variables
2 files changed, 103 insertions(+), 52 deletions(-)
M
|
153
+++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
diff --git a/CONTEXT.md b/CONTEXT.md @@ -26,7 +26,7 @@ **minci-handoff**: The planned provider-neutral runner that accepts a generic handoff event, executes a Jobfile, publishes artifacts, and reports to minci. -**Jobfile**: A POSIX shell, APKBUILD-like file containing CI metadata variables and job functions. The first implementation is server-level; later repos can provide `.config/minci/Jobfile` on an `integ` branch. +**Jobfile**: A POSIX shell, APKBUILD-like file containing CI metadata variables and job functions. Its public variables are capitalized (`PROJECT`, `TARGETS`, `TRIGGER_MAP`, etc.). The first implementation is server-level; later repos can provide `.config/minci/Jobfile` on an `integ` branch. **Native target**: The target returned by `guess_triplet` for the current build host. The initial deployed CI run builds this target.
diff --git a/docs/minci-handoff.md b/docs/minci-handoff.md @@ -11,7 +11,7 @@ Current foundationpkgs-specific pieces should move like this: | `scripts/fpkgs-ci.sh` | standalone `minci-handoff` executable | Current script knows APKBUILD buckets and foundationpkgs artifact layout. | | `FPKGS_*` env vars | server config + generic handoff event vars | The event format should be reusable across gitolite, webhooks, and manual runs. | | Built-in `list_apkbuilds()` planner | `Jobfile` job function | The repo/server Jobfile decides what to build. | -| Built-in artifact path policy | `artifact_path` + `artifact_dir`/`artifact_url` vars | Keeps publishing generic. | +| Built-in artifact path policy | `ARTIFACT_PATH`, `ARTIFACT_DIR`, and `ARTIFACT_URL` | Keeps publishing generic. | | Built-in minci report per APKBUILD | minci reporter around each declared job | minci remains the reporting protocol, not the build planner. | | `scripts/build.sh` / `functions.sh` | job implementation for APKBUILD projects | These stay useful, but should not live in the runner core. | | `scripts/pacstall-install.sh` | optional job helper | Runtime APKBUILD → pacscript conversion stays project/tool-specific. | @@ -37,17 +37,17 @@ For now, use only the common fallback. ## Handoff event format -Adapters produce lowercase shell variables: +Adapters produce capital shell variables, deliberately generic and without a `MINCI_` prefix: ```sh -event=git-push -repo_name=nply/foundationpkgs -repo_url=ssh://git@nply.org/nply/foundationpkgs.git -repo_path=/home/git/repositories/nply/foundationpkgs.git -ref=refs/heads/main -old_rev=0000000000000000000000000000000000000000 -new_rev=... -actor=gitolite +EVENT=git-push +REPO_NAME=nply/foundationpkgs +REPO_URL=ssh://git@nply.org/nply/foundationpkgs.git +REPO_PATH=/home/git/repositories/nply/foundationpkgs.git +REF=refs/heads/main +OLD_REV=0000000000000000000000000000000000000000 +NEW_REV=... +ACTOR=gitolite ``` A gitolite adapter is just a translator from `post-receive` stdin into this event format. GitHub/GitLab/webhook adapters can produce the same format later. @@ -56,70 +56,129 @@ A gitolite adapter is just a translator from `post-receive` stdin into this even A Jobfile is POSIX shell, APKBUILD-like: variables plus functions. -Required/expected variables: +Expected variables: ```sh -project=foundationpkgs -triggers="refs/heads/main" -targets="native" -jobs="packages" -artifact_path="foundationpkgs" +PROJECT=foundationpkgs +TARGETS="native" +JOBS="packages smoke" +ARTIFACT_PATH="foundationpkgs" + +# Branch/ref routing. Left side is a shell case pattern matched against REF; +# right side is the jobs to run for that ref. +TRIGGER_MAP='refs/heads/main: packages +refs/heads/release/*: packages smoke +refs/heads/integ: selftest' ``` +`TRIGGER_MAP` replaces a flat trigger list when branch-specific jobs are needed. The runner picks the first matching line unless the Jobfile sets: + +```sh +TRIGGER_MODE=all +``` + +With `TRIGGER_MODE=all`, every matching line contributes jobs. + Runner-provided variables while executing a job: ```sh -code_dir=/var/tmp/minci-handoff/checkouts/<rev>/code -config_dir=/etc/minci-handoff -work_dir=/var/tmp/minci-handoff/build/<job-key> -artifact_dir=/var/tmp/minci-handoff/build/<job-key>/artifacts -artifact_url=https://nply.org/dl/<artifact_path>/<target>/<job-key>/ -target=x86_64-unknown-linux-gnu -ref=refs/heads/main -old_rev=... -new_rev=... -repo_name=nply/foundationpkgs -repo_url=... -repo_path=... -actor=... +CODE_DIR=/var/tmp/minci-handoff/checkouts/<rev>/code +CONFIG_DIR=/etc/minci-handoff +WORK_DIR=/var/tmp/minci-handoff/build/<job-key> +ARTIFACT_DIR=/var/tmp/minci-handoff/build/<job-key>/artifacts +ARTIFACT_URL=https://nply.org/dl/<ARTIFACT_PATH>/<TARGET>/<job-key>/ +TARGET=x86_64-unknown-linux-gnu +REF=refs/heads/main +OLD_REV=... +NEW_REV=... +REPO_NAME=nply/foundationpkgs +REPO_URL=... +REPO_PATH=... +ACTOR=... ``` Function contract: ```sh prepare() { :; } # optional, once per run -<job>() { ...; } # required for each name in jobs -<job>_artifacts() { # optional; default is find "$artifact_dir" -type f - find "$artifact_dir" -type f +<job>() { ...; } # required for each name in selected jobs +<job>_artifacts() { # optional; default is find "$ARTIFACT_DIR" -type f + find "$ARTIFACT_DIR" -type f +} +<job>_inputs() { # optional; contributes to the job key + find . -type f | sort } cleanup() { :; } # optional ``` +## Trigger map parsing + +The runner should parse `TRIGGER_MAP` as newline-separated routing rules: + +```txt +<ref-pattern>: <job> [<job>...] +``` + +Example: + +```sh +TRIGGER_MAP='refs/heads/main: packages +refs/heads/docs/*: docs +refs/tags/v*: release packages' +``` + +Selection algorithm: + +```sh +selected_jobs() { + printf '%s\n' "$TRIGGER_MAP" | while IFS= read -r line; do + pattern=${line%%:*} + jobs=${line#*:} + case "$REF" in + $pattern) + printf '%s\n' $jobs + [ "${TRIGGER_MODE:-first}" = all ] || break + ;; + esac + done +} +``` + +A flat default remains possible: + +```sh +JOBS="build test" +TRIGGER_MAP='refs/heads/main: build test' +``` + ## Common server Jobfile for foundationpkgs This is the first target Jobfile to install at `/etc/minci-handoff/Jobfile`: ```sh # POSIX sh -project=foundationpkgs -triggers="refs/heads/main" -targets="native" -jobs="packages" -artifact_path="foundationpkgs" +PROJECT=foundationpkgs +TARGETS="native" +ARTIFACT_PATH="foundationpkgs" +TRIGGER_MAP='refs/heads/main: packages' packages() { - cd "$code_dir" + cd "$CODE_DIR" find Linux Unix noarch any -name APKBUILD -type f | sort | while IFS= read -r apk; do pkg=$(awk -F= '$1 == "pkgname" { v = $2; gsub(/^"|"$/, "", v); print v; exit }' "$apk") [ -n "$pkg" ] || pkg=$(dirname "$apk" | sed 's#.*/##') - out="$artifact_dir/$pkg" + out="$ARTIFACT_DIR/$pkg" mkdir -p "$out" - scripts/build.sh -o "$out" -t "$target" "$apk" + scripts/build.sh -o "$out" -t "$TARGET" "$apk" done } packages_artifacts() { - find "$artifact_dir" -type f + find "$ARTIFACT_DIR" -type f +} + +packages_inputs() { + find Linux Unix noarch any scripts -type f | sort } ``` @@ -127,19 +186,11 @@ packages_artifacts() { `minci-handoff` should compute a job key from: -- event data: `repo_name`, `ref`, `new_rev`, `target` +- event data: `REPO_NAME`, `REF`, `NEW_REV`, `TARGET` - selected Jobfile content - job name -- files declared by the Jobfile, if it provides `inputs_<job>()` +- files declared by the Jobfile, if it provides `<job>_inputs()` - build environment: `MAKEFLAGS`, `CFLAGS`, `CPPFLAGS`, `LDFLAGS`, `PKG_CONFIG_PATH`, `CC` - tool versions visible to the runner -For foundationpkgs, the server Jobfile can later add: - -```sh -packages_inputs() { - find Linux Unix noarch any scripts -type f | sort -} -``` - That keeps rebuild criteria in config instead of runner internals.
: nply/foundationpkgs