diff --git a/Jenkinsfile b/Jenkinsfile index 453565c..cff8068 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,14 @@ pipeline { timestamps() } + parameters { + booleanParam( + name: 'ENABLE_NATIVE_BACKENDS', + defaultValue: false, + description: 'Run Linux-only MIDI/Pulse gates after the worker has been migrated and provisioned.' + ) + } + environment { CARGO_TERM_COLOR = 'never' RUST_BACKTRACE = '1' @@ -52,24 +60,37 @@ pipeline { exit 1 fi - rustup toolchain install "${RUSTUP_TOOLCHAIN}" \ - --profile minimal \ - --component rustfmt \ - --component clippy \ - --component llvm-tools-preview + if [ "${ENABLE_NATIVE_BACKENDS}" = true ]; then + rustup toolchain install "${RUSTUP_TOOLCHAIN}" \ + --profile minimal \ + --component rustfmt \ + --component clippy \ + --component llvm-tools-preview + else + rustup toolchain install "${RUSTUP_TOOLCHAIN}" \ + --profile minimal \ + --component rustfmt \ + --component clippy + fi - if ! cargo llvm-cov --version 2>/dev/null \ - | grep -F "cargo-llvm-cov ${CARGO_LLVM_COV_VERSION}" >/dev/null; then - cargo install cargo-llvm-cov \ - --version "${CARGO_LLVM_COV_VERSION}" \ - --locked + if [ "${ENABLE_NATIVE_BACKENDS}" = true ]; then + if ! cargo llvm-cov --version 2>/dev/null \ + | grep -F "cargo-llvm-cov ${CARGO_LLVM_COV_VERSION}" >/dev/null; then + cargo install cargo-llvm-cov \ + --version "${CARGO_LLVM_COV_VERSION}" \ + --locked + fi fi rustc --version cargo --version rustfmt --version cargo clippy --version - cargo llvm-cov --version + if [ "${ENABLE_NATIVE_BACKENDS}" = true ]; then + cargo llvm-cov --version + else + echo 'Native backend and coverage gates are disabled for this portable build.' + fi ''' } } @@ -93,6 +114,7 @@ pipeline { } stage('Check') { + when { expression { params.ENABLE_NATIVE_BACKENDS } } steps { sh ''' set -eu @@ -104,6 +126,7 @@ pipeline { } stage('Tests') { + when { expression { params.ENABLE_NATIVE_BACKENDS } } steps { sh ''' set -eu @@ -115,7 +138,33 @@ pipeline { } } + stage('Portable Rust Gates') { + when { expression { !params.ENABLE_NATIVE_BACKENDS } } + steps { + sh ''' + set -eu + + cargo check -p fader-core -p fader-config -p midi -p volume_lib -p tui \ + --all-targets --no-default-features --locked + cargo test -p fader-core -p fader-config -p midi -p volume_lib -p tui \ + --all-targets --no-default-features --locked + cargo test -p fader-core -p fader-config -p midi -p volume_lib -p tui \ + --doc --no-default-features --locked + RUSTDOCFLAGS='-D warnings' \ + cargo doc -p fader-core -p fader-config -p midi -p volume_lib -p tui \ + --no-deps --no-default-features --locked + cargo clippy -p fader-core -p fader-config -p midi -p volume_lib -p tui \ + --all-targets --no-default-features --locked -- -D warnings + cargo build -p fader-core -p fader-config -p midi -p volume_lib -p tui \ + --release --no-default-features --locked + + : >"coverage/.tests-passed-${BUILD_NUMBER}" + ''' + } + } + stage('Coverage') { + when { expression { params.ENABLE_NATIVE_BACKENDS } } steps { sh ''' scripts/ci-run-coverage.sh \ @@ -128,6 +177,7 @@ pipeline { } stage('Documentation') { + when { expression { params.ENABLE_NATIVE_BACKENDS } } steps { sh ''' set -eu @@ -139,6 +189,7 @@ pipeline { } stage('Clippy') { + when { expression { params.ENABLE_NATIVE_BACKENDS } } steps { sh ''' set -eu @@ -154,6 +205,7 @@ pipeline { } stage('Build Release') { + when { expression { params.ENABLE_NATIVE_BACKENDS } } steps { sh ''' set -eu @@ -210,18 +262,24 @@ pipeline { echo 'Not publishing mutable badges: BRANCH_NAME and GIT_BRANCH are unavailable.' } + def nativeBackends = params.ENABLE_NATIVE_BACKENDS def coverageStatus = fileExists('coverage/coverage-status.txt') ? readFile('coverage/coverage-status.txt').trim() - : "Line coverage: unavailable; required minimum: ${env.COVERAGE_MIN_LINES}%; reason: the coverage stage did not produce a status" + : nativeBackends + ? "Line coverage: unavailable; required minimum: ${env.COVERAGE_MIN_LINES}%; reason: the coverage stage did not produce a status" + : 'Line coverage: unavailable; portable FreeBSD gates intentionally exclude the Linux-only executable and native backends' def passed = currentBuild.currentResult == 'SUCCESS' + def gateSummary = nativeBackends + ? 'Full Linux/native formatting, checks, tests, coverage, documentation, Clippy, and release gates were evaluated.' + : 'Portable formatting, checks, tests, documentation, Clippy, and release-library gates were evaluated; Linux-only executable and native backend gates were skipped.' publishChecks( conclusion: passed ? 'SUCCESS' : 'FAILURE', name: 'Rust CI', - summary: passed ? 'fader_master passed CI.' : 'fader_master failed CI.', - text: "Formatting, checks, tests, coverage, documentation, warning-strict Clippy, release build, and badge generation were evaluated. ${coverageStatus}", - title: passed ? 'Build Successful' : 'Build Failed' + summary: passed ? 'fader_master passed its selected CI mode.' : 'fader_master failed CI.', + text: "${gateSummary} ${coverageStatus}", + title: passed ? (nativeBackends ? 'Native Build Successful' : 'Portable Build Successful') : 'Build Failed' ) - echo "${passed ? 'fader_master passed CI.' : 'fader_master CI failed.'} ${coverageStatus}" + echo "${passed ? 'fader_master passed its selected CI mode.' : 'fader_master CI failed.'} ${gateSummary} ${coverageStatus}" sh 'rm -f coverage/coverage-status.txt' } diff --git a/docs/build.md b/docs/build.md index 7feb9b3..ebb8a05 100644 --- a/docs/build.md +++ b/docs/build.md @@ -62,3 +62,19 @@ newer installed toolchain: cargo +1.88.0 check --workspace --all-targets --all-features --locked cargo +1.88.0 test --workspace --all-targets --all-features --locked ``` + +## Jenkins backend modes + +The current Jenkins worker is FreeBSD, so the job parameter +`ENABLE_NATIVE_BACKENDS` defaults to false. In that mode CI checks, tests, +documents, lints, and release-builds the portable `fader-core`, `fader-config`, +`midi`, `volume_lib`, and `tui` packages with native features disabled. It does +not build or test the Linux-only `fader_master` executable, MIDI transport, +udev identity adapter, or Pulse adapter, and it publishes unavailable coverage +rather than presenting partial coverage as the workspace measurement. + +After Jenkins moves to a provisioned Linux worker, enable +`ENABLE_NATIVE_BACKENDS` on the build (and change its default only after that +build passes). This restores the complete default/no-default/all-feature +workspace matrix, workspace coverage, doctests, strict documentation and +Clippy, and the release executable assertion without changing the pipeline. diff --git a/docs/ci-coverage.md b/docs/ci-coverage.md index 40e39eb..1bde409 100644 --- a/docs/ci-coverage.md +++ b/docs/ci-coverage.md @@ -20,6 +20,12 @@ is not excluded. A valid current-build report is marked ready even when it is below the floor; missing or invalid reports fail with an unavailable diagnostic and cannot reuse an older value. +Coverage runs only when the Jenkins `ENABLE_NATIVE_BACKENDS` parameter is true. +The temporary FreeBSD-compatible mode deliberately emits the neutral/unavailable +coverage badge because its portable package subset would not be comparable to +the full workspace measurement. Enabling the parameter on a provisioned Linux +worker restores the existing coverage command and threshold. + The authoritative version is `[workspace.package].version` in the root `Cargo.toml`. During Jenkins cleanup, the current build's test marker determines the test badge, a ready marker preserves current measured coverage, and the diff --git a/scripts/test-ci.sh b/scripts/test-ci.sh index ca40d10..1819513 100755 --- a/scripts/test-ci.sh +++ b/scripts/test-ci.sh @@ -30,6 +30,13 @@ file_mode() { fi } +assert_contains "$repository/Jenkinsfile" "name: 'ENABLE_NATIVE_BACKENDS'" +assert_contains "$repository/Jenkinsfile" 'defaultValue: false' +assert_contains "$repository/Jenkinsfile" "stage('Portable Rust Gates')" +assert_contains "$repository/Jenkinsfile" '!params.ENABLE_NATIVE_BACKENDS' +assert_contains "$repository/Jenkinsfile" 'params.ENABLE_NATIVE_BACKENDS' +assert_contains "$repository/Jenkinsfile" 'cargo test -p fader-core -p fader-config -p midi -p volume_lib -p tui' + svg_count() { directory=$1 count=0 diff --git a/task.md b/task.md index af2794c..209267b 100644 --- a/task.md +++ b/task.md @@ -20,6 +20,10 @@ Dependencies: planning. - [x] **M0.1 Toolchain and build:** select/test an MSRV and pinned toolchain, centralize workspace metadata/dependencies, track Cargo.lock for the executable, document native build prerequisites. Acceptance: a fresh supported Linux checkout builds and tests reproducibly with `--locked`; the chosen MSRV builds the chosen dependency set. - [ ] **M0.2 CI gates:** align Jenkins with AGENTS.md, including doctests, Clippy `-D warnings`, release build and later backend feature matrix. Acceptance: representative formatting/lint/test failures fail the pipeline; default and full-feature builds pass with provisioned dependencies. Repository configuration now runs locked default, no-default-features, and all-features checks/tests plus warning-strict documentation, Clippy, and release gates. Keep this open until a real Jenkins run on the provisioned worker passes. + While the only worker is FreeBSD, the `ENABLE_NATIVE_BACKENDS=false` default + runs explicit portable-package gates and honestly marks coverage unavailable. + Enabling that build parameter restores the full existing Linux/native matrix; + M0.2 remains open until that mode passes on a provisioned Linux worker. - [x] **M0.2a Coverage badges:** measure locked all-target line coverage with a pinned tool, enforce the documented 20% scaffold floor, and generate/archive the version, test, and coverage badges on every build. Publish atomically only from `main`, with fresh-build markers preventing stale test or coverage values. Acceptance: renderer, coverage lifecycle, finalization, and publication fixture tests pass; the real local measurement is above the floor. Jenkins publication and public retrieval remain deployment checks. - [x] **M0.3 Domain boundary:** add `fader-core` and `fader-config`, wire current crates inward, remove placeholder arithmetic tests as real contracts replace them. Acceptance: core tests run without a terminal, sound daemon, native device connection, or Tokio runtime; dependency graph has no cycles.