ci(windows): remove hello-world and permissions-test projects (#2926)

Don't need them any more. `build-tauri` is about 5 minutes faster
without the permissions test, since it had to be a separate project /
workspace entirely and rebuilt a bunch of stuff. That's a reason I
prefer subcommands. For some reason sccache didn't seem to do much for
it. This is also a flaw in Tauri, I couldn't figure out any proper way
to keep a Tauri project inside the examples dir of another Tauri
project. With two non-Tauri apps it's easier and probably wouldn't add
much build time.
This commit is contained in:
Reactor Scram
2023-12-17 11:12:50 -06:00
committed by GitHub
parent 364d415b67
commit 6b0149e58d
18 changed files with 1 additions and 4336 deletions

View File

@@ -64,45 +64,9 @@ jobs:
- 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
# TODO: Get rid of "temp" and figure out what to do with this
temp-build-tauri:
build-tauri:
runs-on: windows-2019
defaults:
run:
@@ -134,23 +98,11 @@ jobs:
# There's an MSI and NSIS installer too, but their names include the version so I'll try those later.
cd windows-client/examples/permissions-test
# Hopefully sccache speeds this up.
tauri build
cp src-tauri/target/release/windows-permissions-test.exe "windows-permissions-test-x64.exe"
- name: Save Windows client
uses: actions/upload-artifact@v3
with:
name: windows-client-x64.exe
path: ${{ github.workspace }}/rust/windows-client-x64.exe
- name: Save Windows permissions test
uses: actions/upload-artifact@v3
with:
name: windows-permissions-test-x64.exe
path: ${{ github.workspace }}/rust/windows-client/examples/permissions-test/windows-permissions-test-x64.exe
smoke-test-relay:
runs-on: ubuntu-22.04

4
rust/Cargo.lock generated
View File

@@ -2587,10 +2587,6 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hello-world"
version = "0.1.0"
[[package]]
name = "hermit-abi"
version = "0.3.3"

View File

@@ -6,7 +6,6 @@ members = [
"connlib/shared",
"connlib/tunnel",
"gateway",
"hello-world",
"linux-client",
"firezone-cli-utils",
"phoenix-channel",

View File

@@ -1,8 +0,0 @@
[package]
name = "hello-world"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@@ -1,3 +0,0 @@
fn main() {
println!("Hello, world!");
}

View File

@@ -38,15 +38,6 @@ stat ../target/debug/firezone-windows-client.exe
The app's config and logs will be stored at `C:\Users\$USER\AppData\Local\dev.firezone.client`.
## Examples
Examples like `windows-permissions-test` cannot run with a normal Cargo command, because of how tauri.conf.json works.
```
cd examples/permissions-test
cargo run
```
## Platform support
Tauri says it should work on Windows 10, Version 1803 and up. Older versions may work if you [manually install WebView2](https://tauri.app/v1/guides/getting-started/prerequisites#2-webview2)

View File

@@ -1 +0,0 @@
/target

View File

@@ -1,11 +0,0 @@
This is a test program for features that aren't working in the GUI Windows client yet.
# Debugging
In Powershell
```
cd src-tauri
cargo build
Start-Process target/debug/windows-permissions-test.exe -verb runas
```

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +0,0 @@
[package]
name = "windows-permissions-test"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.5", features = [] }
[dependencies]
anyhow = { version = "1.0" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tauri = { version = "1.5", features = ["shell-open"] }
tokio = { version = "1.33.0", features = ["time"] }
uuid = { version = "1.5.0", features = ["v4"] }
wintun = "0.3.2"
[features]
# this feature is used for production builds or when `devPath` points to the filesystem
# DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]
[workspace]
# Not a member of the firezone/rust/Cargo.toml workspace

View File

@@ -1,3 +0,0 @@
fn main() {
tauri_build::build()
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -1,138 +0,0 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use Result as StdResult;
use anyhow::Result as Result;
use std::{
str::FromStr,
sync::Arc,
};
use tokio::sync::mpsc;
#[tauri::command]
async fn start_tunnel_cmd(managed: tauri::State<'_, Managed>) -> StdResult<(), String> {
managed.ctlr_tx.send(ControllerRequest::StartTunnel).await.map_err(|_| "sending start tunnel request".to_string())?;
Ok(())
}
#[tauri::command]
async fn stop_tunnel_cmd(managed: tauri::State<'_, Managed>) -> StdResult<(), String> {
managed.ctlr_tx.send(ControllerRequest::StopTunnel).await.map_err(|_| "sending stop tunnel request".to_string())?;
Ok(())
}
struct Managed {
ctlr_tx: mpsc::Sender<ControllerRequest>,
}
enum ControllerRequest {
StartTunnel,
StopTunnel,
}
fn main() -> Result<()> {
let rt = tokio::runtime::Runtime::new()?;
let _guard = rt.enter();
let (ctlr_tx, ctlr_rx) = mpsc::channel(5);
let managed = Managed {
ctlr_tx,
};
// Unsafe because we are loading an arbitrary dll file
let wintun = unsafe { wintun::load_from_path("./wintun.dll") }?;
tauri::Builder::default()
.manage(managed)
.invoke_handler(tauri::generate_handler![start_tunnel_cmd, stop_tunnel_cmd])
.setup(|app| {
let _ctlr_task = tokio::spawn(run_controller(app.handle(), ctlr_rx, wintun));
Ok(())
})
.run(tauri::generate_context!())?;
Ok(())
}
struct Controller {
wintun_lib: wintun::Wintun,
tunnel: Option<Tunnel>,
}
const TUNNEL_UUID: &str = "ab722ec1-9a87-4d8c-a976-e22ed7b8f6a9";
impl Controller {
async fn start_tunnel (&mut self) -> Result <()> {
self.stop_tunnel().await?;
let uuid = uuid::Uuid::from_str(TUNNEL_UUID)?;
let adapter = match wintun::Adapter::create(&self.wintun_lib, "Firezone", "Example manor hatch stash", Some(uuid.as_u128())) {
Ok(x) => x,
Err(e) => {
eprintln!("Adapter::create failed, probably need admin privileges");
return Err(e.into());
}
};
println!("Adapter has addresses {:?}", adapter.get_addresses()?);
// Specify the size of the ring buffer the wintun driver should use.
let session = Arc::new(adapter.start_session(wintun::MAX_RING_CAPACITY)?);
let session_2 = Arc::clone(&session);
let recv_task = tokio::task::spawn_blocking(move || {
let session = session_2;
while let Ok(pkt) = session.receive_blocking() {
println!("Got packet! {} bytes", pkt.bytes().len());
}
println!("recv_task exiting gracefully");
});
self.tunnel = Some(Tunnel {
_adapter: adapter,
recv_task,
session,
});
Ok(())
}
async fn stop_tunnel (&mut self) -> Result <()> {
if let Some(tunnel) = self.tunnel.take() {
tunnel.session.shutdown()?;
tunnel.recv_task.await?;
}
Ok(())
}
}
struct Tunnel {
_adapter: Arc<wintun::Adapter>,
recv_task: tokio::task::JoinHandle<()>,
session: Arc<wintun::Session>,
}
async fn run_controller(_app: tauri::AppHandle, mut ctlr_rx: mpsc::Receiver<ControllerRequest>, wintun_lib: wintun::Wintun) -> Result<()> {
let mut controller = Controller {
tunnel: None,
wintun_lib,
};
while let Some(req) = ctlr_rx.recv().await { match req {
ControllerRequest::StartTunnel => {
println!("start tunnel");
if let Err(e) = controller.start_tunnel().await {
eprintln!("{e}");
}
},
ControllerRequest::StopTunnel => {
println!("stop tunnel");
if let Err(e) = controller.stop_tunnel().await {
eprintln!("{e}");
}
},
}}
Ok(())
}

View File

@@ -1,42 +0,0 @@
{
"build": {
"beforeDevCommand": "",
"beforeBuildCommand": "",
"devPath": "../src",
"distDir": "../src",
"withGlobalTauri": true
},
"package": {
"productName": "windows-permissions-test",
"version": "0.0.0"
},
"tauri": {
"allowlist": {
"all": false,
"shell": {
"all": false,
"open": true
}
},
"bundle": {
"active": false,
"targets": "all",
"identifier": "dev.firezone.windows-permissions-test",
"icon": [
"icons/firezone.ico"
]
},
"security": {
"csp": null
},
"windows": [
{
"fullscreen": false,
"resizable": true,
"title": "Permissions test",
"width": 800,
"height": 600
}
]
}
}

View File

@@ -1,38 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Settings</title>
<script src="index.js"></script>
<title>Permissions test</title>
<style>
body {
/* Add a nice colorscheme */
background-color: #222831;
color: #ececec;
/* Make the body the exact size of the window */
margin: 0;
height: 100vh;
width: 100vw;
/* Vertically and horizontally center children of the body tag */
display: flex;
justify-content: center;
align-items: center;
font-family: sans-serif;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<button type="button" id="start-tunnel-btn">Start Tunnel</button>
<button type="button" id="stop-tunnel-btn">Stop Tunnel</button>
</div>
</div>
</body>
</html>

View File

@@ -1,20 +0,0 @@
let start_tunnel_btn;
let stop_tunnel_btn;
const querySel = function(id) {
return document.querySelector(id);
};
const { invoke } = window.__TAURI__.tauri;
window.addEventListener("DOMContentLoaded", () => {
start_tunnel_btn = querySel("#start-tunnel-btn");
stop_tunnel_btn = querySel("#stop-tunnel-btn");
start_tunnel_btn.addEventListener("click", (e) => {
invoke("start_tunnel_cmd");
});
stop_tunnel_btn.addEventListener("click", (e) => {
invoke("stop_tunnel_cmd");
});
});

View File

@@ -1,18 +0,0 @@
const { invoke } = window.__TAURI__.tauri;
let greetInputEl;
let greetMsgEl;
async function greet() {
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value });
}
window.addEventListener("DOMContentLoaded", () => {
greetInputEl = document.querySelector("#greet-input");
greetMsgEl = document.querySelector("#greet-msg");
document.querySelector("#greet-form").addEventListener("submit", (e) => {
e.preventDefault();
greet();
});
});

View File

@@ -1,109 +0,0 @@
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;
color: #0f0f0f;
background-color: #f6f6f6;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
.container {
margin: 0;
padding-top: 10vh;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: 0.75s;
}
.logo.tauri:hover {
filter: drop-shadow(0 0 2em #24c8db);
}
.row {
display: flex;
justify-content: center;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
h1 {
text-align: center;
}
input,
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
color: #0f0f0f;
background-color: #ffffff;
transition: border-color 0.25s;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}
button {
cursor: pointer;
}
button:hover {
border-color: #396cd8;
}
button:active {
border-color: #396cd8;
background-color: #e8e8e8;
}
input,
button {
outline: none;
}
#greet-input {
margin-right: 5px;
}
@media (prefers-color-scheme: dark) {
:root {
color: #f6f6f6;
background-color: #2f2f2f;
}
a:hover {
color: #24c8db;
}
input,
button {
color: #ffffff;
background-color: #0f0f0f98;
}
button:active {
background-color: #0f0f0f69;
}
}