Skip to content

Add cargo-deny checks - #12

Merged
flub merged 6 commits into
mainfrom
flub/deny
Nov 26, 2026
Merged

flub merged 6 commits into
mainfrom
flub/deny

Conversation

@flub

@flub flub commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Creates common workflows for deny checks. Also splits the deny checks
in two:

  • One to be run on every PR which does not fail for new
    advisories. This is just too disruptive for PRs and blocks us all
    the time.

  • One to be run daily or for PRs which modify dependencies.

I intend to switch over our main repos, starting with iroh, noq and
net-tools.

@flub
flub requested a review from Arqu November 23, 2026 16:23
@n0bot n0bot Bot added this to iroh Nov 23, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh Nov 23, 2026
@flub

flub commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

POC n0-computer/iroh#4714

#
# This workflow should be called twice:
#
# - Once from a workflow that runs on every PR but only if

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is quite verbose.

Comment thread .github/workflows/cargo-deny.yaml Resolved
@flub

flub commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Oh no. This way we can't make the check required of course because it is not run on every pr.

I guess we'd have to always run the workflow but skip the jobs if the files are not modified. Unfortunately github does not make this functionality available and you end up with using another thirdparty job or having to write some horrible shell script to detect the modified files. The latter is what I was trying to avoid before hence the way I had it split.

i'm not a huge fan, but it'll do
Arqu added a commit that referenced this pull request Nov 26, 2026
#13)

## Description

A caller that patches in a private GitHub repository cannot run
`minimal-crates.yaml`. The workflow takes no secrets, and the caller's
`env` does not reach a called workflow, so cargo fetches the repository
without credentials and fails:

```
fatal: could not read Username for 'https://github.com': No such file or directory
error: failed to load source for dependency `noq`
```

This PR:

- Adds an optional `GIT_TOKEN` secret to `minimal-crates.yaml`.
- Sets the token in the workflow-level `env`, so every job uses it. With
`GIT_TOKEN`, git rewrites `https://github.com/` to carry the token
(`GIT_CONFIG_*` env vars). Cargo fetches with the git CLI so that the
rewrite applies.
- Resets `credential.helper` to empty. With credentials in the URL, git
gives them to the credential helpers to store after each successful
fetch. On macOS, Homebrew git's `osxkeychain` helper blocks during
`actions/checkout`, which runs with a temporary `HOME`, and the job
hangs.
- Without `GIT_TOKEN`, `GIT_CONFIG_COUNT` is `0` and no URL changes. The
only change for current callers is that cargo fetches git dependencies
with the git CLI.
- Documents in the README that every shared workflow takes `GIT_TOKEN`.
A new shared workflow, such as `cargo-deny.yaml` in #12, must take it
too.

Usage:

```yaml
  min-crates:
    uses: "n0-computer/workflows/.github/workflows/minimal-crates.yaml@v2"
    secrets:
      GIT_TOKEN: ${{ secrets.MY_PRIVATE_REPO_TOKEN }}
```

## Testing

- With git and the same `GIT_CONFIG_*` values, with global config off
and a system config whose `credential.helper` blocks (like Homebrew's
`osxkeychain`):
- A private repository, a public repository and the `actions/checkout`
case (its `extraheader` plus the token in the URL) each fetch in about 1
s. Git does not call the helper.
- Without the `credential.helper` reset, git calls the helper's `store`
after each fetch and hangs. This matches the macOS hang in CI.
- `zizmor --offline .`: no findings.
- `actionlint`: same findings as on `main` (runner labels, `$/` action
refs, the Windows `cargo check` step). None comes from this change.
- A private caller with a private git dependency ran this workflow in
CI. Before the `credential.helper` reset, Ubuntu and Windows passed and
macOS hung in `actions/checkout`. At 507db95, Ubuntu, macOS and Windows
pass.

## Release

After merge: tag `v2.0.1` and move `v2`. `v2` does not have #11 yet, so
this release also ships the Windows target dir fix.
@flub

flub commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

PTAL, this now uses a single workflow and re-implements github's selection logic in a job so that the deny job can always be made required on a PR

@flub
flub merged commit 9811cd6 into main Nov 26, 2026
2 checks passed
@flub
flub deleted the flub/deny branch November 26, 2026 12:27
@github-project-automation github-project-automation Bot moved this from 🚑 Needs Triage to ✅ Done in iroh Nov 26, 2026
meefs pushed a commit to meefs/iroh that referenced this pull request Nov 26, 2026
## Description

This moves to the common cargo-deny workflow and makes sure deny
failures are only a problem if deps are modified.

It also fixes hickory-server semver breakage in the code and in the
semver CI check.

## API Changes

n/a

## Notes & open questions

Everything is verified to work, only needs to use the tag once
n0-computer/workflows#12 is merged and tagged:
- [x] update to workflow tag
- [ ] update required checks before merging


## Change checklist

- [x] Self-review.
- [x] Documentation updates following the [style guide], if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.

[style guide]:
https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text
git-blame-cat pushed a commit to git-blame-cat/iroh that referenced this pull request Nov 27, 2026
## Description

This moves to the common cargo-deny workflow and makes sure deny
failures are only a problem if deps are modified.

It also fixes hickory-server semver breakage in the code and in the
semver CI check.

## API Changes

n/a

## Notes & open questions

Everything is verified to work, only needs to use the tag once
n0-computer/workflows#12 is merged and tagged:
- [x] update to workflow tag
- [ ] update required checks before merging


## Change checklist

- [x] Self-review.
- [x] Documentation updates following the [style guide], if relevant.
- [x] Tests if relevant.
- [x] All API changes documented.
- [x] `cargo make` passes locally.

[style guide]:
https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants