Files
Thomas Eizinger b7dc897eea refactor(rust): introduce libs/ directory (#10964)
The current Rust workspace isn't as consistent as it could be. To make
navigation a bit easier, we move a few crates around. Generally, we
follow the idea that entry-points should be at the top-level. `rust/`
now looks like this (directories only):

```
.
├── cli             # Firezone CLI
├── client-ffi      # Entry point for Apple & Android
├── gateway         # Gateway
├── gui-client      # GUI client
├── headless-client # Headless client
├── libs            # Library crates
├── relay           # Relay
├── target          # Compile artifacts
├── tests           # Crates for testing
└── tools           # Local tools
```

To further enforce this structure, we also drop the `firezone-` prefix
from all crates that are not top-level binary crates.
2025-11-25 10:59:11 +00:00

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 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 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"