Files
firezone/.github/workflows/_rust.yml
Reactor Scram 6aec8ce287 test(firezone-tunnel): create a tunnel device in unit tests during CI (#4254)
This catches two of the mutants, according to `cargo-mutants`.

~~Unfortunately since `cargo test` runs in one process, it's
all-or-nothing for sudo, this will run all unit tests as sudo.~~
(This explanation is not exactly correct, `cargo test` does run _a_
subprocess, but still, there is no way to request sudo or non-sudo
runners for specific tests, since it's just an environment variable, and
since many tests run in parallel in different threads of the same
process.)

Here it is passing in Linux:
https://github.com/firezone/firezone/actions/runs/8382799272/job/22957555987#step:5:3160

And Windows:
https://github.com/firezone/firezone/actions/runs/8382799272/job/22957558003#step:5:1006

```[tasklist]
### Before merging
- [x] Try `#[ignore]` attribute
- [x] Fail gracefully if `sudo` isn't available
```
2024-03-28 17:03:32 +00:00

117 lines
4.1 KiB
YAML

name: Rust
on:
workflow_call:
defaults:
run:
working-directory: ./rust
permissions:
contents: 'read'
id-token: 'write'
jobs:
static-analysis:
name: static-analysis-${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
# 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-14
packages: -p connlib-client-apple -p snownet
- runs-on: windows-2022
packages: -p connlib-client-shared -p firezone-gui-client -p snownet
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-rust
- uses: ./.github/actions/setup-tauri
- 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:
name: test-${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
# TODO: https://github.com/rust-lang/cargo/issues/5220
include:
- runs-on: ubuntu-20.04
packages: --workspace
- runs-on: ubuntu-22.04
packages: --workspace
- runs-on: macos-12
packages: -p connlib-client-apple -p snownet
- runs-on: macos-13
packages: -p connlib-client-apple -p snownet
- runs-on: macos-14
packages: -p connlib-client-apple -p snownet
- runs-on: windows-2019
packages: -p connlib-client-shared -p firezone-gui-client -p firezone-tunnel -p snownet
- runs-on: windows-2022
packages: -p connlib-client-shared -p firezone-gui-client -p firezone-tunnel -p snownet
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-rust
- uses: ./.github/actions/setup-tauri
- run: cargo test --all-features ${{ matrix.packages }} -- --include-ignored
env:
# <https://github.com/rust-lang/cargo/issues/5999>
# Needed to create tunnel interfaces in unit tests
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: "sudo --preserve-env"
RUST_BACKTRACE: full
# Runs the Windows client smoke test, built in debug mode. We can't run it in release
# mode because of a known issue: <https://github.com/firezone/firezone/blob/456e044f882c2bb314e19cc44c0d19c5ad817b7c/rust/windows-client/src-tauri/src/client.rs#L162-L164>
gui-smoke-test:
name: gui-smoke-test-${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-20.04
# Broken on 22.04 <https://github.com/firezone/firezone/issues/3699>
- runs-on: ubuntu-22.04
- runs-on: windows-2019
- runs-on: windows-2022
runs-on: ${{ matrix.runs-on }}
defaults:
run:
# Must be in this dir for `pnpm` to work
working-directory: ./rust/gui-client
env:
CONNLIB_LOG_UPLOAD_INTERVAL_SECS: 300
# The Windows client ignores RUST_LOG because it uses a settings file instead
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- uses: ./.github/actions/setup-rust
with:
cache_backend: 'github'
- uses: ./.github/actions/setup-tauri
- name: pnpm install
run: |
pnpm install
cp "node_modules/flowbite/dist/flowbite.min.js" "src/"
- name: Compile TypeScript
run: pnpm tsc
- name: Compile Tailwind
run: pnpm tailwindcss -i src/input.css -o src/output.css
- name: Build client
run: cargo build -p firezone-gui-client
- name: Run smoke tests (Linux)
if: ${{ runner.os == 'Linux' }}
run: bash ../../scripts/tests/smoke-test-gui-linux.sh
- name: Run smoke tests (Windows)
if: ${{ runner.os == 'Windows' }}
run: bash ../../scripts/tests/smoke-test-gui-windows.sh