Files
firezone/.github/workflows/_rust.yml

153 lines
4.9 KiB
YAML

name: Rust
on:
workflow_call:
defaults:
run:
working-directory: ./rust
permissions:
contents: 'read'
id-token: 'write'
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 -p firezone-windows-client
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-rust
- 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-linux-client -p firezone-gateway -p connlib-client-android
- runs-on: ubuntu-22.04
packages: -p firezone-linux-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 firezone-windows-client -p connlib-client-shared
- runs-on: windows-2022
packages: -p firezone-windows-client -p connlib-client-shared
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-rust
- run: cargo test --all-features ${{ matrix.packages }}
# TODO: Remove when windows build works reliably in cd.yml
# These `temp-` jobs serve as a sanity check to early exit if there's an issue in the workflow
temp-build-windows-artifacts:
runs-on: windows-2019
defaults:
run:
working-directory: ./rust
strategy:
fail-fast: false
# The matrix is 1x1 to match the style of build-push-linux-release-artifacts
# In the future we could try to cross-compile aarch64-windows here.
matrix:
name:
- package: hello-world
artifact: hello-world
env:
BINARY_DEST_PATH: ${{ matrix.name.artifact }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-rust
with:
targets: x86_64-pc-windows-msvc
- name: Build release binaries
run: |
cargo `
build `
--release -p ${{ matrix.name.package }}
cp target/release/${{ matrix.name.package }}.exe "${{ env.BINARY_DEST_PATH }}-x64.exe"
pwd
ls *.exe
- name: Save build artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name.artifact }}-x64.exe
path: ${{ github.workspace }}/rust/${{ env.BINARY_DEST_PATH }}-x64.exe
# This should be identical to `build-push-windows-release-artifacts` in `cd.yml` except for the permissions, needs, and uploading step
temp-build-tauri:
runs-on: windows-2019
defaults:
run:
working-directory: ./rust
strategy:
fail-fast: false
# The matrix is 1x1 to match the style of build-push-linux-release-artifacts
# In the future we could try to cross-compile aarch64-windows here.
matrix:
name:
- package: firezone-windows-client
artifact: windows-client
env:
BINARY_DEST_PATH: ${{ matrix.name.artifact }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-rust
with:
targets: x86_64-pc-windows-msvc
- name: Build release binaries
run: |
cargo install tauri-cli
# Tauri build already defaults to '--release'
cargo tauri build
# Used for release artifact
cp target/release/${{ matrix.name.package }}.exe "${{ env.BINARY_DEST_PATH }}-x64.exe"
pwd
ls *.exe
# There's an MSI and NSIS installer here but their names include the version so I'll try those later.
- name: Save build artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name.artifact }}-x64.exe
path: ${{ github.workspace }}/rust/${{ env.BINARY_DEST_PATH }}-x64.exe
smoke-test-relay:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./rust/relay
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-rust
- run: ./run_smoke_test.sh