@@ -2,7 +2,7 @@ name: CICD
22
33# spell-checker:ignore (abbrev/names) CICD CodeCOV MacOS MinGW MSVC musl taiki
44# spell-checker:ignore (env/flags) Awarnings Ccodegen Coverflow Cpanic Dwarnings RUSTDOCFLAGS RUSTFLAGS Zpanic CARGOFLAGS
5- # spell-checker:ignore (jargon) SHAs deps dequote softprops subshell toolchain fuzzers dedupe devel
5+ # spell-checker:ignore (jargon) SHAs deps dequote softprops subshell toolchain fuzzers dedupe devel profdata
66# spell-checker:ignore (people) Peltoche rivy dtolnay Anson dawidd
77# spell-checker:ignore (shell/tools) binutils choco clippy dmake dpkg esac fakeroot fdesc fdescfs gmake grcov halium lcov libclang libfuse libssl limactl mkdir nextest nocross pacman popd printf pushd redoxer rsync rustc rustfmt rustup shopt sccache utmpdump xargs
88# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos getenforce gnueabihf issuecomment maint manpages msys multisize noconfirm nullglob onexitbegin onexitend pell runtest Swatinem tempfile testsuite toybox uutils
@@ -190,12 +190,14 @@ jobs:
190190 unset CARGO_FEATURES_OPTION
191191 if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi
192192 outputs CARGO_FEATURES_OPTION
193- - name : Confirm MinSRV compatible 'Cargo.lock'
193+ - name : Confirm MinSRV compatible '*/ Cargo.lock'
194194 shell : bash
195195 run : |
196- ## Confirm MinSRV compatible 'Cargo.lock'
197- # * 'Cargo.lock' is required to be in a format that `cargo` of MinSRV can interpret (eg, v1-format for MinSRV < v1.38)
198- cargo fetch --locked --quiet || { echo "::error file=Cargo.lock::Incompatible (or out-of-date) 'Cargo.lock' file; update using \`cargo +${{ env.RUST_MIN_SRV }} update\`" ; exit 1 ; }
196+ ## Confirm MinSRV compatible '*/Cargo.lock'
197+ # * '*/Cargo.lock' is required to be in a format that `cargo` of MinSRV can interpret (eg, v1-format for MinSRV < v1.38)
198+ for dir in "." "fuzz"; do
199+ ( cd "$dir" && cargo fetch --locked --quiet ) || { echo "::error file=$dir/Cargo.lock::Incompatible (or out-of-date) '$dir/Cargo.lock' file; update using \`cd '$dir' && cargo +${{ env.RUST_MIN_SRV }} update\`" ; exit 1 ; }
200+ done
199201 - name : Install/setup prerequisites
200202 shell : bash
201203 run : |
@@ -246,7 +248,9 @@ jobs:
246248 run : |
247249 ## `cargo update` testing
248250 # * convert any errors/warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
249- cargo fetch --locked --quiet || { echo "::error file=Cargo.lock::'Cargo.lock' file requires update (use \`cargo +${{ env.RUST_MIN_SRV }} update\`)" ; exit 1 ; }
251+ for dir in "." "fuzz"; do
252+ ( cd "$dir" && cargo fetch --locked --quiet ) || { echo "::error file=$dir/Cargo.lock::'$dir/Cargo.lock' file requires update (use \`cd '$dir' && cargo +${{ env.RUST_MIN_SRV }} update\`)" ; exit 1 ; }
253+ done
250254
251255 build_makefile :
252256 name : Build/Makefile
@@ -509,23 +513,25 @@ jobs:
509513 fail-fast : false
510514 matrix :
511515 job :
512- # - { os , target , cargo-options , features , use-cross , toolchain, skip-tests, workspace-tests }
516+ # - { os , target , cargo-options , default- features, features , use-cross , toolchain, skip-tests, workspace-tests, skip-package, skip-publish }
513517 - { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , features: feat_os_unix_gnueabihf , use-cross: use-cross , skip-tests: true }
514518 - { os: ubuntu-24.04-arm , target: aarch64-unknown-linux-gnu , features: feat_os_unix_gnueabihf }
515- - { os: ubuntu-latest , target: aarch64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross , skip-tests: true }
519+ - { os: ubuntu-latest , target: aarch64-unknown-linux-musl , features: feat_os_unix , use-cross: use-cross , skip-tests: true }
516520 # - { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: feat_selinux , use-cross: use-cross }
517521 - { os: ubuntu-latest , target: i686-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross }
518- - { os: ubuntu-latest , target: i686-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
522+ - { os: ubuntu-latest , target: i686-unknown-linux-musl , features: feat_os_unix , use-cross: use-cross }
519523 - { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross }
520524 - { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,uudoc" , use-cross: no, workspace-tests: true }
521- - { os: ubuntu-latest , target: x86_64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
525+ - { os: ubuntu-latest , target: x86_64-unknown-linux-musl , features: feat_os_unix , use-cross: use-cross }
522526 - { os: ubuntu-latest , target: x86_64-unknown-redox , features: feat_os_unix_redox , use-cross: redoxer , skip-tests: true }
527+ - { os: ubuntu-latest , target: wasm32-unknown-unknown , default-features: false, features: uucore/format, skip-tests: true, skip-package: true, skip-publish: true }
523528 - { os: macos-latest , target: aarch64-apple-darwin , features: feat_os_macos, workspace-tests: true } # M1 CPU
524529 - { os: macos-13 , target: x86_64-apple-darwin , features: feat_os_macos, workspace-tests: true }
525530 - { os: windows-latest , target: i686-pc-windows-msvc , features: feat_os_windows }
526- - { os: windows-latest , target: x86_64-pc-windows-gnu , features: feat_os_windows }
531+ # TODO: Re-enable after rust-onig release: https://github.com/rust-onig/rust-onig/issues/193
532+ # - { os: windows-latest , target: x86_64-pc-windows-gnu , features: feat_os_windows }
527533 - { os: windows-latest , target: x86_64-pc-windows-msvc , features: feat_os_windows }
528- - { os: windows-latest , target: aarch64-pc-windows-msvc , features: feat_os_windows, use-cross: use-cross , skip-tests: true }
534+ - { os: windows-latest , target: aarch64-pc-windows-msvc , features: feat_os_windows, use-cross: use-cross , skip-tests: true }
529535 steps :
530536 - uses : actions/checkout@v4
531537 with :
@@ -615,6 +621,10 @@ jobs:
615621 CARGO_FEATURES_OPTION='' ;
616622 if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi
617623 outputs CARGO_FEATURES_OPTION
624+ # * CARGO_DEFAULT_FEATURES_OPTION
625+ CARGO_DEFAULT_FEATURES_OPTION='' ;
626+ if [ "${{ matrix.job.default-features }}" == "false" ]; then CARGO_DEFAULT_FEATURES_OPTION='--no-default-features' ; fi
627+ outputs CARGO_DEFAULT_FEATURES_OPTION
618628 # * CARGO_CMD
619629 CARGO_CMD='cross'
620630 CARGO_CMD_OPTIONS='+${{ env.RUST_MIN_SRV }}'
@@ -748,20 +758,20 @@ jobs:
748758 # dependencies
749759 echo "## dependency list"
750760 cargo fetch --locked --quiet
751- cargo tree --locked --target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --no-dedupe -e=no-dev --prefix=none | grep -vE "$PWD" | sort --unique
761+ cargo tree --locked --target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} ${{ steps.vars.outputs.CARGO_DEFAULT_FEATURES_OPTION }} --no-dedupe -e=no-dev --prefix=none | grep -vE "$PWD" | sort --unique
752762 - name : Build
753763 shell : bash
754764 run : |
755765 ## Build
756766 ${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} build --release \
757- --target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
767+ --target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} ${{ steps.vars.outputs.CARGO_DEFAULT_FEATURES_OPTION }}
758768 - name : Test
759769 if : matrix.job.skip-tests != true
760770 shell : bash
761771 run : |
762772 ## Test
763773 ${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} test --target=${{ matrix.job.target }} \
764- ${{ steps.vars.outputs.CARGO_TEST_OPTIONS}} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
774+ ${{ steps.vars.outputs.CARGO_TEST_OPTIONS}} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} ${{ steps.vars.outputs.CARGO_DEFAULT_FEATURES_OPTION }}
765775 env :
766776 RUST_BACKTRACE : " 1"
767777 - name : Test individual utilities
@@ -779,6 +789,7 @@ jobs:
779789 name : ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}${{ steps.vars.outputs.ARTIFACTS_SUFFIX }}
780790 path : target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}
781791 - name : Package
792+ if : matrix.job.skip-package != true
782793 shell : bash
783794 run : |
784795 ## Package artifact(s)
@@ -814,7 +825,7 @@ jobs:
814825 fi
815826 - name : Publish
816827 uses : softprops/action-gh-release@v2
817- if : steps.vars.outputs.DEPLOY
828+ if : steps.vars.outputs.DEPLOY && matrix.job.skip-publish != true
818829 with :
819830 draft : true
820831 files : |
@@ -997,6 +1008,123 @@ jobs:
9971008 name : toybox-result.json
9981009 path : ${{ steps.vars.outputs.TEST_SUMMARY_FILE }}
9991010
1011+ coverage :
1012+ name : Code Coverage
1013+ runs-on : ${{ matrix.job.os }}
1014+ timeout-minutes : 90
1015+ env :
1016+ SCCACHE_GHA_ENABLED : " true"
1017+ RUSTC_WRAPPER : " sccache"
1018+ strategy :
1019+ fail-fast : false
1020+ matrix :
1021+ job :
1022+ - { os: ubuntu-latest , features: unix, toolchain: nightly }
1023+ # FIXME: Re-enable macos code coverage
1024+ # - { os: macos-latest , features: macos, toolchain: nightly }
1025+ # FIXME: Re-enable Code Coverage on windows, which currently fails due to "profiler_builtins". See #6686.
1026+ # - { os: windows-latest , features: windows, toolchain: nightly-x86_64-pc-windows-gnu }
1027+ steps :
1028+ - uses : actions/checkout@v4
1029+ - uses : dtolnay/rust-toolchain@master
1030+ with :
1031+ toolchain : ${{ matrix.job.toolchain }}
1032+ components : rustfmt
1033+ - uses : taiki-e/install-action@v2
1034+ with :
1035+ 1036+ - uses : Swatinem/rust-cache@v2
1037+
1038+ - name : Run sccache-cache
1039+ uses :
mozilla-actions/[email protected] 1040+
1041+ # - name: Reattach HEAD ## may be needed for accurate code coverage info
1042+ # run: git checkout ${{ github.head_ref }}
1043+
1044+ - name : Initialize workflow variables
1045+ id : vars
1046+ shell : bash
1047+ run : |
1048+ ## VARs setup
1049+ outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
1050+
1051+ # toolchain
1052+ TOOLCHAIN="nightly" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support
1053+
1054+ # * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files
1055+ case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac;
1056+
1057+ # * use requested TOOLCHAIN if specified
1058+ if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
1059+ outputs TOOLCHAIN
1060+
1061+ # target-specific options
1062+
1063+ # * CARGO_FEATURES_OPTION
1064+ CARGO_FEATURES_OPTION='--all-features' ; ## default to '--all-features' for code coverage
1065+ if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi
1066+ outputs CARGO_FEATURES_OPTION
1067+
1068+ # * CODECOV_FLAGS
1069+ CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
1070+ outputs CODECOV_FLAGS
1071+
1072+ - name : Install/setup prerequisites
1073+ shell : bash
1074+ run : |
1075+ ## Install/setup prerequisites
1076+ case '${{ matrix.job.os }}' in
1077+ macos-latest) brew install coreutils ;; # needed for testing
1078+ esac
1079+
1080+ case '${{ matrix.job.os }}' in
1081+ ubuntu-latest)
1082+ # pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
1083+ # In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands. The account also has empty gecos fields.
1084+ # To work around this for pinky tests, we create a fake login entry for the GH runner account...
1085+ FAKE_UTMP='[7] [999999] [tty2] [runner] [tty2] [] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]'
1086+ # ... by dumping the login records, adding our fake line, then reverse dumping ...
1087+ (utmpdump /var/run/utmp ; echo $FAKE_UTMP) | sudo utmpdump -r -o /var/run/utmp
1088+ # ... and add a full name to each account with a gecos field but no full name.
1089+ sudo sed -i 's/:,/:runner name,/' /etc/passwd
1090+ # We also create a couple optional files pinky looks for
1091+ touch /home/runner/.project
1092+ echo "foo" > /home/runner/.plan
1093+ ;;
1094+ esac
1095+
1096+ case '${{ matrix.job.os }}' in
1097+ # Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368
1098+ windows-latest) C:/msys64/usr/bin/pacman.exe -Sy --needed mingw-w64-x86_64-gcc --noconfirm ; echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH ;;
1099+ esac
1100+
1101+ ## Install the llvm-tools component to get access to `llvm-profdata`
1102+ rustup component add llvm-tools
1103+
1104+ - name : Run test and coverage
1105+ id : run_test_cov
1106+ run : |
1107+ outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
1108+
1109+ # Run the coverage script
1110+ ./util/build-run-test-coverage-linux.sh
1111+
1112+ outputs REPORT_FILE
1113+ env :
1114+ COVERAGE_DIR : ${{ github.workspace }}/coverage
1115+ FEATURES_OPTION : ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
1116+ # RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }}
1117+
1118+ - name : Upload coverage results (to Codecov.io)
1119+ uses : codecov/codecov-action@v5
1120+ with :
1121+ token : ${{ secrets.CODECOV_TOKEN }}
1122+ file : ${{ steps.run_test_cov.outputs.report }}
1123+ # # flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }}
1124+ flags : ${{ steps.vars.outputs.CODECOV_FLAGS }}
1125+ name : codecov-umbrella
1126+ fail_ci_if_error : false
1127+
10001128 test_separately :
10011129 name : Separate Builds
10021130 runs-on : ${{ matrix.os }}
@@ -1067,7 +1195,7 @@ jobs:
10671195 - run : rsync -v -a -e ssh . lima-default:~/work/
10681196 - name : Setup Rust and other build deps in VM
10691197 run : |
1070- lima sudo dnf install gcc g++ git rustup libselinux-devel clang-devel -y
1198+ lima sudo dnf install gcc g++ git rustup libselinux-devel clang-devel attr -y
10711199 lima rustup-init -y --default-toolchain stable
10721200 - name : Verify SELinux Status
10731201 run : |
@@ -1077,3 +1205,5 @@ jobs:
10771205 run : |
10781206 lima ls
10791207 lima bash -c "cd work && cargo test --features 'feat_selinux'"
1208+ - name : Lint with SELinux
1209+ run : lima bash -c "cd work && cargo clippy --all-targets --features 'feat_selinux' -- -D warnings"
0 commit comments