Skip to content

Commit 2f9fac0

Browse files
committed
xx
1 parent 4831a50 commit 2f9fac0

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

.github/workflows/CICD.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,116 @@ jobs:
997997
name: toybox-result.json
998998
path: ${{ steps.vars.outputs.TEST_SUMMARY_FILE }}
999999

1000+
coverage:
1001+
name: Code Coverage
1002+
runs-on: ${{ matrix.job.os }}
1003+
timeout-minutes: 90
1004+
env:
1005+
SCCACHE_GHA_ENABLED: "true"
1006+
RUSTC_WRAPPER: "sccache"
1007+
strategy:
1008+
fail-fast: false
1009+
matrix:
1010+
job:
1011+
- { os: ubuntu-latest , features: unix, toolchain: nightly }
1012+
- { os: macos-latest , features: macos, toolchain: nightly }
1013+
# FIXME: Re-enable Code Coverage on windows, which currently fails due to "profiler_builtins". See #6686.
1014+
# - { os: windows-latest , features: windows, toolchain: nightly-x86_64-pc-windows-gnu }
1015+
steps:
1016+
- uses: actions/checkout@v4
1017+
- uses: dtolnay/rust-toolchain@master
1018+
with:
1019+
toolchain: ${{ matrix.job.toolchain }}
1020+
components: rustfmt
1021+
- uses: taiki-e/install-action@v2
1022+
with:
1023+
tool: nextest,[email protected]
1024+
- uses: Swatinem/rust-cache@v2
1025+
- name: Run sccache-cache
1026+
uses: mozilla-actions/[email protected]
1027+
# - name: Reattach HEAD ## may be needed for accurate code coverage info
1028+
# run: git checkout ${{ github.head_ref }}
1029+
- name: Initialize workflow variables
1030+
id: vars
1031+
shell: bash
1032+
run: |
1033+
## VARs setup
1034+
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
1035+
1036+
# toolchain
1037+
TOOLCHAIN="nightly" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support
1038+
1039+
# * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files
1040+
case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac;
1041+
1042+
# * use requested TOOLCHAIN if specified
1043+
if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
1044+
outputs TOOLCHAIN
1045+
1046+
# target-specific options
1047+
1048+
# * CARGO_FEATURES_OPTION
1049+
CARGO_FEATURES_OPTION='--all-features' ; ## default to '--all-features' for code coverage
1050+
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi
1051+
outputs CARGO_FEATURES_OPTION
1052+
1053+
# * CODECOV_FLAGS
1054+
CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
1055+
outputs CODECOV_FLAGS
1056+
1057+
- name: Install/setup prerequisites
1058+
shell: bash
1059+
run: |
1060+
## Install/setup prerequisites
1061+
case '${{ matrix.job.os }}' in
1062+
macos-latest) brew install coreutils ;; # needed for testing
1063+
esac
1064+
1065+
case '${{ matrix.job.os }}' in
1066+
ubuntu-latest)
1067+
# pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
1068+
# In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands. The account also has empty gecos fields.
1069+
# To work around this for pinky tests, we create a fake login entry for the GH runner account...
1070+
FAKE_UTMP='[7] [999999] [tty2] [runner] [tty2] [] [0.0.0.0] [2022-02-22T22:22:22,222222+00:00]'
1071+
# ... by dumping the login records, adding our fake line, then reverse dumping ...
1072+
(utmpdump /var/run/utmp ; echo $FAKE_UTMP) | sudo utmpdump -r -o /var/run/utmp
1073+
# ... and add a full name to each account with a gecos field but no full name.
1074+
sudo sed -i 's/:,/:runner name,/' /etc/passwd
1075+
# We also create a couple optional files pinky looks for
1076+
touch /home/runner/.project
1077+
echo "foo" > /home/runner/.plan
1078+
;;
1079+
esac
1080+
1081+
case '${{ matrix.job.os }}' in
1082+
# Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368
1083+
windows-latest) C:/msys64/usr/bin/pacman.exe -Sy --needed mingw-w64-x86_64-gcc --noconfirm ; echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH ;;
1084+
esac
1085+
1086+
- name: Run test and coverage
1087+
id: run_test_cov
1088+
run: |
1089+
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
1090+
1091+
# Run the coverage script
1092+
./util/build-run-test-coverage-linux.sh
1093+
1094+
outputs REPORT_FILE
1095+
env:
1096+
COVERAGE_DIR: ${{ github.workspace }}/coverage
1097+
FEATURES_OPTION: ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
1098+
# RUSTUP_TOOLCHAIN: ${{ steps.vars.outputs.TOOLCHAIN }}
1099+
1100+
- name: Upload coverage results (to Codecov.io)
1101+
uses: codecov/codecov-action@v4
1102+
with:
1103+
token: ${{ secrets.CODECOV_TOKEN }}
1104+
file: ${{ steps.run_test_cov.outputs.report }}
1105+
## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }}
1106+
flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
1107+
name: codecov-umbrella
1108+
fail_ci_if_error: false
1109+
10001110
test_separately:
10011111
name: Separate Builds
10021112
runs-on: ${{ matrix.os }}

0 commit comments

Comments
 (0)