From 9ac7fdbeb77c875612ce75b6b8258b49239bee47 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Wed, 10 Dec 2025 22:03:13 +0000 Subject: [PATCH] Improve CI (#181) --- .github/workflows/check.yml | 4 ++- .github/workflows/deploy-docs.yml | 28 +++++---------------- .github/workflows/e2e.yml | 4 ++- .github/workflows/publish-cli-docker.yml | 3 +++ .github/workflows/publish-plugin.yml | 4 +++ .github/workflows/publish-server-docker.yml | 2 ++ frontend/test-client/src/cli.ts | 13 +++++----- scripts/build-docs.sh | 12 +++++++++ scripts/check.sh | 2 +- sync-server/src/app_state/database.rs | 5 ++-- 10 files changed, 44 insertions(+), 33 deletions(-) create mode 100644 scripts/build-docs.sh diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index f3fad1df..cf890830 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -16,6 +16,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Node.js environment uses: actions/setup-node@v4.2.0 @@ -31,7 +33,7 @@ jobs: - name: Setup rust run: | - cargo install sqlx-cli cargo-machete + which sqlx || cargo install sqlx-cli cd sync-server sqlx database create --database-url sqlite://db.sqlite3 sqlx migrate run --source src/app_state/database/migrations --database-url sqlite://db.sqlite3 diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index e1c3bcf8..b6d369cc 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -20,7 +20,8 @@ concurrency: jobs: build: - runs-on: ubuntu-latest + runs-on: self-hosted + steps: - name: Checkout uses: actions/checkout@v4 @@ -30,32 +31,15 @@ jobs: - name: Setup Node uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 cache: npm cache-dependency-path: docs/package-lock.json - name: Setup Pages uses: actions/configure-pages@v4 - - name: Install dependencies - run: | - cd docs - npm ci - - - name: Check formatting - run: | - cd docs - npm run format:check - - - name: Check spelling - run: | - cd docs - npm run spell:check - - - name: Build documentation - run: | - cd docs - npm run build + - name: Build docs + run: scripts/build-docs.sh - name: Upload artifact uses: actions/upload-pages-artifact@v3 @@ -67,7 +51,7 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} needs: build - runs-on: ubuntu-latest + runs-on: self-hosted name: Deploy steps: - name: Deploy to GitHub Pages diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 28fde13e..803cddb2 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -21,6 +21,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Node.js environment uses: actions/setup-node@v4.2.0 @@ -36,7 +38,7 @@ jobs: - name: Setup rust run: | - cargo install sqlx-cli + which sqlx || cargo install sqlx-cli cd sync-server sqlx database create --database-url sqlite://db.sqlite3 sqlx migrate run --source src/app_state/database/migrations --database-url sqlite://db.sqlite3 diff --git a/.github/workflows/publish-cli-docker.yml b/.github/workflows/publish-cli-docker.yml index 73ef1b12..10a7e8ba 100644 --- a/.github/workflows/publish-cli-docker.yml +++ b/.github/workflows/publish-cli-docker.yml @@ -2,6 +2,7 @@ name: Publish CLI on: push: + branches: ["main"] tags: ["*"] pull_request: branches: ["main"] @@ -22,6 +23,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install cosign uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0 diff --git a/.github/workflows/publish-plugin.yml b/.github/workflows/publish-plugin.yml index ed223780..7a168db5 100644 --- a/.github/workflows/publish-plugin.yml +++ b/.github/workflows/publish-plugin.yml @@ -3,6 +3,8 @@ name: Publish Obsidian plugin on: push: tags: ["*"] +pull_request: + branches: ["main"] env: CARGO_TERM_COLOR: always @@ -13,6 +15,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Node.js environment uses: actions/setup-node@v4.2.0 diff --git a/.github/workflows/publish-server-docker.yml b/.github/workflows/publish-server-docker.yml index f9fee79b..4a97a9e6 100644 --- a/.github/workflows/publish-server-docker.yml +++ b/.github/workflows/publish-server-docker.yml @@ -27,6 +27,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 # Install the cosign tool # https://github.com/sigstore/cosign-installer diff --git a/frontend/test-client/src/cli.ts b/frontend/test-client/src/cli.ts index 70817a24..b5370d0b 100644 --- a/frontend/test-client/src/cli.ts +++ b/frontend/test-client/src/cli.ts @@ -118,7 +118,7 @@ async function runTest({ async function runTests(): Promise { for (let i = 0; i < TEST_ITERATIONS; i++) { - for (const useSlowFileEvents of [false, true]) { + for (const useSlowFileEvents of [true, false]) { for (const concurrency of [ 16, 1 // test with concurrency 1 to check for deadlocks @@ -150,10 +150,6 @@ async function runTests(): Promise { } process.on("uncaughtException", (error) => { - if (slowFileEvents) { - return; - } - if ( error instanceof Error && error.message.includes( @@ -172,7 +168,12 @@ process.on("unhandledRejection", (error, _promise) => { return; } - if (slowFileEvents) { + if ( + slowFileEvents && + error instanceof Error && + (error.message.includes("Document not found") || + error.message.includes("Document already exists at new location")) + ) { return; } diff --git a/scripts/build-docs.sh b/scripts/build-docs.sh new file mode 100644 index 00000000..9f3c76d4 --- /dev/null +++ b/scripts/build-docs.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e + +cd docs + +npm ci +npm run format:check +npm run spell:check +npm run build + +cd - diff --git a/scripts/check.sh b/scripts/check.sh index dd41fbcb..2a13953a 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -20,7 +20,7 @@ else cargo fmt --all -- --check fi -cargo install cargo-machete +which cargo-machete || cargo install cargo-machete cargo machete --with-metadata echo "Running checks in frontend" diff --git a/sync-server/src/app_state/database.rs b/sync-server/src/app_state/database.rs index 753880ec..75ce6df4 100644 --- a/sync-server/src/app_state/database.rs +++ b/sync-server/src/app_state/database.rs @@ -6,7 +6,7 @@ use log::info; use models::{ DocumentId, DocumentVersionWithoutContent, StoredDocumentVersion, VaultId, VaultUpdateId, }; -use sqlx::{sqlite::SqliteConnectOptions, types::chrono::Utc}; +use sqlx::{ConnectOptions, sqlite::SqliteConnectOptions, types::chrono::Utc}; pub mod models; use sqlx::{Pool, Sqlite, sqlite::SqlitePoolOptions}; @@ -105,7 +105,8 @@ impl Database { .create_if_missing(true) .auto_vacuum(sqlx::sqlite::SqliteAutoVacuum::Full) .busy_timeout(Duration::from_secs(3600)) - .journal_mode(sqlx::sqlite::SqliteJournalMode::Wal); + .journal_mode(sqlx::sqlite::SqliteJournalMode::Wal) + .log_slow_statements(log::LevelFilter::Warn, Duration::from_secs(30)); let pool = SqlitePoolOptions::new() .max_connections(config.max_connections_per_vault)