From 7deec92bf202846809af27669081f60e1eb0e7be Mon Sep 17 00:00:00 2001 From: Benno van den Berg Date: Wed, 18 Sep 2024 11:18:04 +0200 Subject: [PATCH] Add initial CI (#260) * Add initial CI * Temporary force CI for current branch * Ensure pnpm is installed * Use the latest version of pnpm Change step names * Add pnpm install step * Ensure fiberplane/fpx-types is checked in * Ensure that Tauri required dependencies are installed * Retrieve artifact using the tauri step output * Disable arm for Linux build for now This gives some compile issues with openssl. Which is currently required. Tauri v2 will solve this issues * Try to join the artifact paths to get all the files * Decode from json first Add ci flag * Use var directly * Multiline? * Roundabout way :rolling_eyes: * Add debug message * Also include directories as artifacts * Use manual commands Move to tauri v2 * Force bundles into a string value * Escape arguments Only include bundle directory * No space allowed :( * Include target in artifact path * Unblock frontends, build workflows Synchronize CI workflows Unset default-members to build and clippy everything * Resolve issues for cargo deny * Ensure tauri deps are installed during build_cli * Ignore generate code/json * Fix path * Fix order * Resolve clippies Co-authored: Steph --- .github/workflows/build.yaml | 27 ++++---- .github/workflows/build_app.yml | 98 +++++++++++++++++++++++++++ .github/workflows/build_frontends.yml | 10 ++- Cargo.toml | 1 - biome.jsonc | 8 +-- deny.toml | 5 +- fpx-app/Cargo.toml | 6 +- fpx/src/api/handlers/traces.rs | 2 +- fpx/src/data/models.rs | 4 +- studio/src/tauri/utils.ts | 2 +- xtask/Cargo.toml | 2 +- 11 files changed, 137 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/build_app.yml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 94eaad420..fc9e62da9 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,7 +1,6 @@ # Test and build the project. --- -name: Build - +name: Build cli on: # Allow manual trigger workflow_dispatch: @@ -12,23 +11,17 @@ on: # Run on every push to main push: - branches: ["main"] + branches: ["main", "tauri-main"] jobs: build: + name: Create binary for ${{ matrix.target }} + runs-on: ${{ matrix.os }} strategy: matrix: include: - - target: x86_64-unknown-linux-gnu - os: ubuntu-latest-8-cores - - name: Create binary for ${{ matrix.target }} - runs-on: ${{ matrix.os }} - env: - CARGO: cargo - TARGET_FLAGS: "" - TARGET_DIR: ../target - RUST_BACKTRACE: 1 + - os: ubuntu-latest-8-cores + target: x86_64-unknown-linux-gnu permissions: id-token: write @@ -40,6 +33,12 @@ jobs: fetch-depth: 0 submodules: recursive + - name: Install dependencies (Linux) + if: matrix.os == 'ubuntu-latest-8-cores' + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf + - name: Install Rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: @@ -63,6 +62,6 @@ jobs: uses: actions/upload-artifact@v4 with: name: fpx_${{ matrix.target }} - path: target/release/fpx + path: target/release/fpx-cli if-no-files-found: error retention-days: 7 diff --git a/.github/workflows/build_app.yml b/.github/workflows/build_app.yml new file mode 100644 index 000000000..8a5601d0b --- /dev/null +++ b/.github/workflows/build_app.yml @@ -0,0 +1,98 @@ +# Build the fpx app. This will only be published as a build artifact. +--- +name: Build app +on: + # Allow manual trigger + workflow_dispatch: + + # Run on every pull request + pull_request: + branches: ["*"] + + # Run on every push to main + push: + branches: ["main", "tauri-main"] + +jobs: + build-app: + name: Create binary for ${{ matrix.target }} + runs-on: ${{ matrix.os }} + + # permissions: + # id-token: write + # contents: read + + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest-8-cores + target: x86_64-unknown-linux-gnu + bundles: appimage + - os: macos-latest + target: aarch64-apple-darwin + bundles: app,dmg + - os: macos-latest + target: x86_64-apple-darwin + bundles: app,dmg + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + # Steps required for our project, or our dependencies (like Tauri) + + - name: Install dependencies (Linux) + if: matrix.os == 'ubuntu-latest-8-cores' + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + run_install: false + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: lts/* + cache: "pnpm" + + - name: Setup Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + target: ${{ matrix.target }} + rustflags: "" # Do not fail on warnings, so reset the default value to empty + + - name: Install tauri-cli + run: cargo install tauri-cli@2.0.0-rc.16 + + # Steps related to our project + + - name: Install dependencies + run: pnpm install + env: + CI: true + + - name: Build shared types + run: pnpm build:types + + - name: Build fpx-app + run: | + cargo tauri build \ + --ci \ + --target "${{ matrix.target }}" \ + --bundles "${{ matrix.bundles }}" + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: fpx_${{ matrix.target }} + if-no-files-found: error + retention-days: 7 + path: target/${{ matrix.target }}/release/bundle diff --git a/.github/workflows/build_frontends.yml b/.github/workflows/build_frontends.yml index 2a2501429..7ab0ff72e 100644 --- a/.github/workflows/build_frontends.yml +++ b/.github/workflows/build_frontends.yml @@ -14,11 +14,16 @@ env: jobs: build_packages: name: Build packages - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8-cores steps: - name: Checkout uses: actions/checkout@v4 + - name: Install dependencies (Linux) + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf + - name: Setup pnpm uses: pnpm/action-setup@v4 with: @@ -41,6 +46,9 @@ jobs: env: CI: true + - name: Setup Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Build shared types run: pnpm build:types diff --git a/Cargo.toml b/Cargo.toml index d741c0a80..ca3f078de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,6 @@ [workspace] resolver = "2" members = ["fpx", "fpx-app", "fpx-cli", "fpx-macros", "fpx-workers", "xtask"] -default-members = ["fpx-cli"] [workspace.package] authors = ["Fiberplane "] diff --git a/biome.jsonc b/biome.jsonc index fb6057360..6de3c9aa8 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -96,13 +96,9 @@ ".astro", // ignore all tsconfig.json files - "tsconfig.json" + "tsconfig.json", - // Rust code related - // This caused biome to ignore the entire fpx folder - // commenting out for now as we still want to find a way to - // skip Rust code in biome - // "fpx/*.*" + "fpx-app/gen" ] } } diff --git a/deny.toml b/deny.toml index 66d5f52a9..b97327496 100644 --- a/deny.toml +++ b/deny.toml @@ -1,10 +1,13 @@ [advisories] -ignore = [] +ignore = [ + "RUSTSEC-2024-0370", # unmaintained - proc-macro-error +] yanked = "deny" [licenses] allow = [ "Apache-2.0", + "Apache-2.0 WITH LLVM-exception", "BSD-3-Clause", "ISC", "MIT", diff --git a/fpx-app/Cargo.toml b/fpx-app/Cargo.toml index d15fb86b5..fdfa29297 100644 --- a/fpx-app/Cargo.toml +++ b/fpx-app/Cargo.toml @@ -1,7 +1,11 @@ [package] name = "fpx-app" -version = "0.1.0" +description = "A Tauri App" edition = "2021" +version = { workspace = true } +authors = { workspace = true } +license = { workspace = true } +repository = { workspace = true } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/fpx/src/api/handlers/traces.rs b/fpx/src/api/handlers/traces.rs index 30bc8b48f..1442e89d0 100644 --- a/fpx/src/api/handlers/traces.rs +++ b/fpx/src/api/handlers/traces.rs @@ -52,7 +52,7 @@ pub async fn traces_get_handler( // Retrieve all the spans that are associated with the trace let spans = store.span_list_by_trace(&tx, &trace_id).await?; - let trace = TraceSummary::from_spans(trace_id.into(), spans).ok_or(TraceGetError::NotFound)?; + let trace = TraceSummary::from_spans(trace_id, spans).ok_or(TraceGetError::NotFound)?; Ok(Json(trace)) } diff --git a/fpx/src/data/models.rs b/fpx/src/data/models.rs index 2d1545c42..40c6ee237 100644 --- a/fpx/src/data/models.rs +++ b/fpx/src/data/models.rs @@ -92,8 +92,10 @@ impl HexEncodedId { pub fn as_inner(&self) -> &str { &self.0 } +} - pub fn as_mut(&mut self) -> &mut str { +impl AsMut for HexEncodedId { + fn as_mut(&mut self) -> &mut str { &mut self.0 } } diff --git a/studio/src/tauri/utils.ts b/studio/src/tauri/utils.ts index a2ed134d2..71d9459fd 100644 --- a/studio/src/tauri/utils.ts +++ b/studio/src/tauri/utils.ts @@ -1,7 +1,7 @@ import type { Workspace } from "@fiberplane/fpx-types"; import { invoke } from "@tauri-apps/api/core"; -import { open } from "@tauri-apps/plugin-dialog"; import { appDataDir } from "@tauri-apps/api/path"; +import { open } from "@tauri-apps/plugin-dialog"; export async function listRecentWorkspaces() { return await invoke>("list_recent_workspaces"); diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index ebc4965ef..dd3e84419 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -10,7 +10,7 @@ repository = { workspace = true } anyhow = { workspace = true } clap = { workspace = true, features = ["derive", "env"] } fpx = { version = "0.1.0", path = "../fpx" } -fpx-app = { path = "../fpx-app" } +fpx-app = { version = "0.1.0", path = "../fpx-app" } schemars = { workspace = true } serde = { workspace = true } serde_json = { workspace = true }