diff --git a/.gitignore b/.gitignore
index a15d461..590f7bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,8 +22,9 @@ target/
# Local implementation journal (intentionally not committed)
/recap.md
-# Generated locally by rust_autobadges/Cargo Tarpaulin
+# Generated locally or in CI by Cargo Tarpaulin and the badge scripts
/tarpaulin-report.html
+/coverage/
# Legacy cargo-cyclonedx intermediates may remain in reused CI workspaces.
**/sbom.cdx.json
diff --git a/.run_status.toml b/.run_status.toml
deleted file mode 100644
index 2609c4b..0000000
--- a/.run_status.toml
+++ /dev/null
@@ -1,17 +0,0 @@
-[last_run_clean]
-run_status = "Success"
-lines_parsed = 440
-coverage = 92.72
-
-[last_run_clean.run_duration]
-secs = 62
-nanos = 238260804
-
-[last_run_incremental]
-run_status = "Success"
-lines_parsed = 420
-coverage = 92.84
-
-[last_run_incremental.run_duration]
-secs = 45
-nanos = 633186947
diff --git a/AGENTS.md b/AGENTS.md
index 7e5348d..cd0127b 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -237,9 +237,9 @@ cargo doc --no-deps
```
Run `cargo tarpaulin --config tarpaulin.toml` when tests or executable Rust code
-change. It enforces the 90% line-coverage floor. Refresh
-the tracked local badges with `rust_autobadges --high-coverage-percent 0.7
---mid-coverage-percent 0.3` after a clean test and coverage run.
+change. It enforces the 90% line-coverage floor. Jenkins renders the version,
+test, and coverage badges from package metadata and CI results; generated badge
+files and status snapshots do not belong in the repository.
Also run focused CLI golden tests and LSP protocol tests once those binaries
exist. Favor property tests for replacement idempotence/non-overlap and fuzz
@@ -270,7 +270,8 @@ After every milestone's acceptance criteria and quality gates pass, create an
annotated Git tag named `v0.1.N`, where `N` is the milestone number, on its
completion commit. Before that completion commit, set the workspace package
version and internal registry dependency requirements to `0.1.N`, refresh
-`Cargo.lock`, cut the matching changelog entry, and regenerate the version badge.
-Verify those artifacts and binary `--version` output agree before tagging. Never
-move an existing milestone tag; add a corrective commit and a documented
-successor tag if a published milestone needs amendment.
+`Cargo.lock` and cut the matching changelog entry. Jenkins derives the version
+badge from that metadata. Verify the manifests, lockfile, changelog, and binary
+`--version` output agree before tagging. Never move an existing milestone tag;
+add a corrective commit and a documented successor tag if a published milestone
+needs amendment.
diff --git a/Jenkinsfile b/Jenkinsfile
index 8df4d47..1c7c266 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -8,8 +8,10 @@ pipeline {
CARGO_TERM_COLOR = 'always'
RUST_BACKTRACE = '1'
MSRV = '1.98.1'
+ CARGO_TARPAULIN_VERSION = '0.37.5'
CARGO_AUDIT_VERSION = '0.22.2'
CARGO_DENY_VERSION = '0.20.2'
+ BADGE_PUBLISH_ROOT = '/mnt/assets/coverage'
}
stages {
@@ -65,6 +67,11 @@ pipeline {
cargo install cargo-deny --locked --version "${CARGO_DENY_VERSION}"
fi
+ INSTALLED_TARPAULIN="$(cargo tarpaulin --version 2>/dev/null || true)"
+ if [ "${INSTALLED_TARPAULIN}" != "cargo-tarpaulin-tarpaulin ${CARGO_TARPAULIN_VERSION}" ]; then
+ cargo install cargo-tarpaulin --locked --version "${CARGO_TARPAULIN_VERSION}"
+ fi
+
'''
}
}
@@ -148,6 +155,32 @@ pipeline {
cargo test --locked --test example_fixtures --all-features
cargo test --locked --test cli --all-features
+
+ mkdir -p coverage
+ : > "coverage/.tests-passed-${BUILD_NUMBER}"
+ '''
+ }
+ }
+
+ stage('Coverage') {
+ steps {
+ sh '''
+ set -eu
+
+ cargo tarpaulin \
+ --config tarpaulin.toml \
+ --out Json \
+ --output-dir coverage
+
+ mv coverage/tarpaulin-report.json coverage/summary.json
+ coverage_percent=$(sed -n \
+ 's/^.*],"coverage":\([0-9][0-9.]*\),"covered":[0-9][0-9]*,"coverable":[0-9][0-9]*}$/\1/p' \
+ coverage/summary.json)
+ scripts/render-coverage-badge.sh \
+ "${coverage_percent}" \
+ coverage/coverage.svg
+ rm coverage/summary.json
+ : > "coverage/.coverage-ready-${BUILD_NUMBER}"
'''
}
}
@@ -236,7 +269,7 @@ pipeline {
conclusion: 'SUCCESS',
name: 'Rust CI',
summary: 'JohnSlop passed all CI checks.',
- text: 'The Linux MSRV/stable matrix, formatting, feature tests, fixtures, docs, Clippy, supply-chain policy, and release build completed successfully.',
+ text: 'The Linux MSRV/stable matrix, formatting, feature tests, fixtures, coverage and badge generation, docs, Clippy, supply-chain policy, and release build completed successfully.',
title: 'Build Successful'
)
@@ -248,7 +281,7 @@ pipeline {
conclusion: 'FAILURE',
name: 'Rust CI',
summary: 'JohnSlop failed CI.',
- text: 'A toolchain, formatting, test, fixture, documentation, Clippy, supply-chain, or release check failed. Check the Jenkins log.',
+ text: 'A toolchain, formatting, test, fixture, coverage, badge generation, documentation, Clippy, supply-chain, or release check failed. Check the Jenkins log.',
title: 'Build Failed'
)
@@ -266,5 +299,65 @@ pipeline {
echo '⚠️ JohnSlop CI is unstable.'
}
+
+ cleanup {
+ sh '''
+ set -eu
+
+ mkdir -p coverage
+ test_status=failing
+ if [ -f "coverage/.tests-passed-${BUILD_NUMBER}" ]; then
+ test_status=passing
+ fi
+ scripts/render-test-badge.sh \
+ "${test_status}" \
+ coverage/test.svg
+
+ if [ ! -f "coverage/.coverage-ready-${BUILD_NUMBER}" ]; then
+ scripts/render-coverage-badge.sh - coverage/coverage.svg
+ fi
+
+ package_version=$(awk '
+ $0 == "[workspace.package]" { in_package = 1; next }
+ substr($0, 1, 1) == "[" { in_package = 0 }
+ in_package && $1 == "version" && $2 == "=" {
+ gsub(/^"|"$/, "", $3)
+ print $3
+ exit
+ }
+ ' Cargo.toml)
+ if [ -z "${package_version}" ]; then
+ echo "could not determine workspace package version" >&2
+ exit 2
+ fi
+ scripts/render-version-badge.sh \
+ "${package_version}" \
+ coverage/version.svg
+
+ rm -f \
+ coverage/summary.json \
+ coverage/tarpaulin-report.json \
+ "coverage/.tests-passed-${BUILD_NUMBER}" \
+ "coverage/.coverage-ready-${BUILD_NUMBER}"
+ '''
+
+ archiveArtifacts(
+ allowEmptyArchive: false,
+ artifacts: 'coverage/coverage.svg,coverage/test.svg,coverage/version.svg',
+ fingerprint: true
+ )
+
+ sh '''
+ set -eu
+
+ if [ "${BRANCH_NAME:-}" = "main" ]; then
+ scripts/publish-badges.sh \
+ "${BADGE_PUBLISH_ROOT}" \
+ coverage \
+ test \
+ version
+ fi
+ '''
+ }
}
}
diff --git a/README.md b/README.md
index f70b275..a89a151 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
# John Slop
-
-
-
+
+
+
John Slop is a local-first linter for concrete signs of low-effort or
insufficiently reviewed text and source code. It reports explainable evidence
diff --git a/badges/coverage.svg b/badges/coverage.svg
deleted file mode 100644
index 66cd704..0000000
--- a/badges/coverage.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/badges/test.svg b/badges/test.svg
deleted file mode 100644
index 382bf2f..0000000
--- a/badges/test.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/badges/version.svg b/badges/version.svg
deleted file mode 100644
index bff1a27..0000000
--- a/badges/version.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/docs/development.md b/docs/development.md
index 743bbba..dff9ef1 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -61,10 +61,10 @@ generated diff.
## Coverage and badges
-Run line coverage with Cargo Tarpaulin:
+Run the same line-coverage command used by Jenkins:
```sh
-cargo tarpaulin --config tarpaulin.toml
+cargo tarpaulin --config tarpaulin.toml --out Json --output-dir coverage
```
The configuration enforces a 90% floor. The current suite measured 92.72%
@@ -73,16 +73,21 @@ platform/I/O failure injection, malformed archive internals, coordinate
overflow, LSP logging/reload failures, and subprocess attribution. Do not add
brittle tests or production seams solely to make Tarpaulin count those paths.
-After a clean test and coverage run, refresh the repository-local badges with:
+`Cargo.toml` is the authoritative version source. Jenkins temporarily renames
+the Tarpaulin JSON output to `coverage/summary.json`, extracts and validates its
+overall percentage, renders the badges locally, and then removes the summary.
+It archives only `coverage/version.svg`, `coverage/test.svg`, and
+`coverage/coverage.svg`, with fingerprinting. Successful `main` builds publish
+those files atomically under
+`/mnt/assets/coverage/idle-org/john-slop/main/`, which serves these mutable URLs:
-```sh
-rust_autobadges --high-coverage-percent 0.7 --mid-coverage-percent 0.3
-```
+- `https://assets.dandaedre.com/coverage/idle-org/john-slop/main/version.svg`
+- `https://assets.dandaedre.com/coverage/idle-org/john-slop/main/test.svg`
+- `https://assets.dandaedre.com/coverage/idle-org/john-slop/main/coverage.svg`
-Commit `badges/*.svg` and `.run_status.toml`; do not commit the generated
-`tarpaulin-report.html`. Coverage is currently a local release gate: Jenkins
-runs both feature configurations, but its Tarpaulin check is disabled while the
-job does not publish the report artifact.
+The asset server is deployment-owned: it must mount assets read-only, disable
+directory listings, serve SVG with a restrictive content security policy, and
+revalidate these URLs or apply a short cache lifetime.
## Test scope
@@ -96,7 +101,7 @@ Each completed milestone receives an immutable annotated `v0.1.N` Git tag,
where `N` is the milestone number, after its acceptance criteria and quality
gates pass. Its completion commit must also use package version `0.1.N` in the
workspace manifest, internal registry requirements, lockfile, changelog, binary
-version output, and generated version badge.
+version output. Jenkins derives the current version badge from that metadata.
## Fuzzing
diff --git a/scripts/publish-badges.sh b/scripts/publish-badges.sh
new file mode 100755
index 0000000..282523a
--- /dev/null
+++ b/scripts/publish-badges.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ echo "usage: $0 [badge...]" >&2
+ echo "badges: coverage test version" >&2
+ exit 2
+}
+
+[ "$#" -ge 2 ] || usage
+publication_root=$1
+shift
+case "$publication_root" in
+ /*) ;;
+ *)
+ echo "badge publication root must be an absolute path: $publication_root" >&2
+ exit 2
+ ;;
+esac
+if [ ! -d "$publication_root" ] || [ ! -w "$publication_root" ]; then
+ echo "badge publication root must be an existing writable directory: $publication_root" >&2
+ exit 2
+fi
+
+selected=' '
+for badge in "$@"; do
+ case "$badge" in
+ coverage|test|version) ;;
+ *)
+ echo "unsupported badge: $badge" >&2
+ exit 2
+ ;;
+ esac
+ case "$selected" in
+ *" $badge "*)
+ echo "badge selected more than once: $badge" >&2
+ exit 2
+ ;;
+ esac
+ selected="$selected$badge "
+ source="coverage/$badge.svg"
+ if [ ! -f "$source" ] || [ ! -s "$source" ] || [ -L "$source" ]; then
+ echo "required badge must be a regular nonempty file, not a symlink: $source" >&2
+ exit 2
+ fi
+done
+
+owner_root="$publication_root/idle-org"
+project_root="$owner_root/john-slop"
+badge_root="$project_root/main"
+for directory in "$owner_root" "$project_root"; do
+ if [ -L "$directory" ] || { [ -e "$directory" ] && [ ! -d "$directory" ]; }; then
+ echo "badge destination component is not a directory: $directory" >&2
+ exit 2
+ fi
+ mkdir -p "$directory"
+ chmod 0755 "$directory"
+done
+if [ -L "$badge_root" ]; then
+ unlink "$badge_root"
+elif [ -e "$badge_root" ] && [ ! -d "$badge_root" ]; then
+ echo "badge destination is not a directory: $badge_root" >&2
+ exit 2
+fi
+mkdir -p "$badge_root"
+chmod 0755 "$badge_root"
+
+temporary=
+trap 'if [ -n "$temporary" ]; then rm -f "$temporary"; fi' EXIT HUP INT TERM
+for badge in "$@"; do
+ temporary=$(mktemp "$badge_root/.$badge.svg.XXXXXX")
+ cp "coverage/$badge.svg" "$temporary"
+ chmod 0644 "$temporary"
+ mv -f "$temporary" "$badge_root/$badge.svg"
+ temporary=
+ echo "published $badge badge to $badge_root/$badge.svg"
+done
+trap - EXIT HUP INT TERM
diff --git a/scripts/render-coverage-badge.sh b/scripts/render-coverage-badge.sh
new file mode 100755
index 0000000..5f7f09f
--- /dev/null
+++ b/scripts/render-coverage-badge.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ echo "usage: $0 " >&2
+ exit 2
+}
+
+[ "$#" -eq 2 ] || usage
+percent=$1
+output=$2
+
+if [ "$percent" = "-" ]; then
+ rounded=-
+ color='#9f9f9f'
+else
+ if ! awk -v value="$percent" 'BEGIN {
+ valid = value ~ /^[0-9]+([.][0-9]+)?$/ && value >= 0 && value <= 100
+ exit(valid ? 0 : 1)
+ }'; then
+ echo "coverage percentage must be - or a number from 0 through 100: $percent" >&2
+ exit 2
+ fi
+ rounded=$(awk -v value="$percent" 'BEGIN { printf "%.0f", value }')
+ if [ "$rounded" -ge 90 ]; then
+ color='#4c1'
+ elif [ "$rounded" -ge 70 ]; then
+ color='#dfb317'
+ else
+ color='#e05d44'
+ fi
+fi
+
+output_dir=${output%/*}
+if [ "$output_dir" != "$output" ]; then
+ mkdir -p "$output_dir"
+fi
+temporary="${output}.tmp.$$"
+trap 'rm -f "$temporary"' EXIT HUP INT TERM
+sed \
+ -e "s/@PERCENT@/${rounded}/g" \
+ -e "s/@COLOR@/${color}/g" \
+ >"$temporary" <<'EOF'
+
+EOF
+mv "$temporary" "$output"
+trap - EXIT HUP INT TERM
diff --git a/scripts/render-test-badge.sh b/scripts/render-test-badge.sh
new file mode 100755
index 0000000..94cbf57
--- /dev/null
+++ b/scripts/render-test-badge.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ echo "usage: $0 " >&2
+ exit 2
+}
+
+[ "$#" -eq 2 ] || usage
+status=$1
+output=$2
+case "$status" in
+ passing) color='#4c1' ;;
+ failing) color='#e05d44' ;;
+ *)
+ echo "test badge status must be passing or failing: $status" >&2
+ exit 2
+ ;;
+esac
+
+output_dir=${output%/*}
+if [ "$output_dir" != "$output" ]; then
+ mkdir -p "$output_dir"
+fi
+temporary="${output}.tmp.$$"
+trap 'rm -f "$temporary"' EXIT HUP INT TERM
+sed \
+ -e "s/@STATUS@/${status}/g" \
+ -e "s/@COLOR@/${color}/g" \
+ >"$temporary" <<'EOF'
+
+EOF
+mv "$temporary" "$output"
+trap - EXIT HUP INT TERM
diff --git a/scripts/render-version-badge.sh b/scripts/render-version-badge.sh
new file mode 100755
index 0000000..bfbf61b
--- /dev/null
+++ b/scripts/render-version-badge.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ echo "usage: $0 " >&2
+ exit 2
+}
+
+[ "$#" -eq 2 ] || usage
+version=$1
+output=$2
+case "$version" in
+ ''|*[!0-9A-Za-z.+-]*)
+ echo "package version contains unsupported badge characters: $version" >&2
+ exit 2
+ ;;
+esac
+
+value_width=$(awk -v value="$version" 'BEGIN {
+ width = length(value) * 7 + 10
+ print (width < 45 ? 45 : width)
+}')
+badge_width=$((59 + value_width))
+value_center=$(awk -v width="$value_width" 'BEGIN {
+ printf "%.1f", 59 + width / 2
+}')
+output_dir=${output%/*}
+if [ "$output_dir" != "$output" ]; then
+ mkdir -p "$output_dir"
+fi
+temporary="${output}.tmp.$$"
+trap 'rm -f "$temporary"' EXIT HUP INT TERM
+sed \
+ -e "s/@VERSION@/${version}/g" \
+ -e "s/@BADGE_WIDTH@/${badge_width}/g" \
+ -e "s/@VALUE_WIDTH@/${value_width}/g" \
+ -e "s/@VALUE_CENTER@/${value_center}/g" \
+ >"$temporary" <<'EOF'
+
+EOF
+mv "$temporary" "$output"
+trap - EXIT HUP INT TERM
diff --git a/tests/workspace_contract.rs b/tests/workspace_contract.rs
index f841929..6adb0b6 100644
--- a/tests/workspace_contract.rs
+++ b/tests/workspace_contract.rs
@@ -100,7 +100,19 @@ fn workspace_members_and_resolved_versions_are_synchronized() {
);
}
- let badge = fs::read_to_string("badges/version.svg").expect("version badge must be readable");
+ let temporary = tempfile::tempdir().expect("temporary badge directory must be created");
+ let badge_path = temporary.path().join("version.svg");
+ let output = Command::new("scripts/render-version-badge.sh")
+ .arg(workspace_version)
+ .arg(&badge_path)
+ .output()
+ .expect("version badge renderer must run");
+ assert!(
+ output.status.success(),
+ "version badge rendering failed: {}",
+ String::from_utf8_lossy(&output.stderr)
+ );
+ let badge = fs::read_to_string(badge_path).expect("rendered version badge must be readable");
assert!(
badge.contains(&format!("aria-label=\"version: {workspace_version}\"")),
"version badge must advertise workspace version {workspace_version}"