Files
firezone/.github/workflows/rust.yml
Jamil 2a99cc39e9 Install and cache Rust toolchain (#2353)
On GH-hosted runners, this isn't a problem. But on self-hosted runners
with persistent disks, we hit this issue:
https://github.com/Swatinem/rust-cache#known-issues

This PR should fix that by ensuring the Rust toolchain is installed. It
also installs the toolchain after the cache has been restored so we can
take advantage of any cached artifacts.
2023-10-16 11:16:18 -06:00

89 lines
2.8 KiB
YAML

name: Rust
on:
workflow_call:
defaults:
run:
working-directory: ./rust
jobs:
static-analysis:
strategy:
fail-fast: false
matrix:
runs-on:
# We only need to run static analysis checks per OS family
- ubuntu-22.04
- macos-13
- windows-2022
# TODO: https://github.com/rust-lang/cargo/issues/5220
include:
- runs-on: ubuntu-22.04
packages: # Intentionally blank as a package catch-all linter
- runs-on: macos-13
packages: -p connlib-client-apple
- runs-on: windows-2022
packages: -p connlib-client-shared
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
workspaces: ./rust
save-if: ${{ github.ref == 'refs/heads/main' }}
key: ${{ matrix.runs-on }}-${{ runner.arch }}
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt,clippy
- run: cargo fmt -- --check
- run: |
cargo doc --all-features --no-deps --document-private-items ${{ matrix.packages }}
env:
RUSTDOCFLAGS: "-D warnings"
- run: |
cargo clippy --all-targets --all-features ${{ matrix.packages }} -- -D warnings
test:
strategy:
fail-fast: false
matrix:
# TODO: https://github.com/rust-lang/cargo/issues/5220
include:
- runs-on: ubuntu-20.04
packages: -p firezone-headless-client -p firezone-gateway -p connlib-client-android
- runs-on: ubuntu-22.04
packages: -p firezone-headless-client -p firezone-gateway -p connlib-client-android
- runs-on: macos-12
packages: -p connlib-client-apple
- runs-on: macos-13
packages: -p connlib-client-apple
- runs-on: windows-2019
packages: -p connlib-client-shared
- runs-on: windows-2022
packages: -p connlib-client-shared
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
# Prevents runner.os caches from conflicting
key: ${{ matrix.runs-on }}-${{ runner.arch }}
workspaces: ./rust
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --all-features ${{ matrix.packages }}
smoke-test-relay:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./rust/relay
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
workspaces: ./rust
key: ubuntu-22.04-${{ runner.arch }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: dtolnay/rust-toolchain@stable
- run: ./run_smoke_test.sh