Debian Codegraph @

.github/workflows/ci.yml

raw symbols SCIP
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 PROJECT_NAME: platform-info
11 PROJECT_DESC: 'Cross-platform host machine info'
12 PROJECT_AUTH: 'uutils'
13 # * `rust` caching configuration
14 RUSTC_WRAPPER: 'sccache'
15 SCCACHE_GHA_ENABLED: 'true'
16
17 # terminate execution of the current workflow group when there is a newer changeset detected
18 # * the group is defined by "WORKFLOW_NAME-REF", where REF can be a branch, tag, or pull-request reference
19 # * workflows executing for the default branch are excluded from termination
20 concurrency:
21 group: ${{ github.workflow }}-${{ github.ref }}
22 cancel-in-progress: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
23
24 jobs:
25 style_format:
26 name: Style/format
27 runs-on: ubuntu-latest
28 steps:
29 - uses: actions/checkout@v4
30 - uses: dtolnay/rust-toolchain@stable
31 with:
32 components: rustfmt
33 - uses: Swatinem/rust-cache@v2
34 - uses: mozilla-actions/[email protected]
35 - run: cargo fmt --all -- --check
36
37 style_lint:
38 name: Style/lint
39 runs-on: ${{ matrix.os }}
40 strategy:
41 fail-fast: false
42 matrix:
43 os: [ubuntu-latest, macos-latest, windows-latest]
44 steps:
45 - uses: actions/checkout@v4
46 - uses: dtolnay/rust-toolchain@stable
47 with:
48 components: clippy
49 - uses: Swatinem/rust-cache@v2
50 - uses: mozilla-actions/[email protected]
51 - uses: DavidAnson/markdownlint-cli2-action@v18
52 with:
53 fix: true
54 globs: |
55 *.md
56 docs/src/**/*.md
57 src/**/*.md
58 - run: cargo clippy --all-targets -- -D warnings
59
60 style_spellcheck:
61 name: Style/spellcheck
62 runs-on: ubuntu-latest
63 steps:
64 - uses: actions/checkout@v4
65 - uses: streetsidesoftware/cspell-action@v6 ## ref: <https://github.com/streetsidesoftware/cspell-action>
66 with:
67 incremental_files_only: false
68 verbose: true
69
70 test:
71 name: Build/Test
72 runs-on: ${{ matrix.os }}
73 strategy:
74 fail-fast: false
75 matrix:
76 os: [ubuntu-latest, macos-latest, windows-latest]
77 steps:
78 - uses: actions/checkout@v4
79 - uses: dtolnay/rust-toolchain@stable
80 - uses: Swatinem/rust-cache@v2
81 - uses: mozilla-actions/[email protected]
82 - name: Build/Test Info
83 shell: bash
84 run: |
85 ## Build/Test Info
86 # repo/commit info
87 echo "## repo/commit"
88 echo GITHUB_REPOSITORY=${GITHUB_REPOSITORY}
89 echo GITHUB_REF=${GITHUB_REF}
90 echo GITHUB_SHA=${GITHUB_SHA}
91 # environment
92 echo "## environment"
93 echo "CI='${CI}'"
94 echo "PWD='${PWD}'"
95 # tooling info display
96 echo "## tooling"
97 which gcc >/dev/null 2>&1 && (gcc --version | head -1) || true
98 rustup -V 2>/dev/null
99 rustup show active-toolchain
100 cargo -V
101 rustc -V
102 # dependencies
103 echo "## crate dependency list"
104 # * note: for applications, use `--locked` for `cargo fetch`` and `cargo tree`) and commit *Cargo.lock*
105 cargo fetch --quiet
106 cargo tree --edges=no-dev --prefix=none --workspace | grep -vE "\(.*[/\\]${GITHUB_REPOSITORY##*/}\)" | sort --unique
107 - run: cargo test --all-features -- --test-threads 1
108 env:
109 RUST_BACKTRACE: '1'
110
111 coverage:
112 name: Code Coverage
113 runs-on: ${{ matrix.job.os }}
114 strategy:
115 fail-fast: true
116 matrix:
117 job:
118 - { os: ubuntu-latest }
119 - { os: macos-latest }
120 - { os: windows-latest }
121 steps:
122 - uses: actions/checkout@v4
123 - name: Initialize/setup workflow
124 id: vars
125 shell: bash
126 run: |
127 ## VARs and paths setup
128 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
129 # toolchain
130 TOOLCHAIN="nightly" ## default to "nightly" toolchain (required for certain required unstable compiler flags) ## !maint: refactor when stable channel has needed support
131 # * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files
132 case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-msvc" ;; esac;
133 # * use requested TOOLCHAIN if specified
134 if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
135 outputs TOOLCHAIN
136 # target-specific options
137 # * CARGO_FEATURES_OPTION
138 CARGO_FEATURES_OPTION='--all-features' ; ## default to '--all-features' for code coverage
139 if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ; fi
140 outputs CARGO_FEATURES_OPTION
141 # * CODECOV_FLAGS
142 CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
143 outputs CODECOV_FLAGS
144 # * code coverage
145 COVERAGE_REPORT_DIR="target/debug/coverage"
146 PROFILES_DIR="${COVERAGE_REPORT_DIR}/profiles"
147 mkdir -p "${COVERAGE_REPORT_DIR}" "${PROFILES_DIR}"
148 outputs COVERAGE_REPORT_DIR PROFILES_DIR
149 LLVM_PROFILE_FILE="${PROFILES_DIR}/profile-%p-%m.profraw"
150 outputs LLVM_PROFILE_FILE
151 - uses: dtolnay/rust-toolchain@master
152 with:
153 toolchain: ${{ steps.vars.outputs.TOOLCHAIN }}
154 components: llvm-tools
155 - uses: Swatinem/rust-cache@v2
156 - uses: mozilla-actions/[email protected]
157 - run: cargo install grcov
158 - name: Test
159 shell: bash
160 env:
161 CARGO_INCREMENTAL: '0'
162 LLVM_PROFILE_FILE: ${{ steps.vars.outputs.LLVM_PROFILE_FILE }}
163 RUSTC_WRAPPER: ''
164 RUSTFLAGS: '-C instrument-coverage'
165 RUSTDOCFLAGS: ''
166 run: |
167 ## Test
168 cargo test ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --no-fail-fast -- --test-threads 1
169 - name: Test examples
170 shell: bash
171 env:
172 CARGO_INCREMENTAL: '0'
173 LLVM_PROFILE_FILE: ${{ steps.vars.outputs.LLVM_PROFILE_FILE }}
174 RUSTC_WRAPPER: ''
175 RUSTFLAGS: '-C instrument-coverage'
176 RUSTDOCFLAGS: ''
177 run: |
178 ## Test examples
179 cargo test ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} --examples --no-fail-fast -- --test-threads 1
180 - name: Generate coverage data (via `grcov`)
181 id: coverage
182 shell: bash
183 run: |
184 ## Generate coverage data
185 outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
186 #
187 COVERAGE_REPORT_DIR='${{ steps.vars.outputs.COVERAGE_REPORT_DIR }}'
188 LLVM_PROFILE_FILE='${{ steps.vars.outputs.LLVM_PROFILE_FILE }}'
189 PROFILES_DIR='${{ steps.vars.outputs.PROFILES_DIR }}'
190 BINARY_PATH='target/debug'
191 COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info"
192 # display coverage files
193 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
194 # generate coverage report
195 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\()"
196 report=${COVERAGE_REPORT_FILE}
197 outputs report
198 - name: Upload coverage results (to Codecov.io)
199 uses: codecov/codecov-action@v5
200 # if: steps.vars.outputs.HAS_CODECOV_TOKEN
201 with:
202 token: ${{ secrets.CODECOV_TOKEN }}
203 files: ${{ steps.coverage.outputs.report }}
204 ## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }}
205 flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
206 name: codecov-umbrella
207 fail_ci_if_error: false