mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
Running only the unit-tests of select crates on some platforms is problematic. We are unlikely to update this list of crates as we introduce new ones. It is a better default to run the tests of all crates on all platforms and selectively exclude the ones that can't run because they are unsupported.
104 lines
4.0 KiB
YAML
104 lines
4.0 KiB
YAML
---
|
|
name: "Setup Rust"
|
|
description: "Sets up the correct Rust version and caching via sccache and a GCP backend"
|
|
inputs:
|
|
sccache_azure_connection_string:
|
|
description: "Azure connection string for sccache"
|
|
targets:
|
|
description: "Additional targets to install"
|
|
required: false
|
|
default: ""
|
|
|
|
outputs:
|
|
bench-packages:
|
|
description: Benchmarkable packages for the current OS
|
|
value: ${{
|
|
(runner.os == 'Linux' && '--help') ||
|
|
(runner.os == 'macOS' && '--help') ||
|
|
(runner.os == 'Windows' && '-p firezone-bin-shared') }}
|
|
compile-packages:
|
|
description: Compilable packages for the current OS
|
|
value: ${{
|
|
(runner.os == 'Linux' && '--workspace') ||
|
|
(runner.os == 'macOS' && '--workspace') ||
|
|
(runner.os == 'Windows' && '--workspace --exclude ebpf-turn-router --exclude client-ffi') }}
|
|
test-packages:
|
|
description: Testable packages for the current OS
|
|
value: ${{
|
|
(runner.os == 'Linux' && '--workspace') ||
|
|
(runner.os == 'macOS' && '--workspace --exclude firezone-bin-shared --exclude firezone-gui-client') ||
|
|
(runner.os == 'Windows' && '--workspace --exclude client-ffi') }}
|
|
nightly_version:
|
|
description: The nightly version of Rust
|
|
value: ${{ steps.nightly.outputs.nightly }}
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
|
|
|
|
- name: Disable Windows Defender
|
|
if: ${{ runner.os == 'Windows' }}
|
|
run: Set-MpPreference -DisableRealtimeMonitoring $true
|
|
shell: powershell
|
|
|
|
- name: Extract Rust version
|
|
run: |
|
|
RUST_TOOLCHAIN=$(grep 'channel' rust/rust-toolchain.toml | awk -F '"' '{print $2}')
|
|
echo "RUST_TOOLCHAIN=$RUST_TOOLCHAIN" >> $GITHUB_ENV
|
|
shell: bash
|
|
|
|
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
|
|
id: toolchain
|
|
with:
|
|
toolchain: ${{ env.RUST_TOOLCHAIN }}
|
|
components: rustfmt,clippy
|
|
target: ${{ inputs.targets }}
|
|
cache: false # We explicitly configure the cache below because it doesn't forward `cache-targets`.
|
|
|
|
- name: Cache registry
|
|
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
|
|
with:
|
|
workspaces: rust
|
|
cache-targets: false # Don't cache `target` directory, we use sccache for that.
|
|
save-if: ${{ github.ref == 'refs/heads/main' }} # Only save on main
|
|
|
|
# We use Azure Blob Storage for sccache because credits and GHA cache is too small (10 GB).
|
|
# For this to work, you need an Azure Storage account and a blob container named `sccache`.
|
|
# The connection string here can be found under Storage Account -> Settings -> Security + networking -> Access keys.
|
|
- name: Configure sccache
|
|
shell: bash
|
|
run: |
|
|
echo "SCCACHE_GHA_ENABLED=false" >> $GITHUB_ENV
|
|
echo "SCCACHE_AZURE_CONNECTION_STRING=${{ inputs.sccache_azure_connection_string }}" >> $GITHUB_ENV
|
|
echo "SCCACHE_AZURE_BLOB_CONTAINER=sccache" >> $GITHUB_ENV
|
|
echo "RUSTC_WRAPPER=$SCCACHE_PATH" >> $GITHUB_ENV
|
|
|
|
- name: Install nightly Rust to use for certain tools (fuzzing, cargo-udeps)
|
|
id: nightly
|
|
run: |
|
|
NIGHTLY="nightly-2025-09-30"
|
|
# Check if nightly toolchain is already installed
|
|
if ! rustup toolchain list | grep -q "$NIGHTLY"; then
|
|
rustup toolchain install $NIGHTLY
|
|
rustup component add rust-src --toolchain $NIGHTLY
|
|
fi
|
|
echo "nightly=$NIGHTLY" >> $GITHUB_OUTPUT
|
|
shell: bash
|
|
|
|
- name: Install nightly Rust for compiling eBPF code
|
|
run: |
|
|
NIGHTLY="nightly-2025-05-30"
|
|
# Check if nightly toolchain is already installed
|
|
if ! rustup toolchain list | grep -q "$NIGHTLY"; then
|
|
rustup toolchain install $NIGHTLY
|
|
rustup component add rust-src --toolchain $NIGHTLY
|
|
fi
|
|
shell: bash
|
|
|
|
- name: Start sccache
|
|
run: $SCCACHE_PATH --start-server
|
|
shell: bash
|
|
env:
|
|
SCCACHE_CONF: ".github/actions/setup-rust/sccache.toml"
|