Skip to content

Commit 4f801c9

Browse files
committed
test-ci
1 parent d8616ef commit 4f801c9

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

.github/workflows/CICD.yml

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ jobs:
10121012
components: llvm-tools-preview
10131013
- uses: taiki-e/install-action@nextest
10141014
- uses: taiki-e/install-action@grcov
1015+
- uses: taiki-e/install-action@cargo-llvm-cov
10151016
- uses: Swatinem/rust-cache@v2
10161017
- name: Run sccache-cache
10171018
uses: mozilla-actions/sccache-action@v0.0.6
@@ -1023,29 +1024,37 @@ jobs:
10231024
run: |
10241025
## VARs setup
10251026
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
1027+
10261028
# toolchain
10271029
TOOLCHAIN="nightly" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support
1030+
10281031
# * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files
10291032
case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac;
1033+
10301034
# * use requested TOOLCHAIN if specified
10311035
if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
10321036
outputs TOOLCHAIN
1037+
10331038
# target-specific options
10341039
# * CARGO_FEATURES_OPTION
10351040
CARGO_FEATURES_OPTION='--all-features' ; ## default to '--all-features' for code coverage
10361041
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi
10371042
outputs CARGO_FEATURES_OPTION
1043+
10381044
# * CODECOV_FLAGS
10391045
CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
10401046
outputs CODECOV_FLAGS
1047+
10411048
- name: Install/setup prerequisites
10421049
shell: bash
10431050
run: |
10441051
## Install/setup prerequisites
10451052
case '${{ matrix.job.os }}' in
1046-
macos-latest) brew install coreutils ;; # needed for testing
1047-
esac
1048-
case '${{ matrix.job.os }}' in
1053+
macos-latest)
1054+
# needed for testing
1055+
brew install coreutils
1056+
;;
1057+
10491058
ubuntu-latest)
10501059
# pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
10511060
# 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:
10591068
touch /home/runner/.project
10601069
echo "foo" > /home/runner/.plan
10611070
;;
1071+
1072+
windows-latest)
1073+
# Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368
1074+
C:/msys64/usr/bin/pacman.exe -Sy --needed mingw-w64-x86_64-gcc --noconfirm ; echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
1075+
;;
10621076
esac
1063-
case '${{ matrix.job.os }}' in
1064-
# Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368
1065-
windows-latest) C:/msys64/usr/bin/pacman.exe -Sy --needed mingw-w64-x86_64-gcc --noconfirm ; echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH ;;
1066-
esac
1077+
10671078
- name: Initialize toolchain-dependent workflow variables
10681079
id: dep_vars
10691080
shell: bash
@@ -1072,32 +1083,43 @@ jobs:
10721083
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
10731084
df -h .
10741085
df -h ${{ github.workspace }}
1086+
10751087
# * determine sub-crate utility list
10761088
UTILITY_LIST="$(./util/show-utils.sh ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }})"
10771089
CARGO_UTILITY_LIST_OPTIONS="$(for u in ${UTILITY_LIST}; do echo -n "-puu_${u} "; done;)"
10781090
df -h
10791091
outputs CARGO_UTILITY_LIST_OPTIONS
1092+
10801093
- name: Test
10811094
run: |
1082-
df -h
1083-
cargo nextest run --profile ci --hide-progress-bar ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} -p uucore -p coreutils
1084-
df -h
1095+
# Run the tests and generate a report
1096+
cargo llvm-cov \
1097+
--no-cfg-coverage \
1098+
--no-cfg-coverage-nightly \
1099+
--no-report \
1100+
nextest \
1101+
--profile ci \
1102+
--hide-progress-bar \
1103+
${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} \
1104+
-p uucore \
1105+
-p coreutils
10851106
env:
1086-
RUSTC_WRAPPER: ""
10871107
RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
10881108
RUSTDOCFLAGS: "-Cpanic=abort"
10891109
RUST_BACKTRACE: "1"
10901110
LLVM_PROFILE_FILE: "${{ github.workspace }}/build/coverage-%m.profraw"
10911111
# RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }}
1092-
- name: Test individual utilities
1093-
run: cargo nextest run --profile ci --hide-progress-bar ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }}
1094-
env:
1095-
RUSTC_WRAPPER: ""
1096-
RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
1097-
RUSTDOCFLAGS: "-Cpanic=abort"
1098-
LLVM_PROFILE_FILE: "${{ github.workspace }}/build/coverage-%m.profraw"
1099-
RUST_BACKTRACE: "1"
1100-
# RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }}
1112+
1113+
# - name: Test individual utilities
1114+
# run: cargo nextest run --profile ci --hide-progress-bar ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }}
1115+
# env:
1116+
# RUSTC_WRAPPER: ""
1117+
# RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
1118+
# RUSTDOCFLAGS: "-Cpanic=abort"
1119+
# LLVM_PROFILE_FILE: "${{ github.workspace }}/build/coverage-%m.profraw"
1120+
# RUST_BACKTRACE: "1"
1121+
# # RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }}
1122+
11011123
- name: Generate coverage data (via `grcov`)
11021124
id: coverage
11031125
shell: bash
@@ -1106,14 +1128,17 @@ jobs:
11061128
COVERAGE_REPORT_DIR="target/debug"
11071129
COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info"
11081130
mkdir -p "${COVERAGE_REPORT_DIR}"
1131+
11091132
# display coverage files (for debug)
11101133
du -h ${{ github.workspace }}/build/
11111134
grcov --version
11121135
ls -al target/
11131136
ls -al target/debug
1137+
11141138
# generate coverage report
11151139
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\()"
11161140
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
1141+
11171142
- name: Upload coverage results (to Codecov.io)
11181143
uses: codecov/codecov-action@v4
11191144
with:

0 commit comments

Comments
 (0)