Skip to content

Commit ab91264

Browse files
committed
test-ci
1 parent 9020634 commit ab91264

1 file changed

Lines changed: 45 additions & 20 deletions

File tree

.github/workflows/CICD.yml

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ jobs:
993993
components: llvm-tools-preview
994994
- uses: taiki-e/install-action@nextest
995995
- uses: taiki-e/install-action@grcov
996+
- uses: taiki-e/install-action@cargo-llvm-cov
996997
- uses: Swatinem/rust-cache@v2
997998
- name: Run sccache-cache
998999
uses: mozilla-actions/sccache-action@v0.0.6
@@ -1004,29 +1005,37 @@ jobs:
10041005
run: |
10051006
## VARs setup
10061007
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
1008+
10071009
# toolchain
10081010
TOOLCHAIN="nightly" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support
1011+
10091012
# * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files
10101013
case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac;
1014+
10111015
# * use requested TOOLCHAIN if specified
10121016
if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
10131017
outputs TOOLCHAIN
1018+
10141019
# target-specific options
10151020
# * CARGO_FEATURES_OPTION
10161021
CARGO_FEATURES_OPTION='--all-features' ; ## default to '--all-features' for code coverage
10171022
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi
10181023
outputs CARGO_FEATURES_OPTION
1024+
10191025
# * CODECOV_FLAGS
10201026
CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
10211027
outputs CODECOV_FLAGS
1028+
10221029
- name: Install/setup prerequisites
10231030
shell: bash
10241031
run: |
10251032
## Install/setup prerequisites
10261033
case '${{ matrix.job.os }}' in
1027-
macos-latest) brew install coreutils ;; # needed for testing
1028-
esac
1029-
case '${{ matrix.job.os }}' in
1034+
macos-latest)
1035+
# needed for testing
1036+
brew install coreutils
1037+
;;
1038+
10301039
ubuntu-latest)
10311040
# pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
10321041
# In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands. The account also has empty gecos fields.
@@ -1040,11 +1049,13 @@ jobs:
10401049
touch /home/runner/.project
10411050
echo "foo" > /home/runner/.plan
10421051
;;
1052+
1053+
windows-latest)
1054+
# Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368
1055+
C:/msys64/usr/bin/pacman.exe -Sy --needed mingw-w64-x86_64-gcc --noconfirm ; echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
1056+
;;
10431057
esac
1044-
case '${{ matrix.job.os }}' in
1045-
# Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368
1046-
windows-latest) C:/msys64/usr/bin/pacman.exe -Sy --needed mingw-w64-x86_64-gcc --noconfirm ; echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH ;;
1047-
esac
1058+
10481059
- name: Initialize toolchain-dependent workflow variables
10491060
id: dep_vars
10501061
shell: bash
@@ -1053,32 +1064,43 @@ jobs:
10531064
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
10541065
df -h .
10551066
df -h ${{ github.workspace }}
1067+
10561068
# * determine sub-crate utility list
10571069
UTILITY_LIST="$(./util/show-utils.sh ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }})"
10581070
CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo -n "-puu_${u} "; done;)"
10591071
df -h
10601072
outputs CARGO_UTILITY_LIST_OPTIONS
1073+
10611074
- name: Test
10621075
run: |
1063-
df -h
1064-
cargo nextest run --profile ci --hide-progress-bar ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} -p uucore -p coreutils
1065-
df -h
1076+
# Run the tests and generate a report
1077+
cargo llvm-cov \
1078+
--no-cfg-coverage \
1079+
--no-cfg-coverage-nightly \
1080+
--no-report \
1081+
nextest \
1082+
--profile ci \
1083+
--hide-progress-bar \
1084+
${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} \
1085+
-p uucore \
1086+
-p coreutils
10661087
env:
1067-
RUSTC_WRAPPER: ""
10681088
RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
10691089
RUSTDOCFLAGS: "-Cpanic=abort"
10701090
RUST_BACKTRACE: "1"
10711091
LLVM_PROFILE_FILE: "${{ github.workspace }}/build/coverage-%m.profraw"
10721092
# RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }}
1073-
- name: Test individual utilities
1074-
run: cargo nextest run --profile ci --hide-progress-bar ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }}
1075-
env:
1076-
RUSTC_WRAPPER: ""
1077-
RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
1078-
RUSTDOCFLAGS: "-Cpanic=abort"
1079-
LLVM_PROFILE_FILE: "${{ github.workspace }}/build/coverage-%m.profraw"
1080-
RUST_BACKTRACE: "1"
1081-
# RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }}
1093+
1094+
# - name: Test individual utilities
1095+
# run: cargo nextest run --profile ci --hide-progress-bar ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }}
1096+
# env:
1097+
# RUSTC_WRAPPER: ""
1098+
# RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
1099+
# RUSTDOCFLAGS: "-Cpanic=abort"
1100+
# LLVM_PROFILE_FILE: "${{ github.workspace }}/build/coverage-%m.profraw"
1101+
# RUST_BACKTRACE: "1"
1102+
# # RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }}
1103+
10821104
- name: Generate coverage data (via `grcov`)
10831105
id: coverage
10841106
shell: bash
@@ -1087,14 +1109,17 @@ jobs:
10871109
COVERAGE_REPORT_DIR="target/debug"
10881110
COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info"
10891111
mkdir -p "${COVERAGE_REPORT_DIR}"
1112+
10901113
# display coverage files (for debug)
10911114
du -h ${{ github.workspace }}/build/
10921115
grcov --version
10931116
ls -al target/
10941117
ls -al target/debug
1118+
10951119
# generate coverage report
10961120
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\()"
10971121
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
1122+
10981123
- name: Upload coverage results (to Codecov.io)
10991124
uses: codecov/codecov-action@v4
11001125
with:

0 commit comments

Comments
 (0)