Debian Codegraph @

.github/workflows/ci.yml

raw symbols SCIP
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 fail-fast: false
14 matrix:
15 os: [ubuntu-latest, macOS-latest, windows-latest]
16 steps:
17 - uses: actions/checkout@v4
18 - uses: dtolnay/rust-toolchain@stable
19 - run: cargo check
20
21 test:
22 name: cargo test
23 runs-on: ${{ matrix.os }}
24 strategy:
25 fail-fast: false
26 matrix:
27 os: [ubuntu-latest, macOS-latest, windows-latest]
28 steps:
29 - uses: actions/checkout@v4
30 - uses: dtolnay/rust-toolchain@stable
31 - name: install GNU patch on MacOS
32 if: runner.os == 'macOS'
33 run: |
34 brew install gpatch
35 echo "/opt/homebrew/opt/gpatch/libexec/gnubin" >> "$GITHUB_PATH"
36 - name: set up PATH on Windows
37 # Needed to use GNU's patch.exe instead of Strawberry Perl patch
38 if: runner.os == 'Windows'
39 run: echo "C:\Program Files\Git\usr\bin" >> $env:GITHUB_PATH
40 - run: cargo test
41
42 fmt:
43 name: cargo fmt --all -- --check
44 runs-on: ubuntu-latest
45 steps:
46 - uses: actions/checkout@v4
47 - uses: dtolnay/rust-toolchain@stable
48 - run: rustup component add rustfmt
49 - run: cargo fmt --all -- --check
50
51 clippy:
52 name: cargo clippy -- -D warnings
53 runs-on: ${{ matrix.os }}
54 strategy:
55 fail-fast: false
56 matrix:
57 os: [ubuntu-latest, macOS-latest, windows-latest]
58 steps:
59 - uses: actions/checkout@v4
60 - uses: dtolnay/rust-toolchain@stable
61 - run: rustup component add clippy
62 - run: cargo clippy -- -D warnings
63
64 gnu-testsuite:
65 name: GNU test suite
66 runs-on: ubuntu-latest
67 steps:
68 - uses: actions/checkout@v4
69 - uses: dtolnay/rust-toolchain@stable
70 - run: cargo build --release
71 # do not fail, the report is merely informative (at least until all tests pass reliably)
72 - run: ./tests/run-upstream-testsuite.sh release || true
73 env:
74 TERM: xterm
75 - uses: actions/upload-artifact@v4
76 with:
77 name: test-results.json
78 path: tests/test-results.json
79 - run: ./tests/print-test-results.sh tests/test-results.json
80
81 coverage:
82 name: Code Coverage
83 runs-on: ${{ matrix.job.os }}
84 strategy:
85 fail-fast: false
86 matrix:
87 job:
88 - { os: ubuntu-latest , features: unix }
89 - { os: macos-latest , features: macos }
90 - { os: windows-latest , features: windows }
91 steps:
92 - uses: actions/checkout@v4
93 - name: Initialize workflow variables
94 id: vars
95 shell: bash
96 run: |
97 ## VARs setup
98 outputs() { step_id="vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
99 # toolchain
100 TOOLCHAIN="nightly" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support
101 # * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files
102 case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac;
103 # * use requested TOOLCHAIN if specified
104 if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
105 outputs TOOLCHAIN
106 # target-specific options
107 # * CODECOV_FLAGS
108 CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
109 outputs CODECOV_FLAGS
110
111 - name: rust toolchain ~ install
112 uses: dtolnay/rust-toolchain@nightly
113 - run: rustup component add llvm-tools-preview
114 - name: install GNU patch on MacOS
115 if: runner.os == 'macOS'
116 run: |
117 brew install gpatch
118 echo "/opt/homebrew/opt/gpatch/libexec/gnubin" >> "$GITHUB_PATH"
119 - name: set up PATH on Windows
120 # Needed to use GNU's patch.exe instead of Strawberry Perl patch
121 if: runner.os == 'Windows'
122 run: echo "C:\Program Files\Git\usr\bin" >> $env:GITHUB_PATH
123 - name: Test
124 run: cargo test --all-features --no-fail-fast
125 env:
126 CARGO_INCREMENTAL: "0"
127 RUSTC_WRAPPER: ""
128 RUSTFLAGS: "-Cinstrument-coverage -Zcoverage-options=branch -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
129 RUSTDOCFLAGS: "-Cpanic=abort"
130 LLVM_PROFILE_FILE: "diffutils-%p-%m.profraw"
131 - name: "`grcov` ~ install"
132 id: build_grcov
133 shell: bash
134 run: |
135 git clone https://github.com/mozilla/grcov.git ~/grcov/
136 cd ~/grcov
137 # Hardcode the version of crossbeam-epoch. See
138 # https://github.com/uutils/coreutils/issues/3680
139 sed -i -e "s|tempfile =|crossbeam-epoch = \"=0.9.8\"\ntempfile =|" Cargo.toml
140 cargo install --path .
141 cd -
142 # Uncomment when the upstream issue
143 # https://github.com/mozilla/grcov/issues/849 is fixed
144 # uses: actions-rs/[email protected]
145 # with:
146 # crate: grcov
147 # version: latest
148 # use-tool-cache: false
149 - name: Generate coverage data (via `grcov`)
150 id: coverage
151 shell: bash
152 run: |
153 ## Generate coverage data
154 COVERAGE_REPORT_DIR="target/debug"
155 COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info"
156 mkdir -p "${COVERAGE_REPORT_DIR}"
157 # display coverage files
158 grcov . --output-type files --binary-path "${COVERAGE_REPORT_DIR}" | sort --unique
159 # generate coverage report
160 grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --binary-path "${COVERAGE_REPORT_DIR}" --branch
161 echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
162 - name: Upload coverage results (to Codecov.io)
163 uses: codecov/codecov-action@v5
164 with:
165 token: ${{ secrets.CODECOV_TOKEN }}
166 files: ${{ steps.coverage.outputs.report }}
167 ## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }}
168 flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
169 name: codecov-umbrella
170 fail_ci_if_error: false
171