Debian Codegraph @

.github/workflows/ci.yml

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