diff --git a/.gitignore b/.gitignore index 193d30e..30996ea 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,8 @@ target/ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock +# CI-generated badge files, markers, and coverage reports. +/coverage/ # These are backup files generated by rustfmt **/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..1278905 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,700 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +dependencies = [ + "serde_core", +] + +[[package]] +name = "cassowary" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" + +[[package]] +name = "castaway" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" +dependencies = [ + "rustversion", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "compact_str" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd622ebbb56a5b2ccb651b32b911cdeb2a9b4b11776b2473bf26a26a286244e" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "rustversion", + "ryu", + "serde", + "static_assertions", +] + +[[package]] +name = "crossterm" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" +dependencies = [ + "bitflags", + "crossterm_winapi", + "mio", + "parking_lot", + "rustix", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + +[[package]] +name = "darling" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 3.0.6", +] + +[[package]] +name = "darling_macro" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" +dependencies = [ + "darling_core", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" + +[[package]] +name = "either" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fader_master" +version = "0.1.0" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indoc" +version = "2.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706" +dependencies = [ + "rustversion", +] + +[[package]] +name = "instability" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c3b5acc1e2fd9375041a388da33d1eb8aed5f7a8c0dd3543e3ea2805adfbe20" +dependencies = [ + "darling", + "indoc", + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "libc" +version = "0.2.190" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78" + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "lru" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "midi" +version = "0.1.0" + +[[package]] +name = "mio" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ratatui" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" +dependencies = [ + "bitflags", + "cassowary", + "compact_str", + "crossterm", + "indoc", + "instability", + "itertools", + "lru", + "paste", + "serde", + "strum", + "time", + "unicode-segmentation", + "unicode-truncate", + "unicode-width 0.2.0", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "signal-hook" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "smallvec" +version = "1.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.119", +] + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "time" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" +dependencies = [ + "deranged", + "libc", + "num-conv", + "num_threads", + "powerfmt", + "serde_core", + "time-core", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "tui" +version = "0.1.0" +dependencies = [ + "ratatui", +] + +[[package]] +name = "unicode-ident" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-truncate" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" +dependencies = [ + "itertools", + "unicode-segmentation", + "unicode-width 0.1.14", +] + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + +[[package]] +name = "volume_lib" +version = "0.1.0" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Jenkinsfile b/Jenkinsfile index 675adcb..805615d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,12 +12,16 @@ pipeline { } environment { - // Jenkins logs are easier to read without Cargo ANSI escape sequences. CARGO_TERM_COLOR = 'never' RUST_BACKTRACE = '1' - - // Keep CI artifacts separate from local build output. CARGO_TARGET_DIR = "${WORKSPACE}/target-ci" + + BADGE_OWNER = 'MadGobblins' + BADGE_PROJECT = 'fader_master' + BADGE_DEFAULT_BRANCH = 'main' + BADGE_PUBLICATION_ROOT = '/mnt/assets/coverage' + COVERAGE_MIN_LINES = '20' + CARGO_LLVM_COV_VERSION = '0.9.1' } stages { @@ -30,6 +34,9 @@ pipeline { git submodule sync --recursive git submodule update --init --recursive + + rm -rf coverage + mkdir -p coverage ''' } } @@ -47,13 +54,31 @@ pipeline { rustup toolchain install stable \ --profile minimal \ --component rustfmt \ - --component clippy + --component clippy \ + --component llvm-tools-preview rustup default stable + 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 + rustc --version cargo --version rustfmt --version cargo clippy --version + cargo llvm-cov --version + ''' + } + } + + stage('CI Script Tests') { + steps { + sh ''' + set -eu + scripts/test-ci.sh ''' } } @@ -71,7 +96,7 @@ pipeline { steps { sh ''' set -eu - cargo check --workspace --all-targets --all-features + cargo check --workspace --all-targets --all-features --locked ''' } } @@ -80,7 +105,20 @@ pipeline { steps { sh ''' set -eu - cargo test --workspace --all-targets --all-features + cargo test --workspace --all-targets --all-features --locked + : >"coverage/.tests-passed-${BUILD_NUMBER}" + ''' + } + } + + stage('Coverage') { + steps { + sh ''' + scripts/ci-run-coverage.sh \ + "${COVERAGE_MIN_LINES}" \ + coverage/llvm-cov-summary.json \ + "coverage/.coverage-ready-${BUILD_NUMBER}" \ + coverage/coverage-status.txt ''' } } @@ -89,9 +127,9 @@ pipeline { steps { sh ''' set -eu - cargo test --workspace --doc --all-features + cargo test --workspace --doc --all-features --locked RUSTDOCFLAGS='-D warnings' \ - cargo doc --workspace --no-deps --all-features + cargo doc --workspace --no-deps --all-features --locked ''' } } @@ -104,6 +142,7 @@ pipeline { --workspace \ --all-targets \ --all-features \ + --locked \ -- \ -D warnings ''' @@ -114,7 +153,7 @@ pipeline { steps { sh ''' set -eu - cargo build --workspace --release --all-features + cargo build --workspace --release --all-features --locked BINARY="${CARGO_TARGET_DIR}/release/fader_master" if [ ! -x "${BINARY}" ]; then @@ -131,43 +170,57 @@ pipeline { } post { - success { - publishChecks( - conclusion: 'SUCCESS', - name: 'Rust CI', - summary: 'fader_master passed CI.', - text: 'Formatting, workspace checks, tests, documentation, warning-strict Clippy and the release build completed successfully.', - title: 'Build Successful' - ) - - echo 'fader_master passed CI.' - } - - failure { - publishChecks( - conclusion: 'FAILURE', - name: 'Rust CI', - summary: 'fader_master failed CI.', - text: 'Formatting, workspace checks, tests, documentation, Clippy, or the release build failed. See the Jenkins log.', - title: 'Build Failed' - ) - - echo 'fader_master CI failed.' - } - - unstable { - publishChecks( - conclusion: 'ACTION_REQUIRED', - name: 'Rust CI', - summary: 'fader_master CI is unstable.', - text: 'The Jenkins build completed with an unstable status. See the Jenkins log.', - title: 'Build Unstable' - ) - - echo 'fader_master CI is unstable.' - } - cleanup { + script { + sh ''' + set -eu + scripts/ci-finalize-badges.sh "${BUILD_NUMBER}" + ''' + + archiveArtifacts( + allowEmptyArchive: false, + artifacts: 'coverage/coverage.svg,coverage/test.svg,coverage/version.svg', + fingerprint: true + ) + + def ciBranch = env.BRANCH_NAME + if (!ciBranch && env.GIT_BRANCH) { + ciBranch = env.GIT_BRANCH + .replaceFirst(/^refs\/remotes\/origin\//, '') + .replaceFirst(/^origin\//, '') + } + if (ciBranch == env.BADGE_DEFAULT_BRANCH) { + sh ''' + set -eu + scripts/ci-publish-badges.sh \ + "${BADGE_PUBLICATION_ROOT}" \ + "${BADGE_OWNER}" \ + "${BADGE_PROJECT}" \ + "${BADGE_DEFAULT_BRANCH}" \ + coverage test version + ''' + } else if (ciBranch) { + echo "Not publishing mutable badges from non-default branch ${ciBranch}." + } else { + echo 'Not publishing mutable badges: BRANCH_NAME and GIT_BRANCH are unavailable.' + } + + 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" + def passed = currentBuild.currentResult == 'SUCCESS' + 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' + ) + echo "${passed ? 'fader_master passed CI.' : 'fader_master CI failed.'} ${coverageStatus}" + + sh 'rm -f coverage/coverage-status.txt' + } + deleteDir() } } diff --git a/README.md b/README.md index 29368a9..6bb6da3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # fader_master +![Version](https://assets.dandaedre.com/coverage/MadGobblins/fader_master/main/version.svg) +![Tests](https://assets.dandaedre.com/coverage/MadGobblins/fader_master/main/test.svg) +![Coverage](https://assets.dandaedre.com/coverage/MadGobblins/fader_master/main/coverage.svg) + Linux application volume and mute control from one or more USB MIDI surfaces. This repository currently contains an early Rust workspace and TUI prototype. @@ -9,6 +13,7 @@ planned in the following documents: - [Architecture and library research](architecture.md) - [Implementation tasks and acceptance tests](task.md) - [Project-agent instructions and test/commit workflow](AGENTS.md) +- [CI coverage and badge lifecycle](docs/ci-coverage.md) # References diff --git a/docs/ci-coverage.md b/docs/ci-coverage.md new file mode 100644 index 0000000..40e39eb --- /dev/null +++ b/docs/ci-coverage.md @@ -0,0 +1,60 @@ +# CI coverage and badge lifecycle + +The generic renderer in `scripts/ci-coverage-badges.sh` is copied unchanged +from `Dandaedre/agent-tasks` revision +`fb9d8f7d16f100c2d1377f23394a2302eac9ab18`. + +Jenkins installs the pinned `cargo-llvm-cov` 0.9.1 release and runs: + +```sh +scripts/ci-run-coverage.sh 20 coverage/llvm-cov-summary.json \ + "coverage/.coverage-ready-${BUILD_NUMBER}" coverage/coverage-status.txt +``` + +The underlying measurement is one locked `cargo llvm-cov --workspace +--all-targets --all-features --locked --json --summary-only` run. The script +reads the overall line percentage from the temporary JSON summary, displays the +unrounded measurement and the 20% floor, renders the rounded coverage badge, +then enforces the floor against the unrounded value. Ordinary production code +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. + +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 +workspace version determines the version badge. Jenkins archives exactly these +files with fingerprints: + +```text +coverage/version.svg +coverage/test.svg +coverage/coverage.svg +``` + +The temporary JSON summary and both build-specific markers are removed during +badge finalization. `coverage/coverage-status.txt` is retained just long enough +to populate the Jenkins build summary, then removed as well. + +For a default-branch build, the publication script atomically copies them to: + +```text +/mnt/assets/coverage/MadGobblins/fader_master/main/version.svg +/mnt/assets/coverage/MadGobblins/fader_master/main/test.svg +/mnt/assets/coverage/MadGobblins/fader_master/main/coverage.svg +``` + +Their public URLs are: + +- `https://assets.dandaedre.com/coverage/MadGobblins/fader_master/main/version.svg` +- `https://assets.dandaedre.com/coverage/MadGobblins/fader_master/main/test.svg` +- `https://assets.dandaedre.com/coverage/MadGobblins/fader_master/main/coverage.svg` + +The Jenkins job must expose `BRANCH_NAME` (multibranch Pipeline) or `GIT_BRANCH` +from `checkout scm`; builds without either variable do not publish. Non-default +branches still generate and archive all three badges. The real asset mount and +public retrieval remain deployment checks outside repository tests. + +The public server should mount the asset tree read-only, disable directory +listings, serve SVG with a restrictive content security policy, and revalidate +these mutable URLs or give them a short cache lifetime. diff --git a/scripts/ci-coverage-badges.sh b/scripts/ci-coverage-badges.sh new file mode 100755 index 0000000..c76b094 --- /dev/null +++ b/scripts/ci-coverage-badges.sh @@ -0,0 +1,270 @@ +#!/bin/sh +set -eu + +usage() { + cat >&2 <<'EOF' +usage: $0 [options] + +Render one deterministic SVG badge. Defaults: + version --text version --value unknown --color #007ec6 + test --text tests --value passing --color #4c1 + coverage --text coverage --value - --color #9f9f9f --suffix % + +Options: + --text TEXT left-hand label + --value VALUE right-hand value + --color COLOR value background (#RGB or #RRGGBB) + --size PX font size, from 6 through 24 (default: 11) + --height PX badge height, from 14 through 64 (default: 20) + --label-width PX fixed label width instead of automatic sizing + --value-width PX fixed value width instead of automatic sizing + --suffix TEXT text appended to the displayed value + --output PATH output file (default: coverage/.svg) + -h, --help show this help + +Examples: + ./ci-coverage-badges.sh version --value 1.2.3 + ./ci-coverage-badges.sh test --value failing + ./ci-coverage-badges.sh coverage --value 87.4 + ./ci-coverage-badges.sh version --text release --value rc.12 --size 12 --color '#8a2be2' +EOF + exit "${1:-2}" +} + +[ "$#" -ge 1 ] || usage +kind=$1 +shift + +case "$kind" in + version) + text=version + value=unknown + color='#007ec6' + suffix= + output=coverage/version.svg + ;; + test) + text=tests + value=passing + color= + suffix= + output=coverage/test.svg + ;; + coverage) + text=coverage + value=- + color= + suffix=% + output=coverage/coverage.svg + ;; + -h|--help) usage 0 ;; + *) + echo "unsupported badge kind: $kind" >&2 + usage + ;; +esac + +font_size=11 +height=20 +label_width= +value_width= +color_set=false + +while [ "$#" -gt 0 ]; do + option=$1 + case "$option" in + --text|--value|--color|--size|--height|--label-width|--value-width|--suffix|--output) + [ "$#" -ge 2 ] || { + echo "missing value for $option" >&2 + exit 2 + } + option_value=$2 + shift 2 + case "$option" in + --text) text=$option_value ;; + --value) value=$option_value ;; + --color) color=$option_value; color_set=true ;; + --size) font_size=$option_value ;; + --height) height=$option_value ;; + --label-width) label_width=$option_value ;; + --value-width) value_width=$option_value ;; + --suffix) suffix=$option_value ;; + --output) output=$option_value ;; + esac + ;; + -h|--help) usage 0 ;; + *) + echo "unknown option: $option" >&2 + usage + ;; + esac +done + +validate_text() { + field_name=$1 + field_value=$2 + if ! printf '%sX\n' "$field_value" | LC_ALL=C awk ' + BEGIN { valid = 1 } + NR != 1 || $0 !~ /^[ -~]+X$/ || length($0) <= 1 { valid = 0 } + END { exit(valid == 0 ? 1 : 0) } + '; then + echo "$field_name must contain printable ASCII characters: $field_value" >&2 + exit 2 + fi +} + +validate_integer() { + field_name=$1 + field_value=$2 + minimum=$3 + maximum=$4 + case "$field_value" in + ''|*[!0-9]*) + echo "$field_name must be an integer from $minimum through $maximum: $field_value" >&2 + exit 2 + ;; + esac + if [ "$field_value" -lt "$minimum" ] || [ "$field_value" -gt "$maximum" ]; then + echo "$field_name must be an integer from $minimum through $maximum: $field_value" >&2 + exit 2 + fi +} + +validate_text text "$text" +validate_text value "$value" +if [ -n "$suffix" ]; then + validate_text suffix "$suffix" +fi +validate_integer size "$font_size" 6 24 +validate_integer height "$height" 14 64 +if [ -n "$label_width" ]; then + validate_integer label-width "$label_width" 20 1000 +fi +if [ -n "$value_width" ]; then + validate_integer value-width "$value_width" 20 1000 +fi +case "$output" in + ''|*/) echo "output must name an SVG file: $output" >&2; exit 2 ;; +esac + +case "$kind" in + test) + if [ "$color_set" = false ]; then + case "$value" in + passing) color='#4c1' ;; + failing) color='#e05d44' ;; + *) color='#9f9f9f' ;; + esac + fi + ;; + coverage) + if [ "$value" = '-' ]; then + [ "$color_set" = true ] || color='#9f9f9f' + else + if ! awk -v candidate="$value" 'BEGIN { + valid = candidate ~ /^[0-9]+([.][0-9]+)?$/ && candidate >= 0 && candidate <= 100 + exit(valid ? 0 : 1) + }'; then + echo "coverage value must be - or a number from 0 through 100: $value" >&2 + exit 2 + fi + value=$(awk -v candidate="$value" 'BEGIN { printf "%.0f", candidate }') + if [ "$color_set" = false ]; then + if [ "$value" -ge 90 ]; then + color='#4c1' + elif [ "$value" -ge 70 ]; then + color='#dfb317' + else + color='#e05d44' + fi + fi + fi + ;; +esac + +case "$color" in + \#[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]|\#[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]) ;; + *) echo "color must be #RGB or #RRGGBB: $color" >&2; exit 2 ;; +esac + +display_value=$value$suffix +if [ -z "$label_width" ]; then + label_width=$(printf '%s\\n' "$text" | awk -v size="$font_size" '{ + width = int(length($0) * size * 0.64 + 14) + print (width < 35 ? 35 : width) + }') +fi +if [ -z "$value_width" ]; then + value_width=$(printf '%s\\n' "$display_value" | awk -v size="$font_size" '{ + width = int(length($0) * size * 0.64 + 14) + print (width < 35 ? 35 : width) + }') +fi + +badge_width=$((label_width + value_width)) +label_center=$(awk -v width="$label_width" 'BEGIN { printf "%.1f", width / 2 }') +value_center=$(awk -v left="$label_width" -v width="$value_width" 'BEGIN { + printf "%.1f", left + width / 2 +}') +vertical_center=$(awk -v badge_height="$height" 'BEGIN { printf "%.1f", badge_height / 2 }') + +xml_escape() { + sed \ + -e 's/&/\&/g' \ + -e 's//\>/g' \ + -e 's/"/\"/g' +} + +sed_replacement_escape() { + sed -e 's/[\\&|]/\\&/g' +} + +escaped_text=$(printf '%s' "$text" | xml_escape | sed_replacement_escape) +escaped_value=$(printf '%s' "$display_value" | xml_escape | sed_replacement_escape) +escaped_title=$(printf '%s: %s' "$text" "$display_value" | xml_escape | sed_replacement_escape) + +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/@BADGE_WIDTH@/$badge_width/g" \ + -e "s/@HEIGHT@/$height/g" \ + -e "s/@LABEL_WIDTH@/$label_width/g" \ + -e "s/@VALUE_WIDTH@/$value_width/g" \ + -e "s/@LABEL_CENTER@/$label_center/g" \ + -e "s/@VALUE_CENTER@/$value_center/g" \ + -e "s/@VERTICAL_CENTER@/$vertical_center/g" \ + -e "s/@FONT_SIZE@/$font_size/g" \ + -e "s/@COLOR@/$color/g" \ + -e "s|@TITLE@|$escaped_title|g" \ + -e "s|@TEXT@|$escaped_text|g" \ + -e "s|@VALUE@|$escaped_value|g" \ + >"$temporary" <<'EOF' + + @TITLE@ + + + + + + + + + + + + + + @TEXT@ + @VALUE@ + + +EOF + +mv "$temporary" "$output" +trap - EXIT HUP INT TERM diff --git a/scripts/ci-finalize-badges.sh b/scripts/ci-finalize-badges.sh new file mode 100755 index 0000000..1a69ad9 --- /dev/null +++ b/scripts/ci-finalize-badges.sh @@ -0,0 +1,61 @@ +#!/bin/sh +set -eu + +if [ "$#" -ne 1 ]; then + echo "usage: $0 BUILD_NUMBER" >&2 + exit 2 +fi + +build_number=$1 +case "$build_number" in + ''|*[!A-Za-z0-9._-]*) + echo "build number is not safe for a marker name: $build_number" >&2 + exit 2 + ;; +esac + +script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +test_marker="coverage/.tests-passed-${build_number}" +coverage_marker="coverage/.coverage-ready-${build_number}" + +if [ -f "$test_marker" ] && [ ! -L "$test_marker" ]; then + "$script_dir/ci-coverage-badges.sh" test --value passing +else + "$script_dir/ci-coverage-badges.sh" test --value failing +fi + +if [ ! -f "$coverage_marker" ] || [ -L "$coverage_marker" ]; then + "$script_dir/ci-coverage-badges.sh" coverage --value - +fi + +version=$(awk ' + /^\[workspace.package\]$/ { in_workspace_package = 1; next } + /^\[/ { in_workspace_package = 0 } + in_workspace_package && /^version[[:space:]]*=/ { + value = $0 + sub(/^[^=]*=[[:space:]]*"/, "", value) + sub(/"[[:space:]]*$/, "", value) + print value + exit + } +' Cargo.toml) +[ -n "$version" ] || { + echo 'workspace version is missing from Cargo.toml' >&2 + exit 1 +} +"$script_dir/ci-coverage-badges.sh" version --value "$version" + +rm -f coverage/llvm-cov-summary.json "$test_marker" "$coverage_marker" + +expected='coverage/coverage.svg coverage/test.svg coverage/version.svg' +for badge in $expected; do + [ -f "$badge" ] && [ ! -L "$badge" ] && [ -s "$badge" ] || { + echo "invalid badge artifact: $badge" >&2 + exit 1 + } +done +actual_count=$(find coverage -maxdepth 1 -name '*.svg' | wc -l) +[ "$actual_count" -eq 3 ] || { + echo "expected exactly three SVG badges, found $actual_count" >&2 + exit 1 +} diff --git a/scripts/ci-publish-badges.sh b/scripts/ci-publish-badges.sh new file mode 100755 index 0000000..a1a435e --- /dev/null +++ b/scripts/ci-publish-badges.sh @@ -0,0 +1,106 @@ +#!/bin/sh +set -eu + +usage() { + echo "usage: $0 ROOT OWNER PROJECT DEFAULT_BRANCH BADGE [BADGE ...]" >&2 + exit 2 +} + +[ "$#" -ge 5 ] || usage +root=$1 +owner=$2 +project=$3 +default_branch=$4 +shift 4 + +case "$root" in + /*) ;; + *) echo "publication root must be absolute: $root" >&2; exit 2 ;; +esac +[ -d "$root" ] && [ ! -L "$root" ] && [ -w "$root" ] || { + echo "publication root must be an existing, writable, non-symlink directory: $root" >&2 + exit 2 +} + +validate_component() { + component_name=$1 + component_value=$2 + case "$component_value" in + ''|.|..|*[!A-Za-z0-9._-]*) + echo "$component_name is not a safe path component: $component_value" >&2 + exit 2 + ;; + esac +} + +validate_component owner "$owner" +validate_component project "$project" +validate_component default-branch "$default_branch" + +seen=' ' +for badge_name in "$@"; do + case "$badge_name" in + coverage|test|version) ;; + *) echo "unsupported badge name: $badge_name" >&2; exit 2 ;; + esac + case "$seen" in + *" $badge_name "*) echo "duplicate badge name: $badge_name" >&2; exit 2 ;; + esac + seen="${seen}${badge_name} " + + source_file="coverage/${badge_name}.svg" + [ -f "$source_file" ] && [ ! -L "$source_file" ] && [ -s "$source_file" ] || { + echo "badge source must be a regular, nonempty, non-symlink file: $source_file" >&2 + exit 2 + } +done + +ensure_directory() { + directory=$1 + if [ -e "$directory" ] || [ -L "$directory" ]; then + [ -d "$directory" ] && [ ! -L "$directory" ] || { + echo "publication path component is not a real directory: $directory" >&2 + exit 2 + } + else + mkdir -m 0755 "$directory" + fi + chmod 0755 "$directory" +} + +owner_dir="$root/$owner" +project_dir="$owner_dir/$project" +destination="$project_dir/$default_branch" +ensure_directory "$owner_dir" +ensure_directory "$project_dir" + +if [ -L "$destination" ]; then + unlink "$destination" +elif [ -e "$destination" ] && [ ! -d "$destination" ]; then + echo "default-branch destination is not a directory: $destination" >&2 + exit 2 +fi +ensure_directory "$destination" + +temporary_files= +cleanup() { + for temporary_file in $temporary_files; do + rm -f "$temporary_file" + done +} +trap cleanup EXIT +trap 'cleanup; exit 1' HUP INT TERM + +sequence=0 +for badge_name in "$@"; do + sequence=$((sequence + 1)) + source_file="coverage/${badge_name}.svg" + temporary_file=$(mktemp "$destination/.${badge_name}.svg.tmp.${sequence}.XXXXXX") + temporary_files="$temporary_files $temporary_file" + cp "$source_file" "$temporary_file" + chmod 0644 "$temporary_file" + mv "$temporary_file" "$destination/${badge_name}.svg" +done + +temporary_files= +trap - EXIT HUP INT TERM diff --git a/scripts/ci-run-coverage.sh b/scripts/ci-run-coverage.sh new file mode 100755 index 0000000..2cfea09 --- /dev/null +++ b/scripts/ci-run-coverage.sh @@ -0,0 +1,105 @@ +#!/bin/sh +set -u + +usage() { + echo "usage: $0 MINIMUM SUMMARY READY_MARKER STATUS" >&2 + exit 2 +} + +[ "$#" -eq 4 ] || usage +minimum=$1 +summary=$2 +ready_marker=$3 +status_file=$4 +script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) + +if ! awk -v candidate="$minimum" 'BEGIN { + valid = candidate ~ /^[0-9]+([.][0-9]+)?$/ && candidate >= 0 && candidate <= 100 + exit(valid ? 0 : 1) +}'; then + echo "coverage minimum must be a number from 0 through 100: $minimum" >&2 + exit 2 +fi + +mkdir -p "$(dirname -- "$summary")" "$(dirname -- "$ready_marker")" "$(dirname -- "$status_file")" +rm -f "$summary" "$ready_marker" "$status_file" + +temporary_status="${status_file}.tmp.$$" +cleanup() { + rm -f "$summary" "$temporary_status" +} +trap cleanup EXIT HUP INT TERM + +cargo llvm-cov \ + --workspace \ + --all-targets \ + --all-features \ + --locked \ + --json \ + --summary-only \ + --output-path "$summary" +coverage_exit=$? + +if [ ! -s "$summary" ]; then + diagnostic="Line coverage: unavailable; required minimum: ${minimum}%; reason: cargo llvm-cov exited ${coverage_exit} without a nonempty summary" + printf '%s\n' "$diagnostic" | tee "$temporary_status" + mv "$temporary_status" "$status_file" + echo "Coverage gate: FAIL (measurement unavailable)" + if [ "$coverage_exit" -ne 0 ]; then + exit "$coverage_exit" + fi + exit 1 +fi + +measurement=$(python3 - "$summary" <<'PY' +import json +import math +import sys + +try: + with open(sys.argv[1], encoding="utf-8") as report: + value = json.load(report)["data"][0]["totals"]["lines"]["percent"] + if isinstance(value, bool) or not isinstance(value, (int, float)): + raise ValueError("line percentage is not numeric") + value = float(value) + if not math.isfinite(value) or not 0 <= value <= 100: + raise ValueError("line percentage is outside 0 through 100") + print(format(value, ".12g")) +except (KeyError, IndexError, json.JSONDecodeError, OSError, TypeError, ValueError) as error: + print(f"invalid cargo llvm-cov summary: {error}", file=sys.stderr) + sys.exit(2) +PY +) +parse_exit=$? +if [ "$parse_exit" -ne 0 ]; then + diagnostic="Line coverage: unavailable; required minimum: ${minimum}%; reason: invalid cargo llvm-cov summary" + printf '%s\n' "$diagnostic" | tee "$temporary_status" + mv "$temporary_status" "$status_file" + echo "Coverage gate: FAIL (measurement unavailable)" + exit "$parse_exit" +fi + +diagnostic="Line coverage: ${measurement}%; required minimum: ${minimum}%" +printf '%s\n' "$diagnostic" | tee "$temporary_status" +mv "$temporary_status" "$status_file" + +if ! "$script_dir/ci-coverage-badges.sh" coverage --value "$measurement"; then + echo "Coverage gate: FAIL (badge rendering failed)" + exit 1 +fi +if ! : >"$ready_marker"; then + echo "Coverage gate: FAIL (could not create current-build readiness marker)" + exit 1 +fi + +if [ "$coverage_exit" -ne 0 ]; then + echo "Coverage gate: FAIL (cargo llvm-cov exited $coverage_exit)" + exit "$coverage_exit" +fi +if awk -v actual="$measurement" -v required="$minimum" 'BEGIN { exit(actual >= required ? 0 : 1) }'; then + echo "Coverage gate: PASS" + exit 0 +fi + +echo "Coverage gate: FAIL (below required minimum)" +exit 1 diff --git a/scripts/test-ci.sh b/scripts/test-ci.sh new file mode 100755 index 0000000..9fe28c6 --- /dev/null +++ b/scripts/test-ci.sh @@ -0,0 +1,216 @@ +#!/bin/sh +set -eu + +repository=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +workspace=$(mktemp -d "${TMPDIR:-/tmp}/fader-master-ci-tests.XXXXXX") +trap 'rm -rf "$workspace"' EXIT HUP INT TERM + +fail() { + echo "FAIL: $*" >&2 + exit 1 +} + +assert_contains() { + file=$1 + expected=$2 + grep -F "$expected" "$file" >/dev/null || fail "$file does not contain: $expected" +} + +assert_fails() { + if "$@" >/dev/null 2>&1; then + fail "command unexpectedly succeeded: $*" + fi +} + +renderer="$repository/scripts/ci-coverage-badges.sh" +render_dir="$workspace/render" +mkdir "$render_dir" + +"$renderer" version --value 0.1.0 --output "$render_dir/version.svg" +"$renderer" version --value 1234567890.1234567890-long-version --output "$render_dir/long-version.svg" +"$renderer" version --text 'release & build' --value '0.1.0 ' --size 12 --height 24 \ + --label-width 120 --value-width 100 --color '#8a2be2' --output "$render_dir/custom.svg" +"$renderer" test --value passing --output "$render_dir/passing.svg" +"$renderer" test --value failing --output "$render_dir/failing.svg" +"$renderer" test --value custom --output "$render_dir/custom-test.svg" +"$renderer" coverage --value 0 --output "$render_dir/red.svg" +"$renderer" coverage --value 70 --output "$render_dir/yellow.svg" +"$renderer" coverage --value 90 --output "$render_dir/green.svg" +"$renderer" coverage --value - --output "$render_dir/neutral.svg" + +assert_contains "$render_dir/custom.svg" 'release & build' +assert_contains "$render_dir/custom.svg" '0.1.0 <rc>' +assert_contains "$render_dir/passing.svg" '#4c1' +assert_contains "$render_dir/failing.svg" '#e05d44' +assert_contains "$render_dir/custom-test.svg" '#9f9f9f' +assert_contains "$render_dir/red.svg" '#e05d44' +assert_contains "$render_dir/yellow.svg" '#dfb317' +assert_contains "$render_dir/green.svg" '#4c1' +assert_contains "$render_dir/neutral.svg" '#9f9f9f' + +python3 - "$render_dir" <<'PY' +import pathlib +import sys +import xml.etree.ElementTree as ET + +for badge in pathlib.Path(sys.argv[1]).glob("*.svg"): + ET.parse(badge) +PY + +printf 'keep\n' >"$render_dir/protected.svg" +assert_fails "$renderer" invalid --output "$render_dir/protected.svg" +assert_fails "$renderer" coverage --value 101 --output "$render_dir/protected.svg" +assert_fails "$renderer" version --value ok --size 5 --output "$render_dir/protected.svg" +assert_fails "$renderer" version --value ok --height 65 --output "$render_dir/protected.svg" +assert_fails "$renderer" version --value ok --label-width 19 --output "$render_dir/protected.svg" +assert_fails "$renderer" version --value ok --color red --output "$render_dir/protected.svg" +assert_fails "$renderer" version --value ok --unknown value --output "$render_dir/protected.svg" +[ "$(cat "$render_dir/protected.svg")" = keep ] || fail 'invalid rendering replaced an existing output' + +fake_bin="$workspace/fake-bin" +mkdir "$fake_bin" +cat >"$fake_bin/cargo" <<'EOF' +#!/bin/sh +set -eu +output= +while [ "$#" -gt 0 ]; do + if [ "$1" = --output-path ]; then + output=$2 + shift 2 + else + shift + fi +done +if [ "${FAKE_REPORT:-valid}" = missing ]; then + exit "${FAKE_EXIT:-0}" +fi +if [ "${FAKE_REPORT:-valid}" = invalid ]; then + printf '%s\n' '{not-json' >"$output" +else + printf '{"data":[{"totals":{"lines":{"percent":%s}}}]}\n' "${FAKE_PERCENT:-80}" >"$output" +fi +exit "${FAKE_EXIT:-0}" +EOF +chmod +x "$fake_bin/cargo" + +run_coverage_case() { + case_name=$1 + percent=$2 + tool_exit=$3 + report_kind=$4 + expected_exit=$5 + case_dir="$workspace/coverage-$case_name" + mkdir "$case_dir" + if ( + cd "$case_dir" + PATH="$fake_bin:$PATH" FAKE_PERCENT="$percent" FAKE_EXIT="$tool_exit" FAKE_REPORT="$report_kind" \ + "$repository/scripts/ci-run-coverage.sh" 80 summary.json ready status.txt >output.txt 2>&1 + ); then + actual_exit=0 + else + actual_exit=$? + fi + [ "$actual_exit" -eq "$expected_exit" ] || fail "$case_name returned $actual_exit, expected $expected_exit" +} + +run_coverage_case above 80.01 0 valid 0 +run_coverage_case exact 80 0 valid 0 +run_coverage_case below 79.99 0 valid 1 +run_coverage_case tool-failure 82 7 valid 7 +run_coverage_case invalid 0 0 invalid 2 +run_coverage_case missing 0 0 missing 1 + +for case_name in above exact below tool-failure; do + [ -f "$workspace/coverage-$case_name/ready" ] || fail "$case_name did not create its ready marker" + [ -s "$workspace/coverage-$case_name/coverage/coverage.svg" ] || fail "$case_name did not render coverage" + measurement_line=$(grep -n '^Line coverage:' "$workspace/coverage-$case_name/output.txt" | cut -d: -f1) + gate_line=$(grep -n '^Coverage gate:' "$workspace/coverage-$case_name/output.txt" | cut -d: -f1) + [ "$measurement_line" -lt "$gate_line" ] || fail "$case_name printed its decision before its measurement" +done +for case_name in invalid missing; do + [ ! -e "$workspace/coverage-$case_name/ready" ] || fail "$case_name created a ready marker" + assert_contains "$workspace/coverage-$case_name/status.txt" 'Line coverage: unavailable' +done +assert_contains "$workspace/coverage-below/output.txt" 'Coverage gate: FAIL (below required minimum)' +assert_contains "$workspace/coverage-tool-failure/output.txt" 'Coverage gate: FAIL (cargo llvm-cov exited 7)' + +finalize_work="$workspace/finalize-work" +mkdir -p "$finalize_work/coverage" +cat >"$finalize_work/Cargo.toml" <<'EOF' +[workspace] +members = [] + +[workspace.package] +version = "1.2.3" +EOF +printf 'stale\n' >"$finalize_work/coverage/coverage.svg" +: >"$finalize_work/coverage/.tests-passed-local" +( + cd "$finalize_work" + "$repository/scripts/ci-finalize-badges.sh" local +) +assert_contains "$finalize_work/coverage/coverage.svg" '#9f9f9f' +assert_contains "$finalize_work/coverage/test.svg" 'passing' +assert_contains "$finalize_work/coverage/version.svg" '1.2.3' +[ ! -e "$finalize_work/coverage/.tests-passed-local" ] || fail 'test marker survived finalization' +[ "$(find "$finalize_work/coverage" -maxdepth 1 -name '*.svg' | wc -l)" -eq 3 ] \ + || fail 'finalization did not leave exactly three SVG files' + +printf 'fresh measurement\n' >"$finalize_work/coverage/coverage.svg" +: >"$finalize_work/coverage/.coverage-ready-next" +( + cd "$finalize_work" + "$repository/scripts/ci-finalize-badges.sh" next +) +assert_contains "$finalize_work/coverage/coverage.svg" 'fresh measurement' +assert_contains "$finalize_work/coverage/test.svg" 'failing' + +publish_work="$workspace/publish-work" +publish_root="$workspace/publish-root" +mkdir -p "$publish_work/coverage" "$publish_root" +for badge_name in coverage test version; do + printf '%s\n' "$badge_name" >"$publish_work/coverage/$badge_name.svg" +done +( + cd "$publish_work" + umask 077 + "$repository/scripts/ci-publish-badges.sh" "$publish_root" MadGobblins fader_master main coverage test version + "$repository/scripts/ci-publish-badges.sh" "$publish_root" MadGobblins fader_master main coverage test version +) +destination="$publish_root/MadGobblins/fader_master/main" +[ "$(stat -c '%a' "$publish_root/MadGobblins")" = 755 ] || fail 'owner mode is not 0755' +[ "$(stat -c '%a' "$publish_root/MadGobblins/fader_master")" = 755 ] || fail 'project mode is not 0755' +[ "$(stat -c '%a' "$destination")" = 755 ] || fail 'branch mode is not 0755' +for badge_name in coverage test version; do + [ "$(stat -c '%a' "$destination/$badge_name.svg")" = 644 ] || fail "$badge_name mode is not 0644" +done + +assert_fails sh -c "cd '$publish_work' && '$repository/scripts/ci-publish-badges.sh' '$publish_root' MadGobblins fader_master main coverage coverage" +assert_fails sh -c "cd '$publish_work' && '$repository/scripts/ci-publish-badges.sh' relative MadGobblins fader_master main coverage" +assert_fails sh -c "cd '$publish_work' && '$repository/scripts/ci-publish-badges.sh' '$publish_root' MadGobblins fader_master main unknown" +ln -s "$workspace/outside" "$publish_work/coverage/test.svg.link" +mv "$publish_work/coverage/test.svg" "$publish_work/coverage/test.svg.real" +ln -s test.svg.real "$publish_work/coverage/test.svg" +assert_fails sh -c "cd '$publish_work' && '$repository/scripts/ci-publish-badges.sh' '$publish_root' MadGobblins fader_master main test" +unlink "$publish_work/coverage/test.svg" +mv "$publish_work/coverage/test.svg.real" "$publish_work/coverage/test.svg" + +symlink_root="$workspace/symlink-root" +mkdir "$symlink_root" +ln -s "$workspace/outside-owner" "$symlink_root/MadGobblins" +assert_fails sh -c "cd '$publish_work' && '$repository/scripts/ci-publish-badges.sh' '$symlink_root' MadGobblins fader_master main coverage" + +migration_root="$workspace/migration-root" +old_target="$workspace/old-badges" +mkdir -p "$migration_root/MadGobblins/fader_master" "$old_target" +printf 'preserve\n' >"$old_target/sentinel" +ln -s "$old_target" "$migration_root/MadGobblins/fader_master/main" +( + cd "$publish_work" + "$repository/scripts/ci-publish-badges.sh" "$migration_root" MadGobblins fader_master main coverage test version +) +[ -f "$old_target/sentinel" ] || fail 'old symlink target was modified during migration' +[ -d "$migration_root/MadGobblins/fader_master/main" ] && [ ! -L "$migration_root/MadGobblins/fader_master/main" ] \ + || fail 'old default-branch symlink was not migrated safely' + +echo 'CI script tests passed.' diff --git a/task.md b/task.md index 786e5a1..4bff424 100644 --- a/task.md +++ b/task.md @@ -19,6 +19,7 @@ Dependencies: planning. - [ ] **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. +- [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. - [ ] **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. ## M1 — Domain state and virtual objects