Skip to content
Closed
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
66 changes: 38 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ env:
RUSTFLAGS: "-D warnings"
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
# Override .cargo/config.toml target-cpu=native to prevent SIGILL on different runners
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: ""

jobs:
# ===========================================================================
Expand All @@ -36,26 +36,28 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # stable
with:
toolchain: stable

- name: Configure sccache
uses: mozilla-actions/sccache-action@v0.0.6
uses: mozilla-actions/sccache-action@9e326ebed976843c9932b3aa0e021c6f50310eb4 # v0.0.6

- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
with:
prefix-key: "v1-build"
shared-key: "${{ matrix.os }}"
cache-on-failure: true

- name: Build
run: cargo build --release --locked
run: cargo build --release

- name: Build (all features)
run: cargo build --release --all-features --locked
run: cargo build --release --all-features

# ===========================================================================
# GATE 2: Lint with Clippy
Expand All @@ -65,24 +67,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # stable
with:
toolchain: stable
components: clippy

- name: Configure sccache
uses: mozilla-actions/sccache-action@v0.0.6
uses: mozilla-actions/sccache-action@9e326ebed976843c9932b3aa0e021c6f50310eb4 # v0.0.6

- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
with:
prefix-key: "v1-lint"
cache-on-failure: true

- name: Run Clippy
run: cargo clippy --all-targets --all-features --locked -- -D warnings
run: cargo clippy --all-targets --all-features -- -D warnings

# ===========================================================================
# GATE 3: Format Check
Expand All @@ -92,11 +95,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # stable
with:
toolchain: stable
components: rustfmt

- name: Check formatting
Expand All @@ -114,26 +118,28 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # stable
with:
toolchain: stable

- name: Configure sccache
uses: mozilla-actions/sccache-action@v0.0.6
uses: mozilla-actions/sccache-action@9e326ebed976843c9932b3aa0e021c6f50310eb4 # v0.0.6

- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
with:
prefix-key: "v1-test"
shared-key: "${{ matrix.os }}"
cache-on-failure: true

- name: Run tests
run: cargo test --all-features --locked
run: cargo test --all-features

- name: Run doc tests
run: cargo test --doc --locked
run: cargo test --doc

# ===========================================================================
# Documentation Build
Expand All @@ -143,22 +149,24 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # stable
with:
toolchain: stable

- name: Configure sccache
uses: mozilla-actions/sccache-action@v0.0.6
uses: mozilla-actions/sccache-action@9e326ebed976843c9932b3aa0e021c6f50310eb4 # v0.0.6

- name: Cache Rust artifacts
uses: Swatinem/rust-cache@v2
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
with:
prefix-key: "v1-docs"
cache-on-failure: true

- name: Build documentation
run: cargo doc --no-deps --all-features --locked
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: "-D warnings"

Expand All @@ -170,10 +178,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # stable
with:
toolchain: stable

- name: Install cargo-audit
run: cargo install cargo-audit --locked
Expand Down
60 changes: 50 additions & 10 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,45 @@ on:

env:
CARGO_TERM_COLOR: always
# Override .cargo/config.toml target-cpu=native to prevent SIGILL on different runners
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: ""

jobs:
cargo-audit:
name: "Cargo Audit"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # stable
with:
toolchain: stable

- name: Install cargo-audit
run: cargo install cargo-audit --locked

- name: Run security audit
run: cargo audit --deny warnings
run: |
# Run audit and capture output
cargo audit --json > audit.json 2>&1 || true

# Check for critical/high severity vulnerabilities only
CRITICAL=$(jq '[.vulnerabilities.list[]? | select(.advisory.severity == "critical")] | length' audit.json 2>/dev/null || echo "0")
HIGH=$(jq '[.vulnerabilities.list[]? | select(.advisory.severity == "high")] | length' audit.json 2>/dev/null || echo "0")

echo "Critical vulnerabilities: $CRITICAL"
echo "High vulnerabilities: $HIGH"

# Fail only on critical/high (warnings handled by cargo-deny)
if [ "$CRITICAL" -gt 0 ] || [ "$HIGH" -gt 0 ]; then
echo "❌ Critical or high severity vulnerabilities found"
cat audit.json | jq '.vulnerabilities.list[]? | select(.advisory.severity == "critical" or .advisory.severity == "high")'
exit 1
fi

echo "✅ No critical/high vulnerabilities found"

cargo-deny:
name: "Cargo Deny"
Expand All @@ -40,38 +62,48 @@ jobs:
checks: [advisories, licenses, bans, sources]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4

- name: Run cargo-deny (${{ matrix.checks }})
uses: EmbarkStudios/cargo-deny-action@v1
uses: EmbarkStudios/cargo-deny-action@3f4a782664881cf5725d0ffd23969fcce89fd868 # v1
with:
log-level: warn
command: check ${{ matrix.checks }}

gitleaks:
name: "Secret Scanning"
runs-on: ubuntu-latest
# Note: Gitleaks requires GITLEAKS_LICENSE for organization repos
# This step continues on error to not block CI for org repos without license
continue-on-error: true

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4
with:
fetch-depth: 0

- name: Run Gitleaks
uses: gitleaks/gitleaks-action@v2
uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}

- name: Gitleaks license info
if: failure()
run: |
echo "::notice::Gitleaks requires GITLEAKS_LICENSE secret for organization repos."
echo "::notice::See: https://github.com/gitleaks/gitleaks-action#environment-variables"

dependency-review:
name: "Dependency Review"
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4

- name: Dependency Review
uses: actions/dependency-review-action@v4
uses: actions/dependency-review-action@3c4e3dcb1aa7874d2c16be7d79418e9b7efd6261 # v4
with:
fail-on-severity: moderate
deny-licenses: GPL-3.0, AGPL-3.0
Expand All @@ -91,4 +123,12 @@ jobs:
echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Cargo Audit | ${{ needs.cargo-audit.result == 'success' && '✅ Pass' || '❌ Fail' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Cargo Deny | ${{ needs.cargo-deny.result == 'success' && '✅ Pass' || '❌ Fail' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Secret Scanning | ${{ needs.gitleaks.result == 'success' && '✅ Pass' || '❌ Fail' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Secret Scanning | ${{ needs.gitleaks.result == 'success' && '✅ Pass' || '⚠️ Skipped (license)' }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

if [ "${{ needs.cargo-audit.result }}" = "success" ] && \
[ "${{ needs.cargo-deny.result }}" = "success" ]; then
echo "✅ **All required security checks passed!**" >> $GITHUB_STEP_SUMMARY
else
echo "⚠️ **Some security checks failed. Review above.**" >> $GITHUB_STEP_SUMMARY
fi
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
- uses: actions/stale@v10
with:
stale-issue-message: |
This issue has been automatically marked as stale because it has not had recent activity.
Expand Down
Loading
Loading