chore(ci): Run cargo hack on a daily basis, open issue on failure. (#2608)

This commit is contained in:
Daniel Sanchez 2026-04-23 13:55:32 +00:00 committed by GitHub
parent 70e6847e8b
commit c39e8cb57b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 95 additions and 61 deletions

View File

@ -57,66 +57,6 @@ jobs:
- name: Run cargo-deny
run: cargo-deny --locked --all-features check --hide-inclusion-graph -c .cargo-deny.toml --show-stats -D warnings
features:
name: Check packages feature combinations
strategy:
fail-fast: false
matrix:
platform:
# Using self-hosted runners because we were running out of memory on GitHub-hosted runners
- os: [self-hosted, Linux]
label: self-hosted-linux
- os: [self-hosted, macOS]
label: self-hosted-macos
runs-on: ${{ matrix.platform.os }}
steps:
# Disable rustup override before checkout, so the toolchain state is clean before any workspace files or
# .rust-toolchain.toml are present. Prevents a stale override from affecting the toolchain resolution during
# checkout or subsequent steps.
- name: Disable rustup override
run: rustup override unset || true
- name: Checkout repository
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2
- name: Setup Circuits
uses: ./.github/actions/setup-circuits
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install cargo-hack
uses: taiki-e/install-action@5651179950649c44da31d346537e20c0534f0f25 # Version 2.49.35
with:
tool: cargo-hack
# Prune after Install cargo-hack, before Set up Cargo cache — frees disk space from the previous run's leftover
# artifacts (incremental compile dirs, fingerprints, build dirs) before the cache is restored. This means the
# restored cache lands onto a disk that has already been cleaned, maximizing the chance the restore succeeds
# without hitting disk limits.
- name: Prune disk space (cache-aware, self-hosted)
uses: ./.github/actions/prune-disk-space
- name: Set up Cargo cache
uses: ./.github/actions/setup-cargo-cache
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
key-prefix: code-check/feature-combinations/${{ matrix.platform.label }}
- name: Run Cargo Hack Check (Cache-Aware)
uses: ./.github/actions/cargo-hack-check-cached
- name: Update Cargo cache
if: success() || failure()
uses: ./.github/actions/update-cargo-cache
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
key-prefix: code-check/feature-combinations/${{ matrix.platform.label }}
- name: Clean up build artifacts
if: success() || failure()
uses: actions-rs/cargo@9e120dd99b0fbad1c065f686657e914e76bd7b72 # Version 1.0.1
with:
command: clean
unused-deps:
name: Check for unused dependencies
strategy:
@ -171,7 +111,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
key-prefix: code-check/lints/${{ matrix.os }}
tests:
name: Run test suite
if: ${{ !startsWith(github.event.pull_request.title, '[WIP]') && !contains(github.event.label.name, 'DO NOT MERGE') }}

View File

@ -0,0 +1,94 @@
on:
push:
branches:
- master
workflow_dispatch: # Allow manual triggering
name: Cargo Hack
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
issues: write
jobs:
features:
name: Check packages feature combinations
strategy:
fail-fast: false
matrix:
platform:
# Using self-hosted runners because we were running out of memory on GitHub-hosted runners
- os: [ self-hosted, Linux ]
label: self-hosted-linux
- os: [ self-hosted, macOS ]
label: self-hosted-macos
runs-on: ${{ matrix.platform.os }}
steps:
# Disable rustup override before checkout, so the toolchain state is clean before any workspace files or
# .rust-toolchain.toml are present. Prevents a stale override from affecting the toolchain resolution during
# checkout or subsequent steps.
- name: Disable rustup override
run: rustup override unset || true
- name: Checkout repository
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2
- name: Setup Circuits
uses: ./.github/actions/setup-circuits
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install cargo-hack
uses: taiki-e/install-action@5651179950649c44da31d346537e20c0534f0f25 # Version 2.49.35
with:
tool: cargo-hack
# Prune after Install cargo-hack, before Set up Cargo cache — frees disk space from the previous run's leftover
# artifacts (incremental compile dirs, fingerprints, build dirs) before the cache is restored. This means the
# restored cache lands onto a disk that has already been cleaned, maximizing the chance the restore succeeds
# without hitting disk limits.
- name: Prune disk space (cache-aware, self-hosted)
uses: ./.github/actions/prune-disk-space
- name: Set up Cargo cache
uses: ./.github/actions/setup-cargo-cache
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
key-prefix: cargo-hack/${{ matrix.platform.label }}
- name: Run Cargo Hack Check (Cache-Aware)
uses: ./.github/actions/cargo-hack-check-cached
- name: Update Cargo cache
if: success() || failure()
uses: ./.github/actions/update-cargo-cache
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
key-prefix: cargo-hack/${{ matrix.platform.label }}
- name: Clean up build artifacts
if: success() || failure()
uses: actions-rs/cargo@9e120dd99b0fbad1c065f686657e914e76bd7b72 # Version 1.0.1
with:
command: clean
- name: Create issue on failure
if: failure() && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
run: |
# Use gh CLI to create an issue.
# We check if an open issue with the same title already exists to avoid duplicates.
TITLE="Cargo Hack failed on ${{ matrix.platform.label }}"
EXISTING_ISSUE=$(gh issue list --search "$TITLE" --state open --json number --jq '.[0].number')
BODY="Cargo Hack check failed for platform: ${{ matrix.platform.label }}.
See details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
if [ -z "$EXISTING_ISSUE" ]; then
gh issue create --title "$TITLE" --body "$BODY" --label "bug" --label "automated-issue" --assignee "danielsanchezq,ntn-x2"
else
gh issue comment "$EXISTING_ISSUE" --body "Another failure occurred: $BODY"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}