Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/actions/rust-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# spell-checker:ignore Swatinem sccache
name: Rust cache
description: Cache Rust dependencies and enable sccache.

inputs:
key:
description: Cache namespace for compatible jobs and target layouts.
required: false
default: ""
workspaces:
description: Cargo workspaces.
required: false
default: ". -> target"
cache-targets:
description: Cache target directories.
required: false
default: "true"
save-if:
description: Save the cache.
required: false
default: "true"
sccache:
description: Enable sccache.
required: false
default: "true"

runs:
using: composite
steps:
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
# The workflow supplies an explicit namespace so compatible jobs can
# share a cache without accidentally mixing target directory layouts.
shared-key: ${{ inputs.key }}
workspaces: ${{ inputs.workspaces }}
cache-targets: ${{ inputs.cache-targets }}
save-if: ${{ inputs.save-if == 'true' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}

- name: Setup sccache
id: sccache-setup
if: inputs.sccache == 'true'
uses: mozilla-actions/sccache-action@v0.0.11
continue-on-error: true

- name: Export sccache
if: inputs.sccache == 'true' && steps.sccache-setup.outcome == 'success'
shell: bash
run: |
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
Comment thread
anastygnome marked this conversation as resolved.
Resolved
echo "SCCACHE_GHA_RW_MODE=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && 'READ_WRITE' || 'READ_ONLY' }}" >> "$GITHUB_ENV"
169 changes: 62 additions & 107 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ permissions:
# End the current execution if there is a new changeset in the PR.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}

jobs:
cargo-deny:
Expand All @@ -48,6 +48,7 @@ jobs:
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
max-parallel: 2
matrix:
job:
# note: `cargo-udeps` panics when processing stdbuf/libstdbuf ("uu_stdbuf_libstdbuf"); either b/c of the 'cpp' crate or 'libstdbuf' itself
Expand All @@ -59,10 +60,11 @@ jobs:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: taiki-e/install-action@v2
- uses: taiki-e/install-action@cargo-udeps
- uses: ./.github/actions/rust-cache
with:
tool: cargo-udeps
- uses: Swatinem/rust-cache@v2
key: deps-${{ matrix.job.os }}-${{ matrix.job.features }}
sccache: false
- name: Initialize workflow variables
id: vars
shell: bash
Expand Down Expand Up @@ -110,16 +112,9 @@ jobs:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
id: sccache-setup
uses: mozilla-actions/sccache-action@v0.0.11
continue-on-error: true
- name: Export sccache
if: steps.sccache-setup.outcome == 'success'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
- uses: ./.github/actions/rust-cache
with:
key: docs-${{ matrix.job.os }}-${{ matrix.job.features }}
- name: Install/setup prerequisites
shell: bash
run: |
Expand Down Expand Up @@ -157,6 +152,7 @@ jobs:
name: MinRustV # Minimum supported rust version (aka, MinSRV or MSRV)
runs-on: ${{ matrix.job.os }}
strategy:
max-parallel: 2
matrix:
job:
- { os: ubuntu-latest , features: feat_os_unix }
Expand All @@ -170,19 +166,10 @@ jobs:
with:
toolchain: ${{ env.RUST_MIN_SRV }}
components: rustfmt
- uses: taiki-e/install-action@v2
- uses: taiki-e/install-action@nextest
- uses: ./.github/actions/rust-cache
with:
tool: nextest
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
id: sccache-setup
uses: mozilla-actions/sccache-action@v0.0.11
continue-on-error: true
- name: Export sccache
if: steps.sccache-setup.outcome == 'success'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
key: msrv-${{ matrix.job.features }}
- name: Initialize workflow variables
id: vars
shell: bash
Expand Down Expand Up @@ -254,12 +241,7 @@ jobs:

deps:
name: Dependencies
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
- { os: ubuntu-latest , features: feat_os_unix }
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
with:
Expand All @@ -282,6 +264,7 @@ jobs:
timeout-minutes: 90
strategy:
fail-fast: false
max-parallel: 2
matrix:
job:
- { os: ubuntu-latest , name: feat_os_unix , features: feat_os_unix }
Expand All @@ -294,19 +277,10 @@ jobs:
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@v2
- uses: taiki-e/install-action@nextest
- uses: ./.github/actions/rust-cache
with:
tool: nextest
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
id: sccache-setup
uses: mozilla-actions/sccache-action@v0.0.11
continue-on-error: true
- name: Export sccache
if: steps.sccache-setup.outcome == 'success'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
key: stable-${{ matrix.job.os }}-${{ matrix.job.features }}
- name: Test
run: cargo nextest run --hide-progress-bar --profile ci --features ${{ matrix.job.features }}
env:
Expand All @@ -329,6 +303,7 @@ jobs:
timeout-minutes: 90
strategy:
fail-fast: false
max-parallel: 2
matrix:
job:
- { os: ubuntu-latest , features: feat_os_unix }
Expand All @@ -339,19 +314,10 @@ jobs:
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@nightly
- uses: taiki-e/install-action@v2
- uses: taiki-e/install-action@nextest
- uses: ./.github/actions/rust-cache
with:
tool: nextest
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
id: sccache-setup
uses: mozilla-actions/sccache-action@v0.0.11
continue-on-error: true
- name: Export sccache
if: steps.sccache-setup.outcome == 'success'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
key: nightly-${{ matrix.job.os }}-${{ matrix.job.features }}
- name: Test
run: cargo nextest run --hide-progress-bar --profile ci --features ${{ matrix.job.features }}
env:
Expand Down Expand Up @@ -427,18 +393,11 @@ jobs:
with:
toolchain: ${{ env.RUST_MIN_SRV }}
targets: ${{ matrix.job.target }}
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/rust-cache
with:
key: "${{ matrix.job.os }}_${{ matrix.job.target }}"
- name: Run sccache-cache
id: sccache-setup
uses: mozilla-actions/sccache-action@v0.0.11
continue-on-error: true
- name: Export sccache
if: steps.sccache-setup.outcome == 'success'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
# These jobs pass --target explicitly, so keep their target/<triple>
# cache separate from the implicit-host target/debug caches above.
key: build-${{ matrix.job.os }}-${{ matrix.job.target }}-${{ matrix.job.features }}-${{ matrix.job.default-features }}-${{ matrix.job.use-cross }}
- name: Initialize workflow variables
id: vars
shell: bash
Expand Down Expand Up @@ -744,16 +703,9 @@ jobs:
- uses: taiki-e/install-action@v2
with:
tool: nextest,grcov@0.8.24
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
id: sccache-setup
uses: mozilla-actions/sccache-action@v0.0.11
continue-on-error: true
- name: Export sccache
if: steps.sccache-setup.outcome == 'success'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
- uses: ./.github/actions/rust-cache
with:
key: coverage-${{ matrix.job.os }}-${{ matrix.job.features }}

# - name: Reattach HEAD ## may be needed for accurate code coverage info
# run: git checkout ${{ github.head_ref }}
Expand Down Expand Up @@ -866,19 +818,10 @@ jobs:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: taiki-e/install-action@v2
- uses: taiki-e/install-action@nextest
- uses: ./.github/actions/rust-cache
with:
tool: nextest
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
id: sccache-setup
uses: mozilla-actions/sccache-action@v0.0.11
continue-on-error: true
- name: Export sccache
if: steps.sccache-setup.outcome == 'success'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
key: openssl-${{ matrix.job.os }}-${{ matrix.job.features }}
- name: Test checksum utilities with OpenSSL (system / dynamic)
shell: bash
env:
Expand All @@ -897,19 +840,10 @@ jobs:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: taiki-e/install-action@v2
- uses: taiki-e/install-action@nextest
- uses: ./.github/actions/rust-cache
with:
tool: nextest
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
id: sccache-setup
uses: mozilla-actions/sccache-action@v0.0.11
continue-on-error: true
- name: Export sccache
if: steps.sccache-setup.outcome == 'success'
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
key: no-diagnostics
# The caret diagnostics (`feat_diagnostics`) are on by default; packagers
# who want the smaller dependency tree build with them off, so that build
# must stay green. The caret snapshot tests are gated on the feature and
Expand Down Expand Up @@ -944,8 +878,9 @@ jobs:
- name: Setup Lima
uses: lima-vm/lima-actions/setup@v1
id: lima-actions-setup
- name: Cache ~/.cache/lima
uses: actions/cache@v6
- name: Restore Lima cache
id: lima-cache
uses: actions/cache/restore@v6
with:
path: ~/.cache/lima
key: lima-${{ steps.lima-actions-setup.outputs.version }}
Expand All @@ -963,6 +898,14 @@ jobs:
run: |
lima ls
lima bash -c "cd work && cargo test --features 'feat_selinux' --no-default-features"
- name: Lint with SELinux
run: lima bash -c "cd work && cargo clippy --all-targets --features 'feat_selinux' --no-default-features -- -D warnings"
- name: Save Lima cache
if: steps.lima-cache.outputs.cache-hit != 'true' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: actions/cache/save@v6
with:
path: ~/.cache/lima
key: lima-${{ steps.lima-actions-setup.outputs.version }}

test_safe_traversal:
name: Safe Traversal Security Check
Expand All @@ -973,7 +916,10 @@ jobs:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/rust-cache
with:
key: safe-traversal
sccache: false
- name: Install strace and libselinux headers (needed to build chcon)
run: sudo apt-get update && sudo apt-get install -y strace libselinux1-dev
- name: Build utilities with safe traversal
Expand All @@ -990,7 +936,10 @@ jobs:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/rust-cache
with:
key: libc-interposition
sccache: false
- name: Install fakeroot
run: sudo apt-get update && sudo apt-get install -y fakeroot
- name: Build utilities that must stay interposable
Expand All @@ -1007,7 +956,10 @@ jobs:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/rust-cache
with:
key: open-once
sccache: false
- name: Install strace
run: sudo apt-get update && sudo apt-get install -y strace
- name: Build utilities for redundant open checks
Expand All @@ -1024,7 +976,10 @@ jobs:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: Swatinem/rust-cache@v2
- uses: ./.github/actions/rust-cache
with:
key: toctou
sccache: false
- name: Install strace
run: sudo apt-get update && sudo apt-get install -y strace
- name: Build utilities for TOCTOU checks
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CheckScripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
# End the current execution if there is a new changeset in the PR.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}

jobs:
shell_check:
Expand Down
Loading
Loading