An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:construction_worker: Run contract and unit tests during prerelease packaging https://github.com/siyuan-note/siyuan/issues/19472
Daniel9f01b444b2db
diff --git a/.github/workflows/api-contracts.yml b/.github/workflows/api-contracts.ymldeleted file mode 100644index e3c8f12a0f..0000000000--- a/.github/workflows/api-contracts.yml+++ /dev/null@@ -1,67 +0,0 @@-name: API contracts--on:- pull_request:- push:- branches: [dev, master]--permissions:- contents: read--jobs:- contracts:- runs-on: ubuntu-latest- steps:- - uses: actions/checkout@v6- with:- fetch-depth: 0- - uses: actions/setup-go@v6- with:- go-version-file: kernel/go.mod- cache-dependency-path: kernel/go.sum- - uses: actions/setup-node@v6- with:- node-version: 24- - name: Install repository pnpm version- run: node -e "require('node:child_process').execFileSync('npm', ['install', '--global', require('./app/package.json').packageManager], {stdio:'inherit'});"- - name: Install frontend dependencies- run: pnpm install --frozen-lockfile- working-directory: app- - name: Check generated contracts and route coverage- run: pnpm run api:check- working-directory: app- - name: Check legacy coverage does not grow- if: github.event_name == 'pull_request' || github.event.before != '0000000000000000000000000000000000000000'- run: pnpm run api:check --base "$API_CONTRACT_BASE"- working-directory: app- env:- API_CONTRACT_BASE: ${{ github.event.pull_request.base.sha || github.event.before }}- - name: Check application and strict contract types- run: pnpm run typecheck- working-directory: app- - name: Test all kernel packages- run: go test -tags "fts5 sqlcipher" ./... -count=1- working-directory: kernel- - name: Test path fixtures with custom temporary directories- run: go test -tags "fts5 sqlcipher" ./internal/testutil ./util ./model ./server -run 'Test(PublicDataDir|IsSensitivePath|.*Obsidian|RegisterStaticFileHandlers|StaticFile|WidgetResponseCacheControl|TemplatesAndExportRequireAdministrator|SnippetPublishAccess|PluginPublishAccess)' -count=1- working-directory: kernel- env:- TMPDIR: /tmp- GOTMPDIR: ${{ runner.temp }}-- frontend-tests:- runs-on: windows-latest- timeout-minutes: 30- steps:- - uses: actions/checkout@v6- - uses: actions/setup-node@v6- with:- node-version: 24- - name: Install repository pnpm version- run: node -e "require('node:child_process').execFileSync('npm.cmd', ['install', '--global', require('./app/package.json').packageManager], {stdio:'inherit', shell:true});"- - name: Install frontend dependencies- run: pnpm install --frozen-lockfile- working-directory: app- - name: Test frontend, Electron and packaging scripts- run: pnpm test- working-directory: appdiff --git a/.github/workflows/cd.yml b/.github/workflows/cd.ymlindex db5e56e5b4..3e462cd9bb 100644--- a/.github/workflows/cd.yml+++ b/.github/workflows/cd.yml@@ -105,10 +105,75 @@ jobs:env:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ contracts:+ name: API contracts and kernel tests+ needs: prepare+ runs-on: ubuntu-latest+ permissions:+ contents: read+ steps:+ - uses: actions/checkout@v6+ with:+ fetch-depth: 0+ - uses: actions/setup-go@v6+ with:+ go-version-file: kernel/go.mod+ cache-dependency-path: kernel/go.sum+ - uses: actions/setup-node@v6+ with:+ node-version: 24+ - name: Install repository pnpm version+ run: npm install --global ${{ needs.prepare.outputs.packageManager }}+ - name: Install frontend dependencies+ run: pnpm install --frozen-lockfile+ working-directory: app+ - name: Check generated contracts and route coverage+ run: pnpm run api:check+ working-directory: app+ - name: Check legacy coverage does not grow+ # 排除当前提交上的标签,与上一个版本比较旧接口列表。+ run: |+ API_CONTRACT_BASE=$(git describe --tags --match 'v[0-9]*' --abbrev=0 HEAD^)+ pnpm run api:check --base "$API_CONTRACT_BASE"+ working-directory: app+ - name: Check application and strict contract types+ run: pnpm run typecheck+ working-directory: app+ - name: Test all kernel packages+ run: go test -tags "fts5 sqlcipher" ./... -count=1+ working-directory: kernel+ - name: Test path fixtures with custom temporary directories+ run: go test -tags "fts5 sqlcipher" ./internal/testutil ./util ./model ./server -run 'Test(PublicDataDir|IsSensitivePath|.*Obsidian|RegisterStaticFileHandlers|StaticFile|WidgetResponseCacheControl|TemplatesAndExportRequireAdministrator|SnippetPublishAccess|PluginPublishAccess)' -count=1+ working-directory: kernel+ env:+ TMPDIR: /tmp+ GOTMPDIR: ${{ runner.temp }}++ frontend-tests:+ name: Frontend, Electron and packaging tests+ needs: prepare+ runs-on: windows-latest+ timeout-minutes: 30+ permissions:+ contents: read+ steps:+ - uses: actions/checkout@v6+ - uses: actions/setup-node@v6+ with:+ node-version: 24+ - name: Install repository pnpm version+ run: npm install --global ${{ needs.prepare.outputs.packageManager }}+ - name: Install frontend dependencies+ run: pnpm install --frozen-lockfile+ working-directory: app+ - name: Test frontend, Electron and packaging scripts+ run: pnpm test+ working-directory: app+build:runs-on: ${{ matrix.config.os }}name: ${{ matrix.config.name }}- needs: [prepare]+ needs: [prepare, contracts, frontend-tests]env:SIYUAN_E2E_SHARDS: ${{ matrix.config.e2e_shards }}strategy:@@ -454,9 +519,8 @@ jobs:build_android:runs-on: ubuntu-latestname: ubuntu build android.apk- # Android and desktop builds run in parallel, both depend on prepare.- # create_release aggregates all artifacts once both jobs succeed.- needs: prepare+ # 测试通过后并行执行 Android 和桌面构建,全部成功后汇总产物并创建发布。+ needs: [prepare, contracts, frontend-tests]steps:- name: Checkout codeuses: actions/checkout@v6diff --git a/docs/API-CONTRACTS.md b/docs/API-CONTRACTS.mdindex 9397301e62..0dfbbae1dd 100644--- a/docs/API-CONTRACTS.md+++ b/docs/API-CONTRACTS.md@@ -14,7 +14,7 @@ This document defines type declarations, compatibility requirements, generated a4. Update actual-response, input-compatibility, and strict type tests; run generation and correct calls identified by the compiler5. Synchronize generated and related public declarations in `petal`; update API documentation for public endpoints-Generation checks inspect actual route and handler declarations to verify methods, paths, handlers, and contract adapters. CI compares the legacy list with the pre-change list and prevents additional records. Do not bypass contract checks with `any`, type assertions, or changes to the legacy list.+Generation checks inspect actual route and handler declarations to verify methods, paths, handlers, and contract adapters. Prerelease CI compares the legacy list with the previous version tag reachable from the current commit's parent and prevents additional records. Do not bypass contract checks with `any`, type assertions, or changes to the legacy list.## Contracts and implementation@@ -177,4 +177,4 @@ go test -tags "fts5 sqlcipher" ./... -count=1Import and static-file fixtures use `internal/testutil.PublicDataDir` to create and clean up explicitly validated non-sensitive directories independently of `TMPDIR` and `GOTMPDIR`. The helper tries the user home, current directory, and filesystem root, and reports a fixture setup failure if none is safe and writable. CI also reruns the affected path tests with `/tmp` as `TMPDIR` and a separate `GOTMPDIR` to cover environment overrides.-CI runs all kernel packages on Linux and all frontend, Electron, and packaging-script tests on Windows. Frontend discovery is restricted to `src/**/*.test.ts`, `tests/**/*.test.js`, `electron/**/*.test.js`, and `scripts/**/*.test.js`, so packaged copies under `app/build` are excluded. Test files run serially to avoid Electron process startup contention. New regression tests in these locations are included automatically; update the test command and this document when adding a new test location or filename convention. Keep `Contract` in Go contract regression test names so they remain easy to run separately.+The prerelease workflow `.github/workflows/cd.yml` runs contract and type checks, all kernel packages on Linux, and all frontend, Electron, and packaging-script tests on Windows. These checks run only for prerelease tag pushes (`*-alpha*`, `*-beta*`, `*-rc*`) or manual dispatch of this workflow; ordinary branch pushes and pull requests do not trigger them. Desktop and Android packaging require both test jobs to pass. Frontend discovery is restricted to `src/**/*.test.ts`, `tests/**/*.test.js`, `electron/**/*.test.js`, and `scripts/**/*.test.js`, so packaged copies under `app/build` are excluded. Test files run serially to avoid Electron process startup contention. New regression tests in these locations are included automatically; update the test command and this document when adding a new test location or filename convention. Keep `Contract` in Go contract regression test names so they remain easy to run separately.