|
| 1 | +on: [push, pull_request] |
| 2 | + |
| 3 | +name: Basic CI |
| 4 | + |
| 5 | +env: |
| 6 | + CARGO_TERM_COLOR: always |
| 7 | + |
| 8 | +jobs: |
| 9 | + check: |
| 10 | + name: cargo check |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + os: [ubuntu-latest, macOS-latest, windows-latest] |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + - uses: actions-rs/toolchain@v1 |
| 18 | + with: |
| 19 | + profile: minimal |
| 20 | + toolchain: stable |
| 21 | + override: true |
| 22 | + - uses: actions-rs/cargo@v1 |
| 23 | + with: |
| 24 | + command: check |
| 25 | + |
| 26 | + test: |
| 27 | + name: cargo test |
| 28 | + runs-on: ${{ matrix.os }} |
| 29 | + strategy: |
| 30 | + matrix: |
| 31 | + os: [ubuntu-latest, macOS-latest, windows-latest] |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + - uses: actions-rs/toolchain@v1 |
| 35 | + with: |
| 36 | + profile: minimal |
| 37 | + toolchain: stable |
| 38 | + override: true |
| 39 | + - uses: actions-rs/cargo@v1 |
| 40 | + with: |
| 41 | + command: test |
| 42 | + |
| 43 | + fmt: |
| 44 | + name: cargo fmt --all -- --check |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + - uses: actions-rs/toolchain@v1 |
| 49 | + with: |
| 50 | + profile: minimal |
| 51 | + toolchain: stable |
| 52 | + override: true |
| 53 | + - run: rustup component add rustfmt |
| 54 | + - uses: actions-rs/cargo@v1 |
| 55 | + with: |
| 56 | + command: fmt |
| 57 | + args: --all -- --check |
| 58 | + |
| 59 | + clippy: |
| 60 | + name: cargo clippy -- -D warnings |
| 61 | + runs-on: ${{ matrix.os }} |
| 62 | + strategy: |
| 63 | + matrix: |
| 64 | + os: [ubuntu-latest, macOS-latest, windows-latest] |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + - uses: actions-rs/toolchain@v1 |
| 68 | + with: |
| 69 | + profile: minimal |
| 70 | + toolchain: stable |
| 71 | + override: true |
| 72 | + - run: rustup component add clippy |
| 73 | + - uses: actions-rs/cargo@v1 |
| 74 | + with: |
| 75 | + command: clippy |
| 76 | + args: -- -D warnings |
| 77 | + |
| 78 | + coverage: |
| 79 | + name: Code Coverage |
| 80 | + runs-on: ${{ matrix.job.os }} |
| 81 | + strategy: |
| 82 | + fail-fast: true |
| 83 | + matrix: |
| 84 | + job: |
| 85 | + - { os: ubuntu-latest , features: unix } |
| 86 | + - { os: macos-latest , features: macos } |
| 87 | + - { os: windows-latest , features: windows } |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@v4 |
| 90 | + - name: Initialize workflow variables |
| 91 | + id: vars |
| 92 | + shell: bash |
| 93 | + run: | |
| 94 | + ## VARs setup |
| 95 | + outputs() { step_id="vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; } |
| 96 | + # toolchain |
| 97 | + TOOLCHAIN="nightly" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support |
| 98 | + # * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files |
| 99 | + case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac; |
| 100 | + # * use requested TOOLCHAIN if specified |
| 101 | + if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi |
| 102 | + outputs TOOLCHAIN |
| 103 | + # target-specific options |
| 104 | + # * CARGO_FEATURES_OPTION |
| 105 | + CARGO_FEATURES_OPTION='--all -- --check' ; ## default to '--all-features' for code coverage |
| 106 | + # * CODECOV_FLAGS |
| 107 | + CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' ) |
| 108 | + outputs CODECOV_FLAGS |
| 109 | +
|
| 110 | + - name: rust toolchain ~ install |
| 111 | + uses: actions-rs/toolchain@v1 |
| 112 | + with: |
| 113 | + toolchain: ${{ steps.vars.outputs.TOOLCHAIN }} |
| 114 | + default: true |
| 115 | + profile: minimal # minimal component installation (ie, no documentation) |
| 116 | + - name: Test |
| 117 | + uses: actions-rs/cargo@v1 |
| 118 | + with: |
| 119 | + command: test |
| 120 | + args: ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --no-fail-fast |
| 121 | + env: |
| 122 | + CARGO_INCREMENTAL: "0" |
| 123 | + RUSTC_WRAPPER: "" |
| 124 | + RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" |
| 125 | + RUSTDOCFLAGS: "-Cpanic=abort" |
| 126 | + - name: "`grcov` ~ install" |
| 127 | + id: build_grcov |
| 128 | + shell: bash |
| 129 | + run: | |
| 130 | + git clone https://github.com/mozilla/grcov.git ~/grcov/ |
| 131 | + cd ~/grcov |
| 132 | + # Hardcode the version of crossbeam-epoch. See |
| 133 | + # https://github.com/uutils/coreutils/issues/3680 |
| 134 | + sed -i -e "s|tempfile =|crossbeam-epoch = \"=0.9.8\"\ntempfile =|" Cargo.toml |
| 135 | + cargo install --path . |
| 136 | + cd - |
| 137 | +# Uncomment when the upstream issue |
| 138 | +# https://github.com/mozilla/grcov/issues/849 is fixed |
| 139 | +# uses: actions-rs/[email protected] |
| 140 | +# with: |
| 141 | +# crate: grcov |
| 142 | +# version: latest |
| 143 | +# use-tool-cache: false |
| 144 | + - name: Generate coverage data (via `grcov`) |
| 145 | + id: coverage |
| 146 | + shell: bash |
| 147 | + run: | |
| 148 | + ## Generate coverage data |
| 149 | + COVERAGE_REPORT_DIR="target/debug" |
| 150 | + COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info" |
| 151 | + mkdir -p "${COVERAGE_REPORT_DIR}" |
| 152 | + # display coverage files |
| 153 | + grcov . --output-type files --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" | sort --unique |
| 154 | + # generate coverage report |
| 155 | + grcov . --output-type lcov --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\()" |
| 156 | + echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT |
| 157 | + - name: Upload coverage results (to Codecov.io) |
| 158 | + uses: codecov/codecov-action@v3 |
| 159 | + # if: steps.vars.outputs.HAS_CODECOV_TOKEN |
| 160 | + with: |
| 161 | + # token: ${{ secrets.CODECOV_TOKEN }} |
| 162 | + file: ${{ steps.coverage.outputs.report }} |
| 163 | + ## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }} |
| 164 | + flags: ${{ steps.vars.outputs.CODECOV_FLAGS }} |
| 165 | + name: codecov-umbrella |
| 166 | + fail_ci_if_error: false |
| 167 | + |
0 commit comments