Debian Codegraph @

debian/rust-vendor/platform-info/.github/workflows/ci.yml

raw
1 # spell-checker:ignore (rust) clippy rustdoc rustfmt rustup RUSTC RUSTFLAGS RUSTDOCFLAGS profraw
2 # spell-checker:ignore (abbrevs/acronyms) MSVC (bash) alnum esac (jargon) maint (utils) codecov grcov lcov markdownlint sccache () uutils
3 # spell-checker:ignore (people) dtolnay ; Swatinem ; DavidAnson
4
5 on: [push, pull_request]
6
7 name: CI
8
9 env:
10 CARGO_INCREMENTAL: "0"
11 PROJECT_NAME: platform-info
12 PROJECT_DESC: 'Cross-platform host machine info'
13 PROJECT_AUTH: 'uutils'
14 # * `rust` caching configuration
15 RUSTC_WRAPPER: 'sccache'
16 SCCACHE_GHA_ENABLED: 'true'
17
18 # terminate execution of the current workflow group when there is a newer changeset detected
19 # * the group is defined by "WORKFLOW_NAME-REF", where REF can be a branch, tag, or pull-request reference
20 # * workflows executing for the default branch are excluded from termination
21 concurrency:
22 group: ${{ github.workflow }}-${{ github.ref }}
23 cancel-in-progress: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
24
25 jobs:
26 style_format:
27 name: Style/format
28 runs-on: ubuntu-latest
29 steps:
30 - uses: actions/checkout@v7
31 - uses: Swatinem/rust-cache@v2
32 - uses: mozilla-actions/[email protected]
33 - run: cargo fmt --all -- --check
34
35 style_lint:
36 name: Style/lint
37 runs-on: ${{ matrix.os }}
38 strategy:
39 fail-fast: false
40 matrix:
41 os: [ubuntu-latest, macos-latest, windows-latest]
42 steps:
43 - uses: actions/checkout@v7
44 - uses: Swatinem/rust-cache@v2
45 - uses: mozilla-actions/[email protected]
46 - uses: DavidAnson/markdownlint-cli2-action@v24
47 with:
48 fix: true
49 globs: |
50 *.md
51 docs/src/**/*.md
52 src/**/*.md
53 - run: cargo clippy --all-targets -- -D warnings -D clippy::pedantic
54 - name: Clippy (WASI)
55 if: matrix.os == 'ubuntu-latest'
56 run: |
57 rustup target add wasm32-wasip1
58 cargo clippy --target wasm32-wasip1 -- -D warnings -W clippy::pedantic
59
60 style_spellcheck:
61 name: Style/spellcheck
62 runs-on: ubuntu-latest
63 steps:
64 - uses: actions/checkout@v7
65 - uses: streetsidesoftware/cspell-action@v9 ## ref: <https://github.com/streetsidesoftware/cspell-action>
66 with:
67 incremental_files_only: false
68 verbose: true
69
70 msrv:
71 name: MSRV
72 runs-on: ${{ matrix.os }}
73 strategy:
74 fail-fast: false
75 matrix:
76 os: [ubuntu-latest, windows-latest, macos-latest]
77 steps:
78 - uses: actions/checkout@v7
79 - uses: dtolnay/[email protected]
80 - name: Install tools
81 uses: taiki-e/install-action@v2
82 with:
83 tool: |
84 cargo-hack
85 cargo-minimal-versions
86 - uses: Swatinem/rust-cache@v2
87 - uses: mozilla-actions/[email protected]
88 - run: cargo minimal-versions test --workspace --feature-powerset --ignore-private
89
90 test:
91 name: Build/Test
92 runs-on: ${{ matrix.os }}
93 strategy:
94 fail-fast: false
95 matrix:
96 os: [ubuntu-latest, macos-latest, windows-latest]
97 steps:
98 - uses: actions/checkout@v7
99 - uses: Swatinem/rust-cache@v2
100 - uses: mozilla-actions/[email protected]
101 - name: Build/Test Info
102 shell: bash
103 run: |
104 ## Build/Test Info
105 # repo/commit info
106 echo "## repo/commit"
107 echo GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
108 echo GITHUB_REF=${GITHUB_REF}
109 echo GITHUB_SHA=${GITHUB_SHA}
110 # environment
111 echo "## environment"
112 echo "CI='${CI}'"
113 echo "PWD='${PWD}'"
114 # tooling info display
115 echo "## tooling"
116 command -v gcc >/dev/null 2>&1 && (gcc --version | head -1) || true
117 rustup -V 2>/dev/null
118 rustup show active-toolchain
119 cargo -V
120 rustc -V
121 # dependencies
122 echo "## crate dependency list"
123 # * note: for applications, use `--locked` for `cargo fetch`` and `cargo tree`) and commit *Cargo.lock*
124 cargo fetch --quiet
125 cargo tree --edges=no-dev --prefix=none --workspace | grep -vE "\(.*[/\\]${GITHUB_REPOSITORY##*/}\)" | sort --unique
126 - run: cargo test --all-features -- --test-threads 1
127 env:
128 RUST_BACKTRACE: '1'
129
130 test_wasi:
131 name: Build/Test (WASI)
132 runs-on: ubuntu-latest
133 steps:
134 - uses: actions/checkout@v7
135 - uses: dtolnay/rust-toolchain@stable
136 with:
137 targets: wasm32-wasip1
138 - uses: Swatinem/rust-cache@v2
139 - uses: mozilla-actions/[email protected]
140 - name: Install wasmtime
141 run: |
142 curl https://wasmtime.dev/install.sh -sSf | bash
143 echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
144 - name: Build for WASI
145 run: cargo build --target wasm32-wasip1
146 - name: Test with wasmtime
147 env:
148 CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime
149 # WASI does not support threads, so tests must run sequentially
150 run: cargo test --target wasm32-wasip1 -- --test-threads 1
151
152 coverage:
153 name: Code Coverage
154 runs-on: ${{ matrix.job.os }}
155 strategy:
156 fail-fast: true
157 matrix:
158 job:
159 - { os: ubuntu-latest }
160 - { os: macos-latest }
161 - { os: windows-latest }
162 steps:
163 - uses: actions/checkout@v7
164 - name: Initialize/setup workflow
165 id: vars
166 shell: bash
167 run: |
168 ## VARs and paths setup
169 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
170 # toolchain
171 TOOLCHAIN="nightly" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support
172 # * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files
173 case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-msvc" ;; esac;
174 # * use requested TOOLCHAIN if specified
175 if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
176 outputs TOOLCHAIN
177 # target-specific options
178 # * CARGO_FEATURES_OPTION
179 CARGO_FEATURES_OPTION='--all-features' ; ## default to '--all-features' for code coverage
180 if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi
181 outputs CARGO_FEATURES_OPTION
182 # * CODECOV_FLAGS
183 CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
184 outputs CODECOV_FLAGS
185 # * code coverage
186 COVERAGE_REPORT_DIR="target/debug/coverage"
187 PROFILES_DIR="${COVERAGE_REPORT_DIR}/profiles"
188 mkdir -p "${COVERAGE_REPORT_DIR}" "${PROFILES_DIR}"
189 outputs COVERAGE_REPORT_DIR PROFILES_DIR
190 LLVM_PROFILE_FILE="${PROFILES_DIR}/profile-%p-%m.profraw"
191 outputs LLVM_PROFILE_FILE
192 - uses: dtolnay/rust-toolchain@master
193 with:
194 toolchain: ${{ steps.vars.outputs.TOOLCHAIN }}
195 components: llvm-tools
196 - uses: Swatinem/rust-cache@v2
197 - uses: mozilla-actions/[email protected]
198 - run: cargo install grcov
199 - name: Test
200 shell: bash
201 env:
202 LLVM_PROFILE_FILE: ${{ steps.vars.outputs.LLVM_PROFILE_FILE }}
203 RUSTC_WRAPPER: ''
204 RUSTFLAGS: '-C instrument-coverage'
205 RUSTDOCFLAGS: ''
206 run: |
207 ## Test
208 cargo test ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --no-fail-fast -- --test-threads 1
209 - name: Test examples
210 shell: bash
211 env:
212 LLVM_PROFILE_FILE: ${{ steps.vars.outputs.LLVM_PROFILE_FILE }}
213 RUSTC_WRAPPER: ''
214 RUSTFLAGS: '-C instrument-coverage'
215 RUSTDOCFLAGS: ''
216 run: |
217 ## Test examples
218 cargo test ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --examples --no-fail-fast -- --test-threads 1
219 - name: Generate coverage data (via `grcov`)
220 id: coverage
221 shell: bash
222 run: |
223 ## Generate coverage data
224 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
225 #
226 COVERAGE_REPORT_DIR='${{ steps.vars.outputs.COVERAGE_REPORT_DIR }}'
227 LLVM_PROFILE_FILE='${{ steps.vars.outputs.LLVM_PROFILE_FILE }}'
228 PROFILES_DIR='${{ steps.vars.outputs.PROFILES_DIR }}'
229 BINARY_PATH='target/debug'
230 COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info"
231 # display coverage files
232 grcov . --binary-path "${BINARY_PATH}" --source-dir . --output-type files --ignore build.rs --ignore "examples/*" --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" | sort --unique
233 # generate coverage report
234 grcov . --binary-path "${BINARY_PATH}" --source-dir . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --ignore build.rs --ignore "examples/*" --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()"
235 report=${COVERAGE_REPORT_FILE}
236 outputs report
237 - name: Upload coverage results (to Codecov.io)
238 uses: codecov/codecov-action@v7
239 # if: steps.vars.outputs.HAS_CODECOV_TOKEN
240 with:
241 token: ${{ secrets.CODECOV_TOKEN }}
242 files: ${{ steps.coverage.outputs.report }}
243 ## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }}
244 flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
245 name: codecov-umbrella
246 fail_ci_if_error: false