ci: validate accepted stories with targeted ATDD and gate feature checks
CI / UI Checks (pull_request) Successful in 10s
CI / Rust Checks (pull_request) Failing after 25m35s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Failing after 1s
CI / Deploy (pull_request) Skipped

This commit is contained in:
Hermes DevOps committed 2026-10-25 10:18:09 +00:00
1 parent 9567bbf3aa
commit 1baeefe889
6 files changed
+808 -145

No files matched your search

+133 -90
View File
@@ -2,6 +2,15 @@ name: CI
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
workflow_dispatch:
inputs:
validation_level:
description: Validation depth for this run
type: choice
options: [story, feature]
default: story
required: true
push:
branches:
- main
@@ -9,6 +18,8 @@ on:
env:
CARGO_BUILD_JOBS: "2"
CARGO_INCREMENTAL: "0"
CARGO_PROFILE_DEV_DEBUG: "0"
CARGO_PROFILE_TEST_DEBUG: "0"
RUST_TEST_THREADS: "2"
TESTCONTAINERS_RYUK_DISABLED: "true"
@@ -19,7 +30,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
@@ -56,12 +67,6 @@ jobs:
docker --version
docker info
- name: Install dependency policy tool
run: cargo install cargo-deny --version 0.20.2 --locked
- name: Run tooling unit tests
run: python3 -m unittest discover -s tests/unit
- name: Check typed runtime configuration contract
run: |
cargo run -p crank-config --bin crank-config-contract -- --check
@@ -104,14 +109,10 @@ jobs:
- name: Check Rust code health
run: scripts/check-rust-code-health.sh
- name: Check dependency licenses and advisories
run: cargo deny --locked check advisories bans licenses sources
- name: Check Rust boundaries
run: scripts/check-rust-boundaries.sh
- name: Run offline OpenAPI support corpus gate
run: cargo test -p crank-import --test corpus -- --test-threads=1
- name: Check OpenAPI matrix and corpus compatibility versions
env:
@@ -127,80 +128,15 @@ jobs:
fi
python3 scripts/check-openapi-matrix-compatibility.py --base "$base_ref"
- name: Save OpenAPI corpus evidence
if: always()
uses: https://github.com/ChristopherHX/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: openapi-corpus-evidence
path: crates/crank-import/target/openapi-corpus/evidence-*.json
if-no-files-found: warn
- name: Run clippy
run: cargo clippy --workspace --all-targets --all-features --jobs "$CARGO_BUILD_JOBS" -- -D warnings
# One event per change: a feature branch is gated by its pull request, so the push event runs
# only on `main` (see `on:` above). No cache and no parallel test shards are configured on
# purpose: both need a measured runner/isolation check first (team validation policy), and the
# workspace suites already isolate shared databases per test process.
#
# Story events (`pull_request`) run only the packages the diff touches; the full workspace
# suite stays the feature/release gate and runs on `main`.
- name: Run story tests (affected packages)
if: ${{ gitea.event_name == 'pull_request' }}
run: |
set -eu
base="$(git merge-base HEAD origin/main 2>/dev/null || true)"
if [ -z "$base" ]; then
git fetch --no-tags origin main
base="$(git merge-base HEAD FETCH_HEAD)"
fi
changed="$(git diff --name-only "$base" HEAD)"
packages=""
workspace=""
for path in $changed; do
case "$path" in
Cargo.toml|Cargo.lock|rust-toolchain.toml|justfile|vendor/*|crates/Cargo.toml|apps/Cargo.toml)
workspace="yes"
;;
crates/*/*)
packages="$packages $(printf '%s' "$path" | cut -d/ -f2)"
;;
apps/admin-api/*)
packages="$packages admin-api"
;;
apps/mcp-server/*)
packages="$packages mcp-server"
;;
esac
done
if [ -n "$workspace" ]; then
echo "shared build input changed: running the whole workspace"
cargo test --workspace --all-targets --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
exit 0
fi
selected=""
for package in $(printf '%s\n' $packages | sort -u); do
selected="$selected -p $package"
done
if [ -z "$selected" ]; then
echo "no Rust package changed in this diff; the static checks above are the story gate"
exit 0
fi
echo "story packages:$selected"
cargo test $selected --all-targets --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
- name: Run full workspace tests (feature/release gate)
if: ${{ gitea.event_name != 'pull_request' }}
run: cargo test --workspace --all-targets --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
- name: Run Crank story ATDD
run: scripts/ci-story-checks.sh
ui:
name: UI Checks
runs-on: ubuntu-latest
needs: rust
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Verify runner toolchain
run: |
@@ -208,6 +144,7 @@ jobs:
npm --version
docker --version
- name: Install UI dependencies
working-directory: apps/ui
run: npm ci
@@ -220,10 +157,76 @@ jobs:
working-directory: apps/ui
run: npm run build
rust-feature:
needs: rust
name: Rust Feature Validation
if: >-
inputs.validation_level == 'feature' ||
contains(gitea.event.pull_request.labels.*.name, 'feature-ready')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Install Rust toolchain
run: |
set -eu
toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n1)"
if [ -z "$toolchain" ]; then
echo "Unable to read Rust toolchain channel from rust-toolchain.toml" >&2
exit 1
fi
rustup toolchain install "$toolchain" --profile minimal --component clippy --component rustfmt
rustup default "$toolchain"
host="$(rustc -vV | sed -n 's/^host: //p')"
toolchain_dir="${RUSTUP_HOME:-$HOME/.rustup}/toolchains/${toolchain}-${host}"
toolchain_bin="$toolchain_dir/bin"
if [ ! -x "$toolchain_bin/rustc" ] || [ ! -x "$toolchain_bin/cargo" ]; then
echo "Rust $toolchain was not installed at $toolchain_dir." >&2
exit 1
fi
printf '%s\n' "$toolchain_bin" >> "$GITHUB_PATH"
"$toolchain_bin/rustc" --version
"$toolchain_bin/cargo" --version
"$toolchain_bin/rustfmt" --version
"$toolchain_bin/cargo-clippy" --version
- name: Verify runner toolchain
run: |
python3 --version
rustc --version
cargo --version
rustfmt --version
cargo clippy --version
docker --version
docker info
- name: Install dependency policy tool
run: cargo install cargo-deny --version 0.20.2 --locked
- name: Run tooling unit tests
run: python3 -m unittest discover -s tests/unit
- name: Check dependency licenses and advisories
run: cargo deny --locked check advisories bans licenses sources
- name: Run offline OpenAPI support corpus gate
run: cargo test -p crank-import --test corpus -- --test-threads=1
- name: Save OpenAPI corpus evidence
if: always()
uses: https://github.com/ChristopherHX/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: openapi-corpus-evidence
path: crates/crank-import/target/openapi-corpus/evidence-*.json
if-no-files-found: warn
- name: Run clippy
run: cargo clippy --workspace --all-targets --all-features --jobs "$CARGO_BUILD_JOBS" -- -D warnings
- name: Run tests
run: cargo test --workspace --all-targets --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
frontend-e2e:
needs: [rust, ui]
if: >-
inputs.validation_level == 'feature' ||
contains(gitea.event.pull_request.labels.*.name, 'feature-ready')
name: Frontend E2E
runs-on: ubuntu-latest
needs: ui
services:
crank-e2e-postgres:
image: postgres:16-alpine
@@ -246,7 +249,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Install Rust toolchain
run: |
@@ -324,15 +327,16 @@ jobs:
find .tmp/ui-e2e/logs -maxdepth 1 -type f -print -exec sed -n '1,220p' {} \; || true
deployment:
needs: [rust, ui]
if: >-
inputs.validation_level == 'feature' ||
contains(gitea.event.pull_request.labels.*.name, 'feature-ready')
name: Community Image Smoke
runs-on: ubuntu-latest
needs:
- rust
- ui
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Validate Community deployment manifests
run: |
@@ -447,14 +451,53 @@ jobs:
docker compose -f deploy/community/docker-compose.images.yml \
--env-file .tmp/community-smoke.env --profile local-db down -v --remove-orphans || true
required-checks:
name: Required Checks
runs-on: ubuntu-latest
if: always()
needs:
- rust
- ui
- deployment
- rust-feature
- frontend-e2e
steps:
- name: Require story gates and mode-appropriate feature gates
env:
FEATURE_VALIDATION: ${{ inputs.validation_level == 'feature' || contains(gitea.event.pull_request.labels.*.name, 'feature-ready') }}
RUST_RESULT: ${{ needs.rust.result }}
UI_RESULT: ${{ needs.ui.result }}
RUST_FEATURE_RESULT: ${{ needs.rust-feature.result }}
E2E_RESULT: ${{ needs.frontend-e2e.result }}
IMAGE_RESULT: ${{ needs.deployment.result }}
run: |
set -eu
if [ "$RUST_RESULT" != "success" ] || \
[ "$UI_RESULT" != "success" ]; then
echo "A required story gate did not succeed." >&2
exit 1
fi
if [ "$FEATURE_VALIDATION" = "true" ]; then
if [ "$RUST_FEATURE_RESULT" != "success" ] || \
[ "$E2E_RESULT" != "success" ] || \
[ "$IMAGE_RESULT" != "success" ]; then
echo "A required feature gate did not succeed." >&2
exit 1
fi
else
if [ "$RUST_FEATURE_RESULT" != "skipped" ] || \
[ "$E2E_RESULT" != "skipped" ] || \
[ "$IMAGE_RESULT" != "skipped" ]; then
echo "A feature-only gate did not skip in story mode." >&2
exit 1
fi
fi
deploy:
name: Deploy
runs-on: ubuntu-latest
needs:
- rust
- ui
- frontend-e2e
- deployment
- required-checks
if: ${{ gitea.event_name == 'push' && gitea.ref == 'refs/heads/main' }}
env:
REGISTRY: git.itexp.me
@@ -466,7 +509,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Verify runner toolchain
run: |
+60 -55
View File
@@ -5,6 +5,13 @@ on:
tags:
- "v*"
workflow_dispatch:
inputs:
validation_level:
description: Validation depth for this run
type: choice
options: [story, feature]
default: story
required: true
env:
REGISTRY: git.itexp.me
@@ -17,10 +24,17 @@ env:
jobs:
release:
runs-on: ubuntu-latest
permissions:
code: read
releases: write
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Clear optional release evidence
run: rm -f .tmp/openapi-playwright.json .tmp/openapi-ui-evidence.json
- name: Use preinstalled Rust toolchain
run: |
@@ -53,7 +67,14 @@ jobs:
- name: Install dependency policy tool
run: cargo install cargo-deny --version 0.20.2 --locked
- name: Check formatting
run: cargo fmt --all --check
- name: Audit Rust dependencies
run: cargo deny --locked check advisories bans licenses sources
- name: Run tooling unit tests
if: inputs.validation_level == 'feature'
run: python3 -m unittest discover -s tests/unit
- name: Check typed runtime configuration contract
@@ -93,16 +114,19 @@ jobs:
- name: Check Community scope
run: scripts/check-community-scope.sh
- name: Run Crank story ATDD
run: scripts/ci-story-checks.sh
- name: Run release quality gates
if: inputs.validation_level == 'feature'
run: |
cargo fmt --all --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo test --workspace --all-targets -- --test-threads=1
cargo deny --locked check advisories bans licenses sources
- name: Build release binaries
run: cargo build --release -p admin-api -p mcp-server
- name: Install UI dependencies
working-directory: apps/ui
run: npm ci
@@ -116,10 +140,12 @@ jobs:
run: npm run build
- name: Install Playwright browser
if: inputs.validation_level == 'feature'
working-directory: apps/ui
run: npx playwright install --with-deps chromium
- name: Run release end-to-end tests
if: inputs.validation_level == 'feature'
working-directory: apps/ui
run: |
mkdir -p ../../.tmp
@@ -127,6 +153,7 @@ jobs:
PLAYWRIGHT_JSON_OUTPUT=../../.tmp/openapi-playwright.json npm run e2e
- name: Collect sanitized OpenAPI UI release evidence
if: inputs.validation_level == 'feature'
working-directory: apps/ui
run: |
trap 'rm -f ../../.tmp/openapi-playwright.json' EXIT
@@ -155,22 +182,26 @@ jobs:
- name: Package release artifacts
run: |
set -euo pipefail
mkdir -p dist/release
source_revision="$(git rev-parse HEAD)"
evidence_artifact="dist/crank-openapi-ui-evidence-${IMAGE_TAG}-${source_revision}.json"
cp target/release/admin-api dist/release/admin-api
cp target/release/crank-migrate dist/release/crank-migrate
cp target/release/mcp-server dist/release/mcp-server
cp .tmp/openapi-ui-evidence.json "$evidence_artifact"
tar -C dist/release -czf dist/crank-community-admin-api-${IMAGE_TAG}.tar.gz admin-api crank-migrate
tar -C dist/release -czf dist/crank-community-mcp-server-${IMAGE_TAG}.tar.gz mcp-server
tar -C apps/ui/dist -czf dist/crank-community-ui-${IMAGE_TAG}.tar.gz .
sha256sum \
dist/crank-community-admin-api-${IMAGE_TAG}.tar.gz \
dist/crank-community-mcp-server-${IMAGE_TAG}.tar.gz \
dist/crank-community-ui-${IMAGE_TAG}.tar.gz \
"$evidence_artifact" \
> dist/crank-community-${IMAGE_TAG}-checksums.txt
files=(
"dist/crank-community-admin-api-${IMAGE_TAG}.tar.gz"
"dist/crank-community-mcp-server-${IMAGE_TAG}.tar.gz"
"dist/crank-community-ui-${IMAGE_TAG}.tar.gz"
)
if [ -f .tmp/openapi-ui-evidence.json ]; then
cp .tmp/openapi-ui-evidence.json "$evidence_artifact"
files+=("$evidence_artifact")
fi
sha256sum "${files[@]}" > "dist/crank-community-${IMAGE_TAG}-checksums.txt"
- name: Generate SBOM
run: |
@@ -178,54 +209,28 @@ jobs:
dir:/workspace -o spdx-json \
> dist/crank-community-${IMAGE_TAG}-sbom.spdx.json
- name: Write release notes
run: |
set -eu
tag="${{ gitea.ref_name }}"
{
echo "## Crank Community ${tag}"
echo
echo "Source commit: \`$(git rev-parse HEAD)\`"
echo
echo "### Changes"
echo
git log --oneline -25 | sed 's/^/- /'
echo
echo "### Artifacts and checksums"
echo
echo '```'
cat "dist/crank-community-${tag}-checksums.txt"
echo '```'
} > dist/RELEASE-NOTES.md
cat dist/RELEASE-NOTES.md
# The archives, the checksums and the SBOM only exist inside the runner workspace until they are
# attached to the release entry: publish them so a released version keeps its artifacts, and do
# it before the registry steps so an image-credential problem cannot lose them.
- name: Publish artifacts to the Gitea release
- name: Publish release bundles, checksums, evidence, and SBOM to Gitea
if: startsWith(gitea.ref, 'refs/tags/v')
env:
RELEASE_TOKEN: ${{ secrets.GITEA_TOKEN }}
FALLBACK_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITEA_SERVER_URL: ${{ gitea.server_url }}
GITEA_REPOSITORY: ${{ gitea.repository }}
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
RELEASE_TAG: ${{ gitea.ref_name }}
SOURCE_REVISION: ${{ gitea.sha }}
run: |
set -eu
tag="${{ gitea.ref_name }}"
token="${RELEASE_TOKEN:-${FALLBACK_TOKEN:-}}"
if [ -z "$token" ]; then
echo "No Gitea token is available to the workflow: the release artifacts stay in the runner workspace" >&2
exit 1
set -euo pipefail
assets=(
"dist/crank-community-admin-api-${RELEASE_TAG}.tar.gz"
"dist/crank-community-mcp-server-${RELEASE_TAG}.tar.gz"
"dist/crank-community-ui-${RELEASE_TAG}.tar.gz"
"dist/crank-community-${RELEASE_TAG}-checksums.txt"
"dist/crank-community-${RELEASE_TAG}-sbom.spdx.json"
)
evidence="dist/crank-openapi-ui-evidence-${RELEASE_TAG}-${SOURCE_REVISION}.json"
if [ -f "$evidence" ]; then
assets+=("$evidence")
fi
prerelease=""
case "$tag" in
*-*) prerelease="--prerelease" ;;
esac
GITEA_TOKEN="$token" python3 scripts/publish-gitea-release.py \
--api "${{ gitea.server_url }}/api/v1" \
--repo "${{ gitea.repository }}" \
--tag "$tag" \
--title "Crank Community ${tag}" \
--notes-file dist/RELEASE-NOTES.md \
--dist dist \
$prerelease
python3 scripts/ci-release-assets.py "${assets[@]}"
- name: Load deployment secrets from OpenBao
env: