Debian Codegraph @

debian/rust-vendor/num-prime/.github/workflows/ci.yml

raw
1 on: pull_request
2
3 name: Continuous integration
4
5 jobs:
6 ci:
7 runs-on: ${{ matrix.os }}
8 strategy:
9 matrix:
10 rust:
11 - 1.70.0
12 - stable
13 - nightly
14 os: [ubuntu-latest, windows-latest, macos-latest]
15
16 steps:
17 - uses: actions/checkout@v6
18 - uses: dtolnay/rust-toolchain@master
19 with:
20 toolchain: ${{ matrix.rust }}
21 - run: cargo test
22 - run: cargo test --all-features
23 - run: cargo test --features big-table
24 - run: cargo test --no-default-features
25 - run: cargo test --no-default-features --features big-table
26 - run: cargo test --no-default-features --features big-int
27
28 clippy:
29 runs-on: ${{ matrix.os }}
30 strategy:
31 matrix:
32 rust:
33 - 1.70.0
34 - stable
35 - nightly
36 os: [ubuntu-latest, windows-latest, macos-latest]
37
38 steps:
39 - uses: actions/checkout@v6
40 - uses: dtolnay/rust-toolchain@master
41 with:
42 toolchain: ${{ matrix.rust }}
43 components: clippy
44 - run: cargo clippy -- -D warnings
45
46 rustfmt:
47 runs-on: ${{ matrix.os }}
48 strategy:
49 matrix:
50 rust:
51 - stable
52 os: [ubuntu-latest]
53
54 steps:
55 - uses: actions/checkout@v6
56 - run: cargo fmt --check --all
57
58 mathematical_validation:
59 runs-on: ubuntu-latest
60 steps:
61 - uses: actions/checkout@v6
62 - name: Install Scilab CLI
63 run: |
64 sudo apt-get update
65 sudo apt-get install -y scilab-cli
66 - run: cargo build --release
67 - name: Compare implementation with Scilab
68 run: ./util/validate_with_scilab.sh
69
70 coverage:
71 name: Code Coverage
72 runs-on: ${{ matrix.job.os }}
73 strategy:
74 fail-fast: true
75 matrix:
76 job:
77 - { os: ubuntu-latest , features: unix }
78 - { os: macos-latest , features: macos }
79 - { os: windows-latest , features: windows }
80 steps:
81 - uses: actions/checkout@v6
82 - name: Initialize workflow variables
83 id: vars
84 shell: bash
85 run: |
86 ## VARs setup
87 outputs() { step_id="vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
88 # Emulate a nightly toolchain
89 echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}"
90 # * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files
91 case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac;
92 # * use requested TOOLCHAIN if specified
93 if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
94 outputs TOOLCHAIN
95 # target-specific options
96 # * CODECOV_FLAGS
97 CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
98 outputs CODECOV_FLAGS
99
100 - name: rust toolchain ~ install
101 uses: dtolnay/rust-toolchain@stable
102 with:
103 components: llvm-tools-preview
104 - name: Test
105 run: cargo test --no-fail-fast
106 env:
107 CARGO_INCREMENTAL: "0"
108 RUSTC_WRAPPER: ""
109 RUSTFLAGS: "-Cinstrument-coverage -Zcoverage-options=branch -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
110 RUSTDOCFLAGS: "-Cpanic=abort"
111 LLVM_PROFILE_FILE: "num_prime-%p-%m.profraw"
112 - name: "`grcov` ~ install"
113 id: build_grcov
114 shell: bash
115 run: |
116 git clone --depth=1 https://github.com/mozilla/grcov.git ~/grcov/
117 cd ~/grcov
118 # Hardcode the version of crossbeam-epoch. See
119 # https://github.com/uutils/coreutils/issues/3680
120 # macOS sed rejects sed -i
121 sed -i.bak -e "s|tempfile =|crossbeam-epoch = \"=0.9.8\"\ntempfile =|" Cargo.toml
122 cargo install --path . --locked
123 cd -
124 # Uncomment when the upstream issue
125 # https://github.com/mozilla/grcov/issues/849 is fixed
126 # uses: actions-rs/[email protected]
127 # with:
128 # crate: grcov
129 # version: latest
130 # use-tool-cache: false
131 - name: Generate coverage data (via `grcov`)
132 id: coverage
133 shell: bash
134 run: |
135 ## Generate coverage data
136 COVERAGE_REPORT_DIR="target/debug"
137 COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info"
138 mkdir -p "${COVERAGE_REPORT_DIR}"
139 # display coverage files
140 grcov . --binary-path="${COVERAGE_REPORT_DIR}" --output-type files --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" | sort --unique
141 # generate coverage report
142 grcov . --binary-path="${COVERAGE_REPORT_DIR}" --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\()" --source-dir .
143 echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
144 - name: Upload coverage results (to Codecov.io)
145 uses: codecov/codecov-action@v5
146 with:
147 token: ${{ secrets.CODECOV_TOKEN }}
148 files: ${{ steps.coverage.outputs.report }}
149 flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
150 name: codecov-umbrella
151 fail_ci_if_error: false
152 verbose: true
153 directory: ./
154 root_dir: ./