From a6f19210bf0466b61c343ba7f9b832db22b61420 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Mon, 23 Nov 2026 17:16:07 +0100 Subject: [PATCH 1/6] Add cargo-deny checks --- .github/workflows/cargo-deny-advisories.yaml | 101 +++++++++++++++++++ .github/workflows/cargo-deny.yaml | 50 +++++++++ 2 files changed, 151 insertions(+) create mode 100644 .github/workflows/cargo-deny-advisories.yaml create mode 100644 .github/workflows/cargo-deny.yaml diff --git a/.github/workflows/cargo-deny-advisories.yaml b/.github/workflows/cargo-deny-advisories.yaml new file mode 100644 index 0000000..c3332f6 --- /dev/null +++ b/.github/workflows/cargo-deny-advisories.yaml @@ -0,0 +1,101 @@ +# Check for cargo-deny advisories. +# +# This workflow should be called twice: +# +# - Once from a workflow that runs on every PR but only if +# dependencies are changed. This check can not be made required as +# it will trigger if no dependencies are changed e.g.: +# +# name: Cargo Deny Advisories +# +# on: +# pull_request: +# paths: +# - "**/Cargo.toml" +# - "**/Cargo.lock" +# - "**/deny.toml" +# push: +# branches: [main] +# paths: +# - "**/Cargo.toml" +# - "**/Cargo.lock" +# - "**/deny.toml" +# +# permissions: +# contents: read +# +# jobs: +# cargo-deny-advisories: +# name: Cargo Deny Advisories +# uses: "n0-computer/workflows/.github/workflows/cargo-deny-advisories.yaml@tag" +# +# And once from a daily workflow that reports to discord, e.g.: +# +# on: +# schedule: +# - cron: "0 2 * * *" +# workflow_dispatch: +# +# permissions: +# contents: read +# +# jobs: +# cargo-deny-advisories: +# name: Cargo Deny Advisories +# uses: "n0-computer/workflows/.github/workflows/cargo-deny-advisories.yaml@tag" +# secrets: +# DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL: ${{ secrets.DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL }} + +name: Cargo Deny Advisories + +on: + workflow_call: + secrets: + DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL: + description: | + Discord webhook to report failures to, if present. + required: false + +concurrency: + group: cargo-deny-advisories-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + advisories: + timeout-minutes: 30 + name: cargo deny advisories + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1 + with: + arguments: "--workspace --all-features" + command: check advisories + command-arguments: "-Dwarnings" + + notify: + timeout-minutes: 10 + needs: advisories + if: ${{ always() && needs.advisories.result == 'failure' }} + runs-on: ubuntu-latest + permissions: {} + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL }} + steps: + - name: Notify discord on failure + if: ${{ env.DISCORD_WEBHOOK_URL != '' }} + uses: n0-computer/discord-webhook-notify@1399c1b2d57cc05894d506d2cfdc33c5f012b993 # v1.1.1 + with: + severity: error + text: "cargo deny advisories in **${{ github.repository }}**:" + details: | + cargo deny found advisories for dependencies + See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + webhookUrl: ${{ env.DISCORD_WEBHOOK_URL }} diff --git a/.github/workflows/cargo-deny.yaml b/.github/workflows/cargo-deny.yaml new file mode 100644 index 0000000..e12c7ed --- /dev/null +++ b/.github/workflows/cargo-deny.yaml @@ -0,0 +1,50 @@ +# Run cargo-deny on pull requests. +# +# This workflow is meant to run on every PR. New advisories do not +# fail the job, cargo-deny-advisories.yaml is used to check those when +# dependencies change and periodically. +# +# Usage, re-using triggers from the calling workflow: +# +# jobs: +# cargo-deny: +# name: Cargo Deny +# uses: "n0-computer/workflows/.github/workflows/cargo-deny.yaml@tag" + +name: Cargo Deny + +on: + workflow_call: + +concurrency: + group: cargo-deny-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# Default to read-only; jobs that need more grant it explicitly. +permissions: + contents: read + +jobs: + cargo-deny: + timeout-minutes: 30 + name: cargo deny + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + fail-fast: false + matrix: + checks: + - advisories + - bans licenses sources + # Prevent sudden announcement of a new advisory from failing CI. + continue-on-error: ${{ matrix.checks == 'advisories' }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1 + with: + arguments: "--workspace --all-features" + command: check ${{ matrix.checks }} + command-arguments: "-Dwarnings" From 1877c0b76352a373361b32e8a010a58571045329 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Tue, 24 Nov 2026 17:17:55 +0100 Subject: [PATCH 2/6] only one workflow, only run it on PRs when they change deps --- .github/workflows/cargo-deny-advisories.yaml | 101 ------------------- .github/workflows/cargo-deny.yaml | 55 ++++++---- 2 files changed, 34 insertions(+), 122 deletions(-) delete mode 100644 .github/workflows/cargo-deny-advisories.yaml diff --git a/.github/workflows/cargo-deny-advisories.yaml b/.github/workflows/cargo-deny-advisories.yaml deleted file mode 100644 index c3332f6..0000000 --- a/.github/workflows/cargo-deny-advisories.yaml +++ /dev/null @@ -1,101 +0,0 @@ -# Check for cargo-deny advisories. -# -# This workflow should be called twice: -# -# - Once from a workflow that runs on every PR but only if -# dependencies are changed. This check can not be made required as -# it will trigger if no dependencies are changed e.g.: -# -# name: Cargo Deny Advisories -# -# on: -# pull_request: -# paths: -# - "**/Cargo.toml" -# - "**/Cargo.lock" -# - "**/deny.toml" -# push: -# branches: [main] -# paths: -# - "**/Cargo.toml" -# - "**/Cargo.lock" -# - "**/deny.toml" -# -# permissions: -# contents: read -# -# jobs: -# cargo-deny-advisories: -# name: Cargo Deny Advisories -# uses: "n0-computer/workflows/.github/workflows/cargo-deny-advisories.yaml@tag" -# -# And once from a daily workflow that reports to discord, e.g.: -# -# on: -# schedule: -# - cron: "0 2 * * *" -# workflow_dispatch: -# -# permissions: -# contents: read -# -# jobs: -# cargo-deny-advisories: -# name: Cargo Deny Advisories -# uses: "n0-computer/workflows/.github/workflows/cargo-deny-advisories.yaml@tag" -# secrets: -# DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL: ${{ secrets.DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL }} - -name: Cargo Deny Advisories - -on: - workflow_call: - secrets: - DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL: - description: | - Discord webhook to report failures to, if present. - required: false - -concurrency: - group: cargo-deny-advisories-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - contents: read - -jobs: - advisories: - timeout-minutes: 30 - name: cargo deny advisories - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1 - with: - arguments: "--workspace --all-features" - command: check advisories - command-arguments: "-Dwarnings" - - notify: - timeout-minutes: 10 - needs: advisories - if: ${{ always() && needs.advisories.result == 'failure' }} - runs-on: ubuntu-latest - permissions: {} - env: - DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL }} - steps: - - name: Notify discord on failure - if: ${{ env.DISCORD_WEBHOOK_URL != '' }} - uses: n0-computer/discord-webhook-notify@1399c1b2d57cc05894d506d2cfdc33c5f012b993 # v1.1.1 - with: - severity: error - text: "cargo deny advisories in **${{ github.repository }}**:" - details: | - cargo deny found advisories for dependencies - See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - webhookUrl: ${{ env.DISCORD_WEBHOOK_URL }} diff --git a/.github/workflows/cargo-deny.yaml b/.github/workflows/cargo-deny.yaml index e12c7ed..f7930bf 100644 --- a/.github/workflows/cargo-deny.yaml +++ b/.github/workflows/cargo-deny.yaml @@ -1,44 +1,37 @@ -# Run cargo-deny on pull requests. +# Check for cargo-deny advisories. # -# This workflow is meant to run on every PR. New advisories do not -# fail the job, cargo-deny-advisories.yaml is used to check those when -# dependencies change and periodically. +# This workflow is intended to be called twice: # -# Usage, re-using triggers from the calling workflow: +# - Once from a workflow that runs on every PR, but only if there are +# changes in Cargo.toml, Cargo.lock or deny.toml. Use the +# on.pull_request.paths selector to skip the workflow otherwise. # -# jobs: -# cargo-deny: -# name: Cargo Deny -# uses: "n0-computer/workflows/.github/workflows/cargo-deny.yaml@tag" +# - Once from a daily workflow that reports to discord. -name: Cargo Deny +name: Cargo Deny Advisories on: workflow_call: + secrets: + DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL: + description: | + Discord webhook to report failures to, if present. + required: false concurrency: group: cargo-deny-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -# Default to read-only; jobs that need more grant it explicitly. permissions: contents: read jobs: - cargo-deny: + deny: timeout-minutes: 30 name: cargo deny runs-on: ubuntu-latest permissions: contents: read - strategy: - fail-fast: false - matrix: - checks: - - advisories - - bans licenses sources - # Prevent sudden announcement of a new advisory from failing CI. - continue-on-error: ${{ matrix.checks == 'advisories' }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -46,5 +39,25 @@ jobs: - uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1 with: arguments: "--workspace --all-features" - command: check ${{ matrix.checks }} + command: check command-arguments: "-Dwarnings" + + notify: + timeout-minutes: 10 + needs: deny + if: ${{ always() && needs.deny.result == 'failure' }} + runs-on: ubuntu-latest + permissions: {} + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL }} + steps: + - name: Notify discord on failure + if: ${{ env.DISCORD_WEBHOOK_URL != '' }} + uses: n0-computer/discord-webhook-notify@1399c1b2d57cc05894d506d2cfdc33c5f012b993 # v1.1.1 + with: + severity: error + text: "cargo deny failure in **${{ github.repository }}**:" + details: | + cargo deny found problems for dependencies. + See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + webhookUrl: ${{ env.DISCORD_WEBHOOK_URL }} From d85de951aff4bd8bd57c51ce192353f032c78dcd Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Tue, 24 Nov 2026 17:32:00 +0100 Subject: [PATCH 3/6] fixup name --- .github/workflows/cargo-deny.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cargo-deny.yaml b/.github/workflows/cargo-deny.yaml index f7930bf..d7cd75e 100644 --- a/.github/workflows/cargo-deny.yaml +++ b/.github/workflows/cargo-deny.yaml @@ -8,7 +8,7 @@ # # - Once from a daily workflow that reports to discord. -name: Cargo Deny Advisories +name: Cargo Deny on: workflow_call: From 5d718e7d60d350125876c0b39fac0e2b5fd20cfa Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Wed, 25 Nov 2026 18:28:21 +0100 Subject: [PATCH 4/6] manually check for changed files i'm not a huge fan, but it'll do --- .github/workflows/cargo-deny.yaml | 54 +++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cargo-deny.yaml b/.github/workflows/cargo-deny.yaml index d7cd75e..a4032a8 100644 --- a/.github/workflows/cargo-deny.yaml +++ b/.github/workflows/cargo-deny.yaml @@ -2,9 +2,11 @@ # # This workflow is intended to be called twice: # -# - Once from a workflow that runs on every PR, but only if there are -# changes in Cargo.toml, Cargo.lock or deny.toml. Use the -# on.pull_request.paths selector to skip the workflow otherwise. +# - Once from a workflow that runs on every PR. On pull_request +# events cargo-deny only runs if the PR changes a Cargo.toml, +# Cargo.lock or deny.toml file, otherwise the jobs are skipped. This +# lets the check be marked as required. Set the always-run input to +# disable this and always run cargo-deny. # # - Once from a daily workflow that reports to discord. @@ -12,6 +14,14 @@ name: Cargo Deny on: workflow_call: + inputs: + always-run: + description: | + Always run cargo-deny, even on pull requests which do not + change any Cargo.toml, Cargo.lock or deny.toml files. + type: "boolean" + required: false + default: false secrets: DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL: description: | @@ -26,9 +36,47 @@ permissions: contents: read jobs: + changes: + timeout-minutes: 10 + name: check for dependency changes + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + deps: ${{ steps.filter.outputs.deps }} + steps: + # The PR merge commit's first parent is the base branch, so a + # depth of 2 is enough to diff the PR's changes. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + if: ${{ github.event_name == 'pull_request' && !inputs.always-run }} + with: + persist-credentials: false + fetch-depth: 2 + - name: Check for changed dependency files + id: filter + env: + EVENT_NAME: ${{ github.event_name }} + ALWAYS_RUN: ${{ inputs.always-run }} + run: | + if [ "$EVENT_NAME" != "pull_request" ] || [ "$ALWAYS_RUN" = "true" ]; then + echo "Not filtering on changed files" + echo "deps=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + changed=$(git diff --name-only HEAD^1 HEAD) + if grep -E '(^|/)(Cargo\.toml|Cargo\.lock|deny\.toml)$' <<< "$changed"; then + echo "Dependency files changed" + echo "deps=true" >> "$GITHUB_OUTPUT" + else + echo "No dependency files changed, skipping cargo-deny" + echo "deps=false" >> "$GITHUB_OUTPUT" + fi + deny: timeout-minutes: 30 name: cargo deny + needs: changes + if: ${{ needs.changes.outputs.deps == 'true' }} runs-on: ubuntu-latest permissions: contents: read From 774fc8707b5a6b1b07154e4a75424ca5ac5e4a11 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Thu, 26 Nov 2026 12:33:54 +0100 Subject: [PATCH 5/6] be more human --- .github/workflows/cargo-deny.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cargo-deny.yaml b/.github/workflows/cargo-deny.yaml index a4032a8..ff80661 100644 --- a/.github/workflows/cargo-deny.yaml +++ b/.github/workflows/cargo-deny.yaml @@ -15,10 +15,9 @@ name: Cargo Deny on: workflow_call: inputs: - always-run: + force: description: | - Always run cargo-deny, even on pull requests which do not - change any Cargo.toml, Cargo.lock or deny.toml files. + Always run cargo-deny, even on PRs with no deps or deny changes. type: "boolean" required: false default: false From a71404d1421ebbe6d07f131a3fb0eabcd057bc13 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Thu, 26 Nov 2026 12:37:04 +0100 Subject: [PATCH 6/6] fix stupid comments --- .github/workflows/cargo-deny.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cargo-deny.yaml b/.github/workflows/cargo-deny.yaml index ff80661..febdf63 100644 --- a/.github/workflows/cargo-deny.yaml +++ b/.github/workflows/cargo-deny.yaml @@ -2,13 +2,11 @@ # # This workflow is intended to be called twice: # -# - Once from a workflow that runs on every PR. On pull_request -# events cargo-deny only runs if the PR changes a Cargo.toml, -# Cargo.lock or deny.toml file, otherwise the jobs are skipped. This -# lets the check be marked as required. Set the always-run input to -# disable this and always run cargo-deny. +# - Once from a workflow that runs on every PR. Should only checks if +# dependencies or deny config has changed. # -# - Once from a daily workflow that reports to discord. +# - Once from a daily workflow that reports to discord. Should use the +# `force` option to always run the checks. name: Cargo Deny @@ -47,7 +45,7 @@ jobs: # The PR merge commit's first parent is the base branch, so a # depth of 2 is enough to diff the PR's changes. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - if: ${{ github.event_name == 'pull_request' && !inputs.always-run }} + if: ${{ github.event_name == 'pull_request' && !inputs.force }} with: persist-credentials: false fetch-depth: 2 @@ -55,7 +53,7 @@ jobs: id: filter env: EVENT_NAME: ${{ github.event_name }} - ALWAYS_RUN: ${{ inputs.always-run }} + ALWAYS_RUN: ${{ inputs.force }} run: | if [ "$EVENT_NAME" != "pull_request" ] || [ "$ALWAYS_RUN" = "true" ]; then echo "Not filtering on changed files"