chore: Update from _rust template

This commit is contained in:
Ed Page
2026-09-18 10:11:50 -05:00
15 changed files with 327 additions and 110 deletions
+44 -10
View File
@@ -1,13 +1,10 @@
name: Security audit
name: Audit
permissions:
contents: read
on:
pull_request:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
push:
branches:
- master
@@ -22,19 +19,38 @@ concurrency:
cancel-in-progress: true
jobs:
security_audit:
audit:
permissions:
contents: none
name: Audit
needs: [advisories, cargo_deny, actions]
runs-on: ubuntu-latest
if: "always()"
steps:
- name: Failed
run: exit 1
if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')"
advisories:
permissions:
issues: write # to create issues (actions-rs/audit-check)
checks: write # to create check (actions-rs/audit-check)
runs-on: ubuntu-latest
# Prevent sudden announcement of a new advisory from failing ci:
continue-on-error: true
strategy:
matrix:
checks:
- advisories
steps:
- name: Checkout repository
uses: actions/checkout@v6
- uses: actions-rs/audit-check@v1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Lint advisories
uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1
with:
command: check ${{ matrix.checks }}
rust-version: stable
cargo_deny:
permissions:
@@ -46,8 +62,26 @@ jobs:
checks:
- bans licenses sources
steps:
- uses: actions/checkout@v6
- uses: EmbarkStudios/cargo-deny-action@v2
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Lint bans
uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 # v2.1.1
with:
command: check ${{ matrix.checks }}
rust-version: stable
actions:
runs-on: ubuntu-latest
permissions:
security-events: write
contents: read # only needed for private or internal repos
actions: read # only needed for private or internal repos
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Run zizmor
uses: zizmorcore/zizmor-action@3dc1ecc9bcb9e94e9b2c709687979e1298497054 # v0.6.2
+73 -52
View File
@@ -14,6 +14,8 @@ env:
CARGO_TERM_COLOR: always
CLICOLOR: 1
COLUMNS: 130
CARGO_INCREMENTAL: 0
RUST_TOOLCHAIN_STABLE: "1.98" # STABLE
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
@@ -44,14 +46,17 @@ jobs:
CARGO_PROFILE_DEV_DEBUG: line-tables-only
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
toolchain: ${{ matrix.rust }}
components: rustfmt
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
persist-credentials: false
- name: Install Rust
run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
- name: Initialize cache
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Install cargo-hack
uses: taiki-e/install-action@37f7c5781271959fb65b6b35224e28652ff2b63d # v2.87.0
with:
tool: cargo-hack
- name: Build
run: cargo test --workspace --no-run
- name: Test
@@ -64,13 +69,17 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
persist-credentials: false
- name: Install Rust
run: rustup update --no-self-update stable && rustup default stable
- name: Initialize cache
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Install cargo-hack
uses: taiki-e/install-action@37f7c5781271959fb65b6b35224e28652ff2b63d # v2.87.0
with:
tool: cargo-hack
- name: Default features
run: cargo hack check --each-feature --locked --rust-version --ignore-private --workspace --all-targets --keep-going
wasm:
@@ -87,24 +96,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
toolchain: stable
targets: ${{ matrix.target }}
persist-credentials: false
- name: Install Rust
run: rustup toolchain install stable --target ${{ matrix.target }} && rustup default stable
- name: Default features
run: cargo check -p typos -p typos-dict
lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
persist-credentials: false
- name: Install Rust
run: rustup update --no-self-update stable && rustup default stable
- name: Initialize cache
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: "Is lockfile updated?"
run: cargo update --workspace --locked
docs:
@@ -112,28 +121,31 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
toolchain: "1.98" # STABLE
- uses: Swatinem/rust-cache@v2
persist-credentials: false
- name: Install Rust
run: rustup update --no-self-update $RUST_TOOLCHAIN_STABLE && rustup default $RUST_TOOLCHAIN_STABLE
- name: Initialize cache
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Check documentation
env:
RUSTDOCFLAGS: -D warnings
CARGO_BUILD_WARNINGS: deny
run: cargo doc --workspace --all-features --no-deps --document-private-items --keep-going
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
toolchain: "1.98" # STABLE
components: rustfmt
- uses: Swatinem/rust-cache@v2
persist-credentials: false
- name: Install Rust
run: rustup update --no-self-update $RUST_TOOLCHAIN_STABLE && rustup default $RUST_TOOLCHAIN_STABLE
- name: Install rustfmt
run: rustup component add rustfmt
- name: Initialize cache
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Check formatting
run: cargo fmt --check
clippy:
@@ -143,13 +155,15 @@ jobs:
security-events: write # to upload sarif results
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
toolchain: "1.98" # STABLE
components: clippy
- uses: Swatinem/rust-cache@v2
persist-credentials: false
- name: Install Rust
run: rustup update --no-self-update $RUST_TOOLCHAIN_STABLE && rustup default $RUST_TOOLCHAIN_STABLE
- name: Install clippy
run: rustup component add clippy
- name: Initialize cache
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Install SARIF tools
run: cargo install clippy-sarif --locked
- name: Install SARIF tools
@@ -162,28 +176,35 @@ jobs:
| sarif-fmt
continue-on-error: true
- name: Upload
uses: github/codeql-action/upload-sarif@v4
uses: github/codeql-action/upload-sarif@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
with:
sarif_file: clippy-results.sarif
wait-for-processing: true
- name: Report status
run: cargo clippy --workspace --all-features --all-targets --keep-going -- -D warnings --allow deprecated
env:
CARGO_BUILD_WARNINGS: deny
run: cargo clippy --workspace --all-features --all-targets --keep-going -- --allow deprecated --allow renamed_and_removed_lints
coverage:
name: Coverage
runs-on: ubuntu-latest
permissions:
code-quality: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
persist-credentials: false
- name: Install Rust
run: rustup update --no-self-update stable && rustup default stable
- name: Initialize cache
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Gather coverage
run: cargo tarpaulin --output-dir coverage --out lcov
- name: Publish to Coveralls
uses: coverallsapp/github-action@master
run: cargo tarpaulin --out xml
- name: Upload coverage report
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: actions/upload-code-coverage@d8e329117199404bba6fc81efe8093dc7c015e34 # v1.4.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: cobertura.xml
language: Rust
+5 -3
View File
@@ -20,9 +20,11 @@ jobs:
name: Lint Commits
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v6
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
filter: "tree:0"
persist-credentials: false
- name: Lint Commits
uses: crate-ci/committed@master
uses: crate-ci/committed@faeed42f2e10c244533a01525f13c4d8b6ce383f # v1.1.11
+29 -23
View File
@@ -14,6 +14,10 @@
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/
name: post-release
permissions:
contents: read
on:
push:
tags:
@@ -23,36 +27,37 @@ on:
env:
BIN_NAME: typos
# We need this to be able to create releases.
permissions:
contents: write
jobs:
create-release:
permissions:
contents: write
name: create-release
runs-on: ubuntu-latest
outputs:
tag: ${{ env.TAG }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 1
persist-credentials: false
- name: Get the release version from the tag
if: env.TAG == ''
run: echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV
run: echo "TAG=${GITHUB_REF_NAME}" >> $GITHUB_ENV
- name: Show the tag
run: |
echo "tag is: $TAG"
- name: Generate Release Notes
run: |
./.github/workflows/release-notes.py --tag ${{ env.TAG }} --output notes-${{ env.TAG }}.md
cat notes-${{ env.TAG }}.md
./.github/workflows/release-notes.py --tag ${TAG} --output notes-${TAG}.md
cat notes-${TAG}.md
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create $TAG --verify-tag --draft --title $TAG --notes-file notes-${{ env.TAG }}.md
run: gh release create $TAG --verify-tag --draft --title $TAG --notes-file notes-${TAG}.md
build-release:
permissions:
contents: write
name: build-release
needs: create-release
strategy:
@@ -83,26 +88,24 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 1
persist-credentials: false
- name: Install packages (Ubuntu)
if: matrix.build == 'linux' || matrix.build == 'linux-aarch64'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends xz-utils liblz4-tool musl-tools
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
run: rustup toolchain install ${{ matrix.rust }} --target ${{ matrix.target }} && rustup default ${{ matrix.rust }}
- name: Build release binary
run: cargo build --target ${{ matrix.target }} --verbose --release
- name: Build archive
shell: bash
run: |
outdir="./target/${{ matrix.target }}/release"
staging="${{ env.BIN_NAME }}-${{ needs.create-release.outputs.tag }}-${{ matrix.target }}"
staging="${{ env.BIN_NAME }}-${NEEDS_CREATE_RELEASE_OUTPUTS_TAG}-${{ matrix.target }}"
mkdir -p "$staging"/doc
cp {README.md,LICENSE-*} "$staging/"
cp {CHANGELOG.md,docs/*} "$staging/doc/"
@@ -118,27 +121,30 @@ jobs:
tar czf "$staging.tar.gz" -C "$staging" .
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
env:
NEEDS_CREATE_RELEASE_OUTPUTS_TAG: ${{ needs.create-release.outputs.tag }}
- name: Upload release archive
env:
GH_TOKEN: ${{ github.token }}
NEEDS_CREATE_RELEASE_OUTPUTS_TAG: ${{ needs.create-release.outputs.tag }}
shell: bash
run: |
tag="${{ needs.create-release.outputs.tag }}"
gh release upload "$tag" ${{ env.ASSET }}
tag="${NEEDS_CREATE_RELEASE_OUTPUTS_TAG}"
gh release upload "$tag" ${ASSET}
publish-release:
permissions:
contents: write
name: Publish Release
needs: [create-release, build-release]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 1
persist-credentials: false
- name: Publish Release
env:
GH_TOKEN: ${{ github.token }}
run: gh release edit "${{ needs.create-release.outputs.tag }}" --draft=false
- name: Update major tag
uses: rickstaa/action-update-semver@v1
with:
major_version_tag_only: true
NEEDS_CREATE_RELEASE_OUTPUTS_TAG: ${{ needs.create-release.outputs.tag }}
run: gh release edit "${NEEDS_CREATE_RELEASE_OUTPUTS_TAG}" --draft=false
+13 -1
View File
@@ -22,7 +22,19 @@ jobs:
contents: read
runs-on: ubuntu-latest
steps:
<<<<<<< HEAD
- uses: actions/checkout@v6
- uses: j178/prek-action@v2
||||||| e4f2b351
- uses: actions/checkout@v6
- uses: j178/prek-action@v1
=======
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
>>>>>>> _rust/main
with:
prek-version: '0.2.27'
persist-credentials: false
- name: prek
uses: j178/prek-action@4e14d07f9231acabce116ccfca13b13dd9755ece # v3.0.0
with:
prek-version: '0.5.0'
+39 -6
View File
@@ -11,7 +11,12 @@ env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CLICOLOR: 1
<<<<<<< HEAD
COLUMNS: 130
||||||| e4f2b351
=======
CARGO_INCREMENTAL: 0
>>>>>>> _rust/main
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
@@ -34,14 +39,28 @@ jobs:
CARGO_PROFILE_DEV_DEBUG: line-tables-only
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
<<<<<<< HEAD
toolchain: ${{ matrix.rust }}
components: rustfmt
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
||||||| e4f2b351
toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
=======
persist-credentials: false
- name: Install Rust
run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
- name: Initialize cache
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Install cargo-hack
uses: taiki-e/install-action@37f7c5781271959fb65b6b35224e28652ff2b63d # v2.87.0
with:
tool: cargo-hack
>>>>>>> _rust/main
- name: Build
run: cargo test --workspace --no-run
- name: Test
@@ -56,14 +75,28 @@ jobs:
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: allow
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
<<<<<<< HEAD
toolchain: stable
components: rustfmt
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
||||||| e4f2b351
toolchain: stable
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
=======
persist-credentials: false
- name: Install Rust
run: rustup update --no-self-update stable && rustup default stable
- name: Initialize cache
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Install cargo-hack
uses: taiki-e/install-action@37f7c5781271959fb65b6b35224e28652ff2b63d # v2.87.0
with:
tool: cargo-hack
>>>>>>> _rust/main
- name: Update dependencies
run: cargo update
- name: Build
+3 -2
View File
@@ -28,12 +28,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: true # to push the branch and create PR
- name: Configure git
run: |
git config --global user.name '${{ github.actor }}'
git config --global user.name '${GITHUB_ACTOR}'
git config --global user.email '<>'
- name: Fetch template
run: "git remote add template ${{ env.TEMPLATE_URL }} && git fetch template ${{ env.TEMPLATE_BRANCH }}"