mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-28 12:03:20 +00:00
Keep the Node.js build helper and its tests in the build-script directory recognised by Community review. Update the Vite import and unit CI path filters while preserving the copy behaviour and release artefacts.
250 lines
7.9 KiB
YAML
250 lines
7.9 KiB
YAML
# Run Unit test without Harnesses
|
|
name: unit-ci
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
- beta
|
|
paths:
|
|
- 'manifest.json'
|
|
- 'updates.md'
|
|
- 'src/**'
|
|
- 'test/**'
|
|
- '_tools/**'
|
|
- 'scripts/**'
|
|
- 'package.json'
|
|
- 'package-lock.json'
|
|
- 'tsconfig.json'
|
|
- 'vite.config.ts'
|
|
- 'vitest.config*.ts'
|
|
- 'esbuild.config.mjs'
|
|
- 'eslint.config.mjs'
|
|
- 'eslint.config.common.mjs'
|
|
- 'eslint.community.config.mjs'
|
|
- 'terser.config.mjs'
|
|
- 'update-workspaces.mjs'
|
|
- 'version-bump.mjs'
|
|
- 'utils/check-compatibility.js'
|
|
- 'utils/livesync-commonlib-version.test.ts'
|
|
- 'utils/livesync-commonlib-version.ts'
|
|
- 'utils/*ci*.unit.spec.ts'
|
|
- 'utils/cli-docker-*.mjs'
|
|
- 'utils/release-*.mjs'
|
|
- 'utils/release-*.unit.spec.ts'
|
|
- 'utils/couchdb/**'
|
|
- 'utils/flyio/**'
|
|
- 'utils/setup/**'
|
|
- '.github/workflows/prepare-release.yml'
|
|
- '.github/workflows/finalise-release.yml'
|
|
- '.github/workflows/release.yml'
|
|
- '.github/workflows/cli-deno-tests.yml'
|
|
- '.github/workflows/cli-p2p-tests.yml'
|
|
- '.github/workflows/cli-docker-validation.yml'
|
|
- '.github/workflows/cli-docker.yml'
|
|
- '.github/workflows/unit-ci.yml'
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, ready_for_review]
|
|
paths:
|
|
- 'manifest.json'
|
|
- 'updates.md'
|
|
- 'src/**'
|
|
- 'test/**'
|
|
- '_tools/**'
|
|
- 'scripts/**'
|
|
- 'package.json'
|
|
- 'package-lock.json'
|
|
- 'tsconfig.json'
|
|
- 'vite.config.ts'
|
|
- 'vitest.config*.ts'
|
|
- 'esbuild.config.mjs'
|
|
- 'eslint.config.mjs'
|
|
- 'eslint.config.common.mjs'
|
|
- 'eslint.community.config.mjs'
|
|
- 'terser.config.mjs'
|
|
- 'update-workspaces.mjs'
|
|
- 'version-bump.mjs'
|
|
- 'utils/check-compatibility.js'
|
|
- 'utils/livesync-commonlib-version.test.ts'
|
|
- 'utils/livesync-commonlib-version.ts'
|
|
- 'utils/*ci*.unit.spec.ts'
|
|
- 'utils/cli-docker-*.mjs'
|
|
- 'utils/release-*.mjs'
|
|
- 'utils/release-*.unit.spec.ts'
|
|
- 'utils/couchdb/**'
|
|
- 'utils/flyio/**'
|
|
- 'utils/setup/**'
|
|
- '.github/workflows/prepare-release.yml'
|
|
- '.github/workflows/finalise-release.yml'
|
|
- '.github/workflows/release.yml'
|
|
- '.github/workflows/cli-deno-tests.yml'
|
|
- '.github/workflows/cli-p2p-tests.yml'
|
|
- '.github/workflows/cli-docker-validation.yml'
|
|
- '.github/workflows/cli-docker.yml'
|
|
- '.github/workflows/unit-ci.yml'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
setup-tools:
|
|
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
|
|
name: Self-hosted setup tools
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: '24.x'
|
|
cache: 'npm'
|
|
|
|
- name: Setup Deno
|
|
uses: denoland/setup-deno@v2
|
|
with:
|
|
deno-version: v2.x
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run setup-tool contract tests
|
|
run: npm run test:setup-tools
|
|
|
|
- name: Create CouchDB test configuration
|
|
run: |
|
|
cat <<EOF > .test.env
|
|
hostname=http://127.0.0.1:5989/
|
|
dbname=livesync-test-db
|
|
username=admin
|
|
password=testpassword
|
|
EOF
|
|
|
|
- name: Start CouchDB
|
|
run: npm run test:docker-couchdb:start
|
|
|
|
- name: Provision a versioned LiveSync database
|
|
run: npx dotenv-cli -e .test.env -- env database=setup-tools-ci retry_count=1 retry_delay_ms=0 ./utils/couchdb/couchdb-init.sh
|
|
|
|
- name: Verify the Commonlib database version
|
|
run: |
|
|
npx dotenv-cli -e .test.env -- bash -lc 'curl --fail --silent --show-error --user "${username}:${password}" "${hostname}/setup-tools-ci/obsydian_livesync_version" | node --input-type=module -e "import { VER } from \"@vrtmrz/livesync-commonlib/compat/common/types\";let input=\"\";process.stdin.on(\"data\",chunk=>input+=chunk).on(\"end\",()=>{const document=JSON.parse(input);if(document.type!==\"versioninfo\"||document.version!==VER)throw new Error(\"Unexpected LiveSync database version\");})"'
|
|
|
|
- name: Stop CouchDB
|
|
if: always()
|
|
run: npm run test:docker-couchdb:stop || true
|
|
|
|
unit-test:
|
|
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
|
|
name: Unit Tests
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: '24.x'
|
|
cache: 'npm'
|
|
|
|
- name: Verify clean installation with npm 10
|
|
run: npx --yes npm@10.9.4 ci --ignore-scripts --no-audit --no-fund
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run source checks
|
|
run: npm run check
|
|
|
|
- name: Run release process tests
|
|
run: npm run test:release-process
|
|
|
|
- name: Run unit tests suite with coverage
|
|
run: npm run test:unit:coverage
|
|
|
|
- name: Run real-Obsidian runner contract tests
|
|
run: npm run test:e2e:obsidian:runner
|
|
|
|
- name: Upload coverage report
|
|
if: always()
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: unit-coverage-report
|
|
path: coverage/**
|
|
|
|
integration-test:
|
|
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
|
|
name: Integration Tests
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Detect LiveSync-owned integration tests
|
|
id: integration_tests
|
|
shell: bash
|
|
run: |
|
|
git ls-files -- ':(glob)**/*.integration.spec.ts' ':(glob)**/*.integration.test.ts' > "$RUNNER_TEMP/livesync-integration-tests.txt"
|
|
if [[ -s "$RUNNER_TEMP/livesync-integration-tests.txt" ]]; then
|
|
echo 'present=true' >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo 'present=false' >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Record delegated integration coverage
|
|
if: ${{ steps.integration_tests.outputs.present != 'true' }}
|
|
run: echo 'No LiveSync-owned integration tests are present. Commonlib integration tests run in the Commonlib package CI.' >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
- name: Setup Node.js
|
|
if: ${{ steps.integration_tests.outputs.present == 'true' }}
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: '24.x'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
if: ${{ steps.integration_tests.outputs.present == 'true' }}
|
|
run: npm ci
|
|
|
|
- name: Create environment configuration files
|
|
if: ${{ steps.integration_tests.outputs.present == 'true' }}
|
|
run: |
|
|
cat <<EOF > .env
|
|
BUILD_MODE=dev
|
|
PATHS_TEST_INSTALL=
|
|
EOF
|
|
cat <<EOF > .test.env
|
|
hostname=http://127.0.0.1:5989/
|
|
dbname=livesync-test-db2
|
|
username=admin
|
|
password=testpassword
|
|
minioEndpoint=http://127.0.0.1:9000
|
|
accessKey=minioadmin
|
|
secretKey=minioadmin
|
|
bucketName=livesync-test-bucket
|
|
EOF
|
|
|
|
- name: Start CouchDB container
|
|
if: ${{ steps.integration_tests.outputs.present == 'true' }}
|
|
run: npm run test:docker-couchdb:start
|
|
|
|
- name: Start RustFS container
|
|
if: ${{ steps.integration_tests.outputs.present == 'true' }}
|
|
run: npm run test:docker-s3:start
|
|
|
|
- name: Run integration tests
|
|
if: ${{ steps.integration_tests.outputs.present == 'true' }}
|
|
run: npm run test:integration
|
|
|
|
- name: Stop containers
|
|
if: ${{ always() && steps.integration_tests.outputs.present == 'true' }}
|
|
run: |
|
|
npm run test:docker-couchdb:stop || true
|
|
npm run test:docker-s3:stop || true
|