-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1012,6 +1012,7 @@ jobs: | |
components: llvm-tools-preview | ||
- uses: taiki-e/install-action@nextest | ||
- uses: taiki-e/install-action@grcov | ||
- uses: taiki-e/install-action@cargo-llvm-cov | ||
- uses: Swatinem/rust-cache@v2 | ||
- name: Run sccache-cache | ||
uses: mozilla-actions/[email protected] | ||
|
@@ -1023,29 +1024,37 @@ jobs: | |
run: | | ||
## VARs setup | ||
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } | ||
# toolchain | ||
TOOLCHAIN="nightly" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support | ||
# * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files | ||
case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac; | ||
# * use requested TOOLCHAIN if specified | ||
if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi | ||
outputs TOOLCHAIN | ||
# target-specific options | ||
# * CARGO_FEATURES_OPTION | ||
CARGO_FEATURES_OPTION='--all-features' ; ## default to '--all-features' for code coverage | ||
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi | ||
outputs CARGO_FEATURES_OPTION | ||
# * CODECOV_FLAGS | ||
CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' ) | ||
outputs CODECOV_FLAGS | ||
- name: Install/setup prerequisites | ||
shell: bash | ||
run: | | ||
## Install/setup prerequisites | ||
case '${{ matrix.job.os }}' in | ||
macos-latest) brew install coreutils ;; # needed for testing | ||
esac | ||
case '${{ matrix.job.os }}' in | ||
macos-latest) | ||
# needed for testing | ||
brew install coreutils | ||
;; | ||
ubuntu-latest) | ||
# pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd. | ||
# In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands. The account also has empty gecos fields. | ||
|
@@ -1059,11 +1068,13 @@ jobs: | |
touch /home/runner/.project | ||
echo "foo" > /home/runner/.plan | ||
;; | ||
windows-latest) | ||
# Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368 | ||
C:/msys64/usr/bin/pacman.exe -Sy --needed mingw-w64-x86_64-gcc --noconfirm ; echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH | ||
;; | ||
esac | ||
case '${{ matrix.job.os }}' in | ||
# Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368 | ||
windows-latest) C:/msys64/usr/bin/pacman.exe -Sy --needed mingw-w64-x86_64-gcc --noconfirm ; echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH ;; | ||
esac | ||
- name: Initialize toolchain-dependent workflow variables | ||
id: dep_vars | ||
shell: bash | ||
|
@@ -1072,32 +1083,43 @@ jobs: | |
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } | ||
df -h . | ||
df -h ${{ github.workspace }} | ||
# * determine sub-crate utility list | ||
UTILITY_LIST="$(./util/show-utils.sh ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }})" | ||
CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo -n "-puu_${u} "; done;)" | ||
df -h | ||
outputs CARGO_UTILITY_LIST_OPTIONS | ||
- name: Test | ||
run: | | ||
df -h | ||
cargo nextest run --profile ci --hide-progress-bar ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} -p uucore -p coreutils | ||
df -h | ||
# Run the tests and generate a report | ||
cargo llvm-cov \ | ||
--no-cfg-coverage \ | ||
--no-cfg-coverage-nightly \ | ||
--no-report \ | ||
nextest \ | ||
--profile coverage \ | ||
${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} \ | ||
-p uucore \ | ||
-p coreutils \\ | ||
|| true # Always exit 0 | ||
env: | ||
RUSTC_WRAPPER: "" | ||
RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" | ||
RUSTDOCFLAGS: "-Cpanic=abort" | ||
RUST_BACKTRACE: "1" | ||
LLVM_PROFILE_FILE: "${{ github.workspace }}/build/coverage-%m.profraw" | ||
# RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }} | ||
- name: Test individual utilities | ||
run: cargo nextest run --profile ci --hide-progress-bar ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }} | ||
env: | ||
RUSTC_WRAPPER: "" | ||
RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" | ||
RUSTDOCFLAGS: "-Cpanic=abort" | ||
LLVM_PROFILE_FILE: "${{ github.workspace }}/build/coverage-%m.profraw" | ||
RUST_BACKTRACE: "1" | ||
# RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }} | ||
|
||
# - name: Test individual utilities | ||
# run: cargo nextest run --profile ci --hide-progress-bar ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }} | ||
# env: | ||
# RUSTC_WRAPPER: "" | ||
# RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" | ||
# RUSTDOCFLAGS: "-Cpanic=abort" | ||
# LLVM_PROFILE_FILE: "${{ github.workspace }}/build/coverage-%m.profraw" | ||
# RUST_BACKTRACE: "1" | ||
# # RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }} | ||
|
||
- name: Generate coverage data (via `grcov`) | ||
id: coverage | ||
shell: bash | ||
|
@@ -1106,14 +1128,17 @@ jobs: | |
COVERAGE_REPORT_DIR="target/debug" | ||
COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info" | ||
mkdir -p "${COVERAGE_REPORT_DIR}" | ||
# display coverage files (for debug) | ||
du -h ${{ github.workspace }}/build/ | ||
grcov --version | ||
ls -al target/ | ||
ls -al target/debug | ||
# generate coverage report | ||
grcov ${{ github.workspace }}/build/ --output-type lcov -b target/debug/ --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" | ||
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT | ||
- name: Upload coverage results (to Codecov.io) | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
|