name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
persist-credentials: false
- name: Install Rust (stable)
run: rustup toolchain install stable --profile minimal && rustup default stable
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-test-${{ hashFiles('Cargo.lock') }}
- name: Check
run: cargo check
- name: Test
run: cargo test
- name: Clippy
run: cargo clippy -- -D warnings
- name: Format check
run: cargo fmt -- --check
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
persist-credentials: false
- name: Install Rust (stable)
run: rustup toolchain install stable --profile minimal && rustup default stable
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-e2e-${{ hashFiles('Cargo.lock') }}
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 with:
python-version: '3.12'
- name: Install scanners
run: |
pip install semgrep
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
curl -sSfL https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz | tar -xz -C /tmp gitleaks
sudo mv /tmp/gitleaks /usr/local/bin/gitleaks
- name: Verify scanners
run: cargo run -- doctor
- name: Warm trivy vulnerability DB
run: trivy fs --quiet --format json --scanners vuln Cargo.lock > /dev/null
- name: E2E tests (vulnerable-sample-app, all scanners required)
run: cargo test --test integration_test
env:
SHIPSAFE_REQUIRE_SCANNERS: '1'
build:
needs: test
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
persist-credentials: false
- name: Install Rust (stable)
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup target add ${{ matrix.target }}
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with:
name: shipsafe-${{ matrix.target }}
path: target/${{ matrix.target }}/release/shipsafe
zizmor:
name: Audit workflows (zizmor)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 with:
python-version: '3.12'
- name: Install zizmor
run: pip install zizmor==1.25.2
- name: Run zizmor
env:
GH_TOKEN: ${{ github.token }}
run: zizmor .github/workflows/