Convert license
, sort
, and update
to Rust tests
#5177
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
merge_group: | |
pull_request: | |
workflow_dispatch: | |
concurrency: | |
group: ci-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
maybe-expedite: | |
outputs: | |
value: ${{ steps.expedite.outputs.value }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Log github refs | |
run: | | |
{ | |
echo '```' | |
echo 'github.ref: ${{ github.ref }}' | |
echo 'github.sha: ${{ github.sha }}' | |
echo '```' | |
} >> "$GITHUB_STEP_SUMMARY" | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check if merging an up-to-date branch | |
if: ${{ github.event_name == 'merge_group' }} | |
id: expedite | |
run: | | |
N="$(expr "${{ github.ref }}" : '.*-\([0-9]\+\)-[^-]*$')" | |
BASE_SHA="$(gh api /repos/${{ github.repository }}/pulls/"$N" | jq -r '.base.sha')" | |
if git diff --quiet ${{ github.event.merge_group.base_sha }} "$BASE_SHA"; then | |
echo "value=1" >> "$GITHUB_OUTPUT" | |
fi | |
env: | |
GH_TOKEN: ${{ github.token }} | |
lint: | |
needs: [maybe-expedite] | |
if: ${{ ! needs.maybe-expedite.outputs.value }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
~/.dylint_drivers/ | |
~/.rustup/toolchains/ | |
key: ${{ runner.os }}-drivers-${{ hashFiles('driver/**') }} | |
- name: Install dylint-link | |
run: cargo install --path ./dylint-link --force | |
- name: Actionlint | |
run: | | |
go install github.com/rhysd/actionlint/cmd/actionlint@latest | |
"$HOME"/go/bin/actionlint | |
- name: Shellcheck | |
run: shellcheck --exclude=SC2002 scripts/* | |
- name: Install tools | |
run: | | |
# smoelius: Prettier is still needed for scripts/update_example_READMEs.sh. | |
npm install -g prettier | |
rm -f "$HOME"/.cargo/bin/cargo-fmt | |
rm -f "$HOME"/.cargo/bin/rustfmt | |
rustup install nightly | |
rustup component add rustfmt --toolchain nightly | |
cargo install cargo-rdme || true | |
- name: Format | |
run: ./scripts/format.sh && git diff --exit-code | |
- name: Format example READMEs | |
run: ./scripts/update_example_READMEs.sh && git diff --exit-code | |
- name: Format util READMEs | |
run: ./scripts/update_util_READMEs.sh && git diff --exit-code | |
- name: Lint | |
run: ./scripts/lint.sh | |
test: | |
needs: [maybe-expedite] | |
if: ${{ ! needs.maybe-expedite.outputs.value }} | |
strategy: | |
fail-fast: ${{ github.event_name == 'merge_group' }} | |
matrix: | |
environment: [ubuntu-latest, macos-latest, windows-latest] | |
package: [cargo-dylint, cargo-dylint-cli, examples, other] | |
runs-on: ${{ matrix.environment }} | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v4 | |
# smoelius: The `nightly_toolchain` test makes sense only if the nightly driver is cached. | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
~/.dylint_drivers/ | |
~/.rustup/toolchains/ | |
key: ${{ runner.os }}-drivers-${{ hashFiles('driver/**') }} | |
- name: Rustup | |
run: rustup update | |
- name: Install dylint-link | |
run: cargo install --path ./dylint-link --force | |
# smoelius: This list will grow: https://github.com/trailofbits/dylint/issues/636 | |
- name: Install tools | |
run: | | |
npm install -g prettier | |
rustup install nightly | |
cargo install cargo-hack || true | |
cargo install cargo-license || true | |
cargo install cargo-msrv || true | |
cargo install cargo-sort || true | |
cargo install cargo-supply-chain || true | |
cargo install cargo-udeps --locked || true | |
cargo install cargo-unmaintained || true | |
- name: Free up space on Ubuntu | |
if: ${{ matrix.environment == 'ubuntu-latest' }} | |
run: | | |
# https://github.com/actions/runner-images/issues/2606#issuecomment-772683150 | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /usr/share/swift | |
# du -sh /usr/*/* 2>/dev/null | sort -h || true | |
- name: Test | |
run: | | |
if [[ '${{ matrix.environment }}' = 'windows-latest' ]]; then | |
export CARGO_INCREMENTAL=0 | |
fi | |
if [[ '${{ matrix.package }}' != 'other' ]]; then | |
if [[ '${{ matrix.package }}' == 'cargo-dylint-cli' ]]; then | |
cargo test -p cargo-dylint --no-default-features --features=cargo-cli -- --nocapture | |
else | |
cargo test -p '${{ matrix.package }}' --all-features -- --nocapture | |
fi | |
else | |
cargo test --workspace --exclude cargo-dylint --exclude examples --all-features -- --nocapture | |
pushd driver | |
cargo test --all-features -- --nocapture | |
popd | |
pushd utils/linting | |
cargo test --all-features -- --nocapture | |
popd | |
# smoelius: The `cdylib` -> `lib` trick is due to @MinerSebas. | |
for X in examples/*/*; do | |
if [[ ! -d "$X" ]]; then | |
continue | |
fi | |
if [[ "$(basename "$X")" = '.cargo' || "$(basename "$X")" = 'src' ]]; then | |
continue | |
fi | |
pushd "$X" | |
sed -i.bak 's/"cdylib"/"lib"/g' Cargo.toml | |
cargo test --doc | |
popd | |
done | |
fi | |
all-checks: | |
needs: [lint, test] | |
# smoelius: From "Defining prerequisite jobs" | |
# (https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs): | |
# > If you would like a job to run even if a job it is dependent on did not succeed, use the | |
# > `always()` conditional expression in `jobs.<job_id>.if`. | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check results | |
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} | |
run: exit 1 |