mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
This patch-set aims to make several improvements to our CI caching: 1. Use of registry as build cache: Pushes a separate image to our docker registry at GCP that contains the cache layers. This happens for every PR & main. As a result, we can restore from **both** which should make repeated runs of CI on an individual PR faster and give us a good baseline cache for new PRs from `main`. See https://docs.docker.com/build/ci/github-actions/cache/#registry-cache for details. As a nice side-effect, this allows us to use the 10 GB we have on GitHub actions for other jobs. 2. We make better use of `restore-keys` by also attempting to restore the cache if the fingerprint of our lockfiles doesn't match. This is useful for CI runs that upgrade dependencies. Those will restore a cache that is still useful although doesn't quite match. That is better[^1] than not hitting the cache at all. 3. There were two tiny bugs in our Swift and Android builds: a. We used `rustup show` in the wrong directory and thus did not actually install the toolchain properly. b. We used `shared-key` instead of `key` for the https://github.com/Swatinem/rust-cache action and thus did not differentiate between jobs properly. 5. Our Dockerfile for Rust had a bug where it did not copy in the `rust-toolchain.toml` file in the `chef` layer and thus also did not use the correctly toolchain. 6. We remove the dedicated gradle cache because the build action already comes with a cache configuration: https://github.com/firezone/firezone/actions/runs/6416847209/job/17421412150#step:10:25 [^1]: Over time, this may mean that our caches grow a bit. In an ideal world, we automatically remove files from the caches that haven't been used in a while. The cache action we use for Rust does that automatically: https://github.com/Swatinem/rust-cache?tab=readme-ov-file#cache-details. As a workaround, we can just purge all caches every now and then. --------- Signed-off-by: Jamil <jamilbk@users.noreply.github.com> Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
65 lines
1.8 KiB
YAML
65 lines
1.8 KiB
YAML
name: Rust
|
|
on:
|
|
workflow_call:
|
|
|
|
# Cancel old workflow runs if new code is pushed
|
|
concurrency:
|
|
group: "rust-${{ github.workflow }}-${{ github.ref }}"
|
|
cancel-in-progress: true
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: ./rust
|
|
|
|
jobs:
|
|
test:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
runs-on:
|
|
# We only need to run unit tests on one OS version.
|
|
# Saves cache size.
|
|
- ubuntu-latest
|
|
- macos-13
|
|
- windows-2022
|
|
# TODO: https://github.com/rust-lang/cargo/issues/5220
|
|
include:
|
|
- runs-on: ubuntu-latest
|
|
packages: -p firezone-headless-client -p firezone-gateway -p connlib-client-android
|
|
- 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
|
|
- name: Update toolchain
|
|
run: rustup show
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: ./rust
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- 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
|
|
- run: cargo test --all-features ${{ matrix.packages }}
|
|
|
|
smoke-test-relay:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ./rust/relay
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Update toolchain
|
|
run: rustup show
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: ./rust
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
- run: ./run_smoke_test.sh
|