name: Rust
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubicloud-standard-8
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 with:
cache-on-failure: "true"
- name: Install Rust
uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c with:
toolchain: stable
- name: Test supported feature boundaries
run: |
cargo test --no-default-features
cargo test
cargo test --no-default-features --features agent-control
cargo test --no-default-features --features ws-client
cargo test --no-default-features --features ws
cargo test --no-default-features --features full
cargo test --all-features
clippy_check:
runs-on: ubicloud-standard-8
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 with:
cache-on-failure: "true"
- name: Install Rust
uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c with:
toolchain: stable
components: clippy
- name: Lint supported feature boundaries
run: |
cargo clippy --all-targets --no-default-features -- -D warnings
cargo clippy --all-targets -- -D warnings
cargo clippy --all-targets --no-default-features --features agent-control -- -D warnings
cargo clippy --all-targets --no-default-features --features ws-client -- -D warnings
cargo clippy --all-targets --no-default-features --features ws -- -D warnings
cargo clippy --all-targets --no-default-features --features full -- -D warnings
cargo clippy --all-targets --all-features -- -D warnings
format_check:
runs-on: ubicloud-standard-8
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 with:
cache-on-failure: "true"
- name: Install Rust
uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c with:
toolchain: stable
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
security_audit:
runs-on: ubicloud-standard-2
permissions:
contents: read
checks: write
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 - name: Resolve current compatible dependencies for audit
run: cargo generate-lockfile
- uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 with:
token: ${{ secrets.GITHUB_TOKEN }}
publish:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [test, clippy_check, format_check, security_audit]
runs-on: ubicloud-standard-2
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c - name: Publish a reviewed version bump
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
BEFORE_SHA: ${{ github.event.before }}
run: |
if git diff --quiet "$BEFORE_SHA" "$GITHUB_SHA" -- Cargo.toml; then
echo "Cargo.toml did not change; nothing to publish"
exit 0
fi
cargo publish --registry crates-io