Files
firezone/.github/workflows/_rust.yml
Reactor Scram fa30588536 ci(windows): run the Windows smoke test in CI (#3542)
Closes #3534 

I'm running it in another job in parallel. It doesn't work in release
mode for Windows reasons, and I'm not sure how to share it with the
`cargo test` jobs.

So the overall time for `ci.yml` is only 11 minutes, which seems
typical. However it is using up another CI runner unit to build the
whole Tauri app from scratch in debug mode.

```[tasklist]
- [x] Skip the WebView2 error dialog if we're in smoke-test mode
- [x] Research if there's any Github action to install WebView2 in the runner
```

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Gabi <gabrielalejandro7@gmail.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2024-02-05 21:54:22 +00:00

184 lines
7.2 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:
runs-on:
# We only need to run static analysis checks per OS family
- ubuntu-22.04
- macos-14
- 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-14
packages: -p connlib-client-apple -p snownet
- runs-on: windows-2022
packages: -p connlib-client-shared -p firezone-windows-client -p snownet
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:
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: -p firezone-linux-client -p firezone-gateway -p connlib-client-android -p snownet
- runs-on: ubuntu-22.04
packages: -p firezone-linux-client -p firezone-gateway -p connlib-client-android -p snownet
- 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 firezone-windows-client -p connlib-client-shared -p snownet
- runs-on: windows-2022
packages: -p firezone-windows-client -p connlib-client-shared -p snownet
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-rust
- run: cargo test --all-features ${{ matrix.packages }}
# 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>
windows-smoke-test:
name: windows-smoke-test
runs-on: windows-2019
defaults:
run:
working-directory: ./rust/windows-client
env:
RUST_LOG: firezone_windows_client=info
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- uses: ./.github/actions/setup-rust
with:
targets: x86_64-pc-windows-msvc
# This is the "Evergreen" bootstrapper from Microsoft
# <https://developer.microsoft.com/en-us/microsoft-edge/webview2/?form=MA13LH#download>
# Unfortunately, this makes the test non-deterministic.
# Controlling the version would be difficult.
- name: Download WebView2 bootstrapper
run: Invoke-WebRequest -Uri https://go.microsoft.com/fwlink/p/?LinkId=2124703 -OutFile WebView2Installer.exe
# This downloads about 200 MB and takes about 5 minutes on my VM
# So we could fault in WebView2 from the client exe without the MSI if we needed.
# Currently the MSI does this and it's a little janky.
- name: Install WebView2
run: Start-Process WebView2Installer.exe -ArgumentList "/install" -Wait
- 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-windows-client
- name: Run smoke test
run: cargo run -p firezone-windows-client -- smoke-test
# This should be identical to `build-push-windows-release-artifacts` in `cd.yml` except for the Github permissions, needs tag, and uploading step
build-tauri:
name: build-tauri-${{ matrix.artifact }}
runs-on: windows-2019
defaults:
run:
working-directory: ./rust/windows-client
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:
include:
- package: firezone-windows-client
artifact: windows-client
env:
BINARY_DEST_PATH: ${{ matrix.artifact }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- uses: ./.github/actions/setup-rust
with:
targets: x86_64-pc-windows-msvc
- name: Build release binaries
run: |
# Build Windows Tauri GUI
pnpm install
pnpm build
# Used for release artifact
# In release mode the name comes from tauri.conf.json
cp "../target/release/Firezone.exe" "${{ env.BINARY_DEST_PATH }}-x64.exe"
cp "../target/release/bundle/msi/*.msi" "${{ env.BINARY_DEST_PATH }}-x64.msi"
cp "../target/release/firezone_windows_client.pdb" "${{ env.BINARY_DEST_PATH }}-x64.pdb"
Get-FileHash ${{ env.BINARY_DEST_PATH }}-x64.exe -Algorithm SHA256 | Select-Object Hash > ${{ env.BINARY_DEST_PATH }}-x64.exe.sha256sum.txt
Get-FileHash ${{ env.BINARY_DEST_PATH }}-x64.msi -Algorithm SHA256 | Select-Object Hash > ${{ env.BINARY_DEST_PATH }}-x64.msi.sha256sum.txt
Get-FileHash ${{ env.BINARY_DEST_PATH }}-x64.pdb -Algorithm SHA256 | Select-Object Hash > ${{ env.BINARY_DEST_PATH }}-x64.pdb.sha256sum.txt
# This might catch regressions in #3384, depending how CI runners
# handle exit codes
git diff --exit-code
- name: Save Windows client
uses: actions/upload-artifact@v4
with:
name: windows-client-x64
path: |
${{ github.workspace }}/rust/windows-client/windows-client-x64.exe
${{ github.workspace }}/rust/windows-client/windows-client-x64.exe.sha256sum.txt
- name: Save Windows installer
uses: actions/upload-artifact@v4
with:
name: windows-client-x64-msi
path: |
${{ github.workspace }}/rust/windows-client/windows-client-x64.msi
${{ github.workspace }}/rust/windows-client/windows-client-x64.msi.sha256sum.txt
- name: Save Windows debug symbols
uses: actions/upload-artifact@v4
with:
name: windows-client-x64-pdb
path: |
${{ github.workspace }}/rust/windows-client/windows-client-x64.pdb
${{ github.workspace }}/rust/windows-client/windows-client-x64.pdb.sha256sum.txt
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