Skip to content

Commit

Permalink
refactor(ci): use the same test framework for headless client and IPC…
Browse files Browse the repository at this point in the history
… service (#4943)

This will fix an issue with `linux-group` and `token-path` that happens
when I try to split up the binaries.

```[tasklist]
### Before merging
- [x] Fix linux-group. That stub-ipc-client command doesn't even exist anymore
```
  • Loading branch information
ReactorScram committed May 10, 2024
1 parent e03340b commit 390f9de
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-rust
- run: cargo build -p firezone-headless-client
name: "cargo build"
shell: bash
- uses: ./.github/actions/setup-tauri
- run: scripts/tests/${{ matrix.test }}.sh
name: "test script"
shell: bash
Expand Down
12 changes: 10 additions & 2 deletions scripts/build/tauri-rename-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/usr/bin/env bash
set -euox pipefail

FZ_GROUP="firezone-client"
SERVICE_NAME=firezone-client-ipc

function debug_exit() {
systemctl status "$SERVICE_NAME"
exit 1
}

# For debugging
ls ../target/release ../target/release/bundle/deb

Expand Down Expand Up @@ -40,5 +48,5 @@ stat /usr/share/icons/hicolor/512x512/apps/firezone-client-gui.png
firezone-client-gui --help | grep "Usage: firezone-client-gui"

# Try to start the IPC service
sudo groupadd --force firezone-client
sudo systemctl start firezone-client-ipc || systemctl status firezone-client-ipc
sudo groupadd --force "$FZ_GROUP"
sudo systemctl start "$SERVICE_NAME" || debug_exit
22 changes: 11 additions & 11 deletions scripts/tests/linux-group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ SERVICE_NAME=firezone-client-ipc
SOCKET=/run/dev.firezone.client/ipc.sock
export RUST_LOG=info

cd rust || exit 1
cargo build --bin "$BINARY_NAME"
cd ..

function debug_exit() {
systemctl status "$SERVICE_NAME"
exit 1
}

# Copy the Linux Client out of the build dir
sudo cp "rust/target/debug/firezone-headless-client" "/usr/bin/$BINARY_NAME"
sudo cp "rust/target/debug/$BINARY_NAME" "/usr/bin/$BINARY_NAME"

# Set up the systemd service
sudo cp "rust/gui-client/src-tauri/deb_files/$SERVICE_NAME.service" /usr/lib/systemd/system/
sudo cp "scripts/tests/systemd/env" "/etc/default/firezone-client-ipc"

# The firezone group must exist before the daemon starts
sudo groupadd "$FZ_GROUP"
sudo systemctl start "$SERVICE_NAME" || { systemctl status "$SERVICE_NAME"; exit 1; }
sudo systemctl start "$SERVICE_NAME" || debug_exit

# Make sure the socket has the right permissions
if [ "root $FZ_GROUP" != "$(stat -c '%U %G' $SOCKET)" ]
then
exit 1
fi

# Add ourselves to the firezone group
sudo gpasswd --add "$USER" "$FZ_GROUP"

echo "# Expect Firezone to accept our commands if we run with 'su --login'"
sudo su --login "$USER" --command RUST_LOG="$RUST_LOG" "$BINARY_NAME" stub-ipc-client

echo "# Expect Firezone to reject our command if we run without 'su --login'"
"$BINARY_NAME" stub-ipc-client && exit 1

# Stop the service in case other tests run on the same VM
sudo systemctl stop "$SERVICE_NAME"

Expand Down
8 changes: 6 additions & 2 deletions scripts/tests/token-path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

source "./scripts/tests/lib.sh"

BINARY_NAME=firezone-linux-client
BINARY_NAME=firezone-headless-client
TOKEN="n.SFMyNTY.g2gDaANtAAAAJGM4OWJjYzhjLTkzOTItNGRhZS1hNDBkLTg4OGFlZjZkMjhlMG0AAAAkN2RhN2QxY2QtMTExYy00NGE3LWI1YWMtNDAyN2I5ZDIzMGU1bQAAACtBaUl5XzZwQmstV0xlUkFQenprQ0ZYTnFJWktXQnMyRGR3XzJ2Z0lRdkZnbgYAGUmu74wBYgABUYA.UN3vSLLcAMkHeEh5VHumPOutkuue8JA6wlxM9JxJEPE"
TOKEN_PATH="token"

sudo cp "rust/target/debug/firezone-headless-client" "/usr/bin/$BINARY_NAME"
cd rust || exit 1
cargo build -p "$BINARY_NAME"
cd ..

sudo cp "rust/target/debug/$BINARY_NAME" "/usr/bin/$BINARY_NAME"

# Fails because there's no token yet
sudo "$BINARY_NAME" --check standalone && exit 1
Expand Down

0 comments on commit 390f9de

Please sign in to comment.