mirror of
https://github.com/Xevion/byte-me.git
synced 2025-12-06 01:14:33 -06:00
ci: merge ci builds, run cargo tests directly, export bindings directly into src/
This commit is contained in:
115
.github/workflows/ci.yml
vendored
115
.github/workflows/ci.yml
vendored
@@ -9,55 +9,46 @@ env:
|
|||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Frontend checks
|
build:
|
||||||
frontend-check:
|
|
||||||
name: Frontend Check
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install pnpm
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: 10
|
version: 10
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: "20"
|
node-version: 20
|
||||||
cache: "pnpm"
|
cache: "pnpm"
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install JS deps
|
||||||
run: pnpm install
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
- name: Check TypeScript
|
- name: Build frontend (tsc + vite)
|
||||||
run: pnpm run build
|
run: |
|
||||||
|
pnpm run build # implicitly runs generate-types
|
||||||
- name: Format check
|
|
||||||
run: pnpm exec prettier --check .
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
# Rust backend checks
|
|
||||||
rust-check:
|
|
||||||
name: Rust Check
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
components: rustfmt, clippy
|
|
||||||
|
|
||||||
- name: Rust Cache
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
workspaces: src-tauri
|
|
||||||
|
|
||||||
- name: Install Linux dependencies
|
- name: Install Linux dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
sudo apt-get install -y \
|
||||||
|
pkg-config \
|
||||||
|
build-essential \
|
||||||
|
libssl-dev \
|
||||||
|
libglib2.0-dev \
|
||||||
|
libwebkit2gtk-4.1-dev \
|
||||||
|
libayatana-appindicator3-dev \
|
||||||
|
librsvg2-dev \
|
||||||
|
patchelf
|
||||||
|
|
||||||
- name: Format check
|
- name: Format check
|
||||||
run: cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check
|
run: cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check
|
||||||
@@ -67,59 +58,3 @@ jobs:
|
|||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --manifest-path src-tauri/Cargo.toml --all-features
|
run: cargo test --manifest-path src-tauri/Cargo.toml --all-features
|
||||||
|
|
||||||
# Security audit
|
|
||||||
security-audit:
|
|
||||||
name: Security Audit
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Install cargo-audit
|
|
||||||
uses: taiki-e/cache-cargo-install-action@v2
|
|
||||||
with:
|
|
||||||
tool: cargo-audit
|
|
||||||
|
|
||||||
- name: Run security audit
|
|
||||||
run: cargo audit --file src-tauri/Cargo.lock
|
|
||||||
|
|
||||||
# Check if Tauri app builds successfully
|
|
||||||
build-check:
|
|
||||||
name: Build Check
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [frontend-check, rust-check]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install pnpm
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: "20"
|
|
||||||
cache: "pnpm"
|
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Rust Cache
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
workspaces: src-tauri
|
|
||||||
|
|
||||||
- name: Install Linux dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
|
||||||
run: pnpm install
|
|
||||||
|
|
||||||
- name: Build Tauri app
|
|
||||||
run: pnpm tauri build --no-bundle
|
|
||||||
|
|||||||
10
.github/workflows/code-quality.yml
vendored
10
.github/workflows/code-quality.yml
vendored
@@ -39,7 +39,15 @@ jobs:
|
|||||||
- name: Install Linux dependencies
|
- name: Install Linux dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
sudo apt-get install -y \
|
||||||
|
pkg-config \
|
||||||
|
build-essential \
|
||||||
|
libssl-dev \
|
||||||
|
libglib2.0-dev \
|
||||||
|
libwebkit2gtk-4.1-dev \
|
||||||
|
libayatana-appindicator3-dev \
|
||||||
|
librsvg2-dev \
|
||||||
|
patchelf
|
||||||
|
|
||||||
- name: Install cargo-udeps
|
- name: Install cargo-udeps
|
||||||
uses: taiki-e/cache-cargo-install-action@v2
|
uses: taiki-e/cache-cargo-install-action@v2
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"build": "pnpm generate-types && tsc && vite build",
|
"build": "pnpm generate-types && tsc && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
"generate-types": "tsx scripts/generate-types.ts"
|
"generate-types": "cargo test --manifest-path src-tauri/Cargo.toml -- --test export_bindings"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nivo/core": "^0.99.0",
|
"@nivo/core": "^0.99.0",
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
import { execSync } from "child_process";
|
|
||||||
import { copyFileSync, mkdirSync, existsSync, readdirSync } from "fs";
|
|
||||||
import { join, dirname } from "path";
|
|
||||||
import { fileURLToPath } from "url";
|
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
|
||||||
const __dirname = dirname(__filename);
|
|
||||||
|
|
||||||
console.log("🔄 Generating TypeScript bindings...");
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Run the test to generate bindings
|
|
||||||
execSync("cargo test export_bindings", {
|
|
||||||
cwd: "./src-tauri",
|
|
||||||
stdio: "inherit",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!existsSync(join(__dirname, "../src-tauri/bindings"))) {
|
|
||||||
throw new Error(
|
|
||||||
"Bindings directory not found. Bindings generation failed or improperly configured.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("✅ TypeScript bindings generated successfully!");
|
|
||||||
|
|
||||||
// Copy bindings to src directory
|
|
||||||
const srcBindingsDir = join(__dirname, "../src/bindings");
|
|
||||||
const files = readdirSync(join(__dirname, "../src-tauri/bindings")).filter(
|
|
||||||
(file) => file.endsWith(".ts"),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (files.length === 0) {
|
|
||||||
throw new Error(
|
|
||||||
"No bindings files found. Bindings generation failed or improperly configured.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const file of files) {
|
|
||||||
const source = join(__dirname, "../src-tauri/bindings", file);
|
|
||||||
const dest = join(srcBindingsDir, file);
|
|
||||||
copyFileSync(source, dest);
|
|
||||||
console.log(`📁 Copied ${file} to src/bindings/`);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("🎉 All done! TypeScript bindings are up to date.");
|
|
||||||
} catch (error) {
|
|
||||||
console.error("❌ Failed to generate TypeScript bindings:", error);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
@@ -99,14 +99,13 @@ pub fn run() {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::models::StreamDetail;
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
use ts_rs::TS;
|
use ts_rs::TS;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn export_bindings() {
|
fn export_bindings() {
|
||||||
// This will generate TypeScript bindings when you run `cargo test export_bindings`
|
// This will generate TypeScript bindings when you run `cargo test export_bindings`
|
||||||
TS::export_all_to("../../src/bindings")
|
use crate::models::*;
|
||||||
|
|
||||||
|
StreamDetail::export_all_to("../../src/bindings").expect("Failed to export bindings");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user