An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:zap: Report non-blocking workflow step failures https://github.com/siyuan-note/siyuan/issues/20264
Daniel02c14f146c8a
diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.ymlindex 5feaed717d..24b5a91ffc 100644--- a/.github/workflows/cd.yml+++ b/.github/workflows/cd.yml@@ -116,6 +116,12 @@ jobs:env:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ - name: Report non-blocking step outcomes+ if: always()+ env:+ WORKFLOW_STEPS: ${{ toJSON(steps) }}+ run: node scripts/report-workflow-outcomes.mjs+languages:name: Language validationneeds: prepare@@ -128,14 +134,26 @@ jobs:with:python-version: '3.x'- name: Test language validation+ id: test_language_validation# 测试失败只记录结果,不阻塞后续发布构建。continue-on-error: truerun: python -m unittest discover -s scripts -p "test_check_lang_keys.py"- name: Check language keys and kernel placeholdersrun: python scripts/check-lang-keys.py- name: Test editor workflow safeguards+ id: test_editor_workflow_safeguardscontinue-on-error: truerun: python -m unittest discover -s scripts -p "test_editor_e2e_workflow.py"+ - name: Test workflow outcome reporting+ id: workflow_report_tests+ continue-on-error: true+ run: node --test scripts/test-report-workflow-outcomes.mjs++ - name: Report non-blocking step outcomes+ if: always()+ env:+ WORKFLOW_STEPS: ${{ toJSON(steps) }}+ run: node scripts/report-workflow-outcomes.mjscontracts:name: API contracts and kernel tests@@ -178,6 +196,7 @@ jobs:- name: Prepare native OCR verification resourcesrun: python3 scripts/prepare-ocr.py --runtime linux-amd64 --build-worker- name: Test all kernel packages+ id: test_all_kernel_packages# 测试失败只记录结果,不阻塞后续发布构建。continue-on-error: truerun: go test -tags "fts5 sqlcipher" ./... -count=1@@ -186,6 +205,7 @@ jobs:SIYUAN_OCR_TEST_ASSETS: ${{ github.workspace }}/app/stage/ocr/modelsSIYUAN_OCR_TEST_LIBRARY: ${{ github.workspace }}/app/stage/ocr/runtime/linux-amd64/libonnxruntime.so- name: Test path fixtures with custom temporary directories+ id: test_path_fixtures_with_custom_temporary_directories# 测试失败只记录结果,不阻塞后续发布构建。continue-on-error: truerun: go test -tags "fts5 sqlcipher" ./internal/testutil ./util ./model ./server -run 'Test(PublicDataDir|IsSensitivePath|.*Obsidian|RegisterStaticFileHandlers|StaticFile|WidgetResponseCacheControl|TemplatesAndExportRequireAdministrator|SnippetPublishAccess|PluginPublish|PublishFile)' -count=1@@ -194,6 +214,12 @@ jobs:TMPDIR: /tmpGOTMPDIR: ${{ runner.temp }}+ - name: Report non-blocking step outcomes+ if: always()+ env:+ WORKFLOW_STEPS: ${{ toJSON(steps) }}+ run: node scripts/report-workflow-outcomes.mjs+frontend-tests:name: Frontend, Electron and packaging testsneeds: prepare@@ -208,6 +234,7 @@ jobs:go-version-file: kernel/go.modcache-dependency-path: kernel/go.sum- name: Test Windows process helpers+ id: test_windows_process_helpers# 测试失败只记录结果,不阻塞后续发布构建。continue-on-error: truerun: go test ./internal/elevator -count=1@@ -221,6 +248,7 @@ jobs:run: pnpm install --frozen-lockfileworking-directory: app- name: Test frontend, Electron and packaging scripts+ id: test_frontend_electron_and_packaging_scripts# 测试失败只记录结果,不阻塞后续发布构建。continue-on-error: truerun: pnpm test@@ -228,9 +256,16 @@ jobs:- name: Test OCR build and resource scriptsrun: python -m unittest discover -s scripts -p "test_*ocr*.py"- name: Test editor group selection+ id: test_editor_group_selectioncontinue-on-error: truerun: node --test scripts/test-prepare-editor-e2e-groups.mjs+ - name: Report non-blocking step outcomes+ if: always()+ env:+ WORKFLOW_STEPS: ${{ toJSON(steps) }}+ run: node scripts/report-workflow-outcomes.mjs+build:name: ${{ matrix.config.name }}# 前端测试与构建并行,发布汇总仍等待前端检查完成。@@ -408,6 +443,7 @@ jobs:working-directory: siyuan-testing- name: Stop editor kernel+ id: stop_editor_kernelif: always()continue-on-error: trueshell: bash@@ -452,6 +488,7 @@ jobs:} | tee siyuan-testing/kernel-logs/outcome.txt >> "$GITHUB_STEP_SUMMARY"- name: Upload editor reports and logs+ id: upload_editor_reports_and_logsif: always()continue-on-error: trueuses: actions/upload-artifact@v7@@ -466,6 +503,12 @@ jobs:if-no-files-found: warnretention-days: 14+ - name: Report non-blocking step outcomes+ if: always()+ env:+ WORKFLOW_STEPS: ${{ toJSON(steps) }}+ run: node source/scripts/report-workflow-outcomes.mjs+build_android:runs-on: ubuntu-24.04name: ubuntu build android.apkdiff --git a/.github/workflows/desktop-build.yml b/.github/workflows/desktop-build.ymlindex 36e85acaf7..990529cfb1 100644--- a/.github/workflows/desktop-build.yml+++ b/.github/workflows/desktop-build.yml@@ -130,6 +130,7 @@ jobs:working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}- name: Upload raw ARM editor runtime+ id: upload_raw_arm_editor_runtimeif: steps.editor-runtime.outcome == 'success'continue-on-error: trueuses: actions/upload-artifact@v7@@ -141,6 +142,7 @@ jobs:retention-days: 2- name: Checkout siyuan-testing+ id: checkout_siyuan_testingif: fromJSON(inputs.config).e2e_shards != ''continue-on-error: trueuses: actions/checkout@v6@@ -150,6 +152,7 @@ jobs:path: ${{ github.workspace }}/siyuan-testing- name: Install End-to-End Test Dependencies+ id: install_end_to_end_test_dependenciesif: fromJSON(inputs.config).e2e_shards != ''continue-on-error: truerun: pnpm install --frozen-lockfile@@ -167,6 +170,7 @@ jobs:working-directory: ${{ github.workspace }}/siyuan-testing- name: Start Kernel for End-to-End Tests+ id: start_kernel_for_end_to_end_testsif: fromJSON(inputs.config).e2e_shards != ''continue-on-error: trueshell: bash@@ -185,6 +189,7 @@ jobs:working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/kernel- name: Wait for End-to-End Test Kernels+ id: wait_for_end_to_end_test_kernelsif: fromJSON(inputs.config).e2e_shards != ''continue-on-error: trueshell: bash@@ -223,6 +228,7 @@ jobs:done- name: Run End-to-End Tests+ id: run_end_to_end_testsif: fromJSON(inputs.config).e2e_shards != ''continue-on-error: truetimeout-minutes: 50@@ -268,6 +274,7 @@ jobs:working-directory: ${{ github.workspace }}/siyuan-testing- name: Stop End-to-End Test Kernels+ id: stop_end_to_end_test_kernelsif: always() && fromJSON(inputs.config).e2e_shards != ''continue-on-error: trueshell: bash@@ -295,6 +302,7 @@ jobs:done- name: Collect End-to-End Test Logs+ id: collect_end_to_end_test_logsif: always() && fromJSON(inputs.config).e2e_shards != ''continue-on-error: trueshell: bash@@ -308,6 +316,7 @@ jobs:fi- name: Upload End-to-End Test Results+ id: upload_end_to_end_test_resultsif: always() && fromJSON(inputs.config).e2e_shards != ''continue-on-error: trueuses: actions/upload-artifact@v7@@ -359,3 +368,9 @@ jobs:${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/build/siyuan-*-linux.tar.gz${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/build/siyuan-*-linux.deb${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app/build/siyuan-*-linux.rpm++ - name: Report non-blocking step outcomes+ if: always()+ env:+ WORKFLOW_STEPS: ${{ toJSON(steps) }}+ run: node "${{ github.workspace }}/go/src/github.com/${{ github.repository }}/scripts/report-workflow-outcomes.mjs"diff --git a/scripts/report-workflow-outcomes.mjs b/scripts/report-workflow-outcomes.mjsnew file mode 100644index 0000000000..a6b2a1da3d--- /dev/null+++ b/scripts/report-workflow-outcomes.mjs@@ -0,0 +1,17 @@+import {appendFileSync} from "node:fs";+import {pathToFileURL} from "node:url";++export const reportWorkflowOutcomes = (steps) => {+ const failed = Object.entries(steps).filter(([, step]) => step.outcome === "failure" && step.conclusion === "success");+ const warnings = failed.map(([id]) => `::warning title=Non-blocking step failed::${id} failed; continue-on-error kept the job running`);+ const summary = "### Non-blocking step outcomes\n\n" + (failed.length ?+ "The following steps failed without blocking the job:\n\n" + failed.map(([id]) => `- \`${id}\`: failure`).join("\n") :+ "No non-blocking step failures.") + "\n";+ return {warnings, summary};+};++if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {+ const {warnings, summary} = reportWorkflowOutcomes(JSON.parse(process.env.WORKFLOW_STEPS));+ warnings.forEach(warning => console.log(warning));+ appendFileSync(process.env.GITHUB_STEP_SUMMARY, summary, "utf8");+}diff --git a/scripts/test-report-workflow-outcomes.mjs b/scripts/test-report-workflow-outcomes.mjsnew file mode 100644index 0000000000..594c065100--- /dev/null+++ b/scripts/test-report-workflow-outcomes.mjs@@ -0,0 +1,42 @@+import {test} from "node:test";+import * as assert from "node:assert/strict";+import {execFileSync} from "node:child_process";+import {mkdtempSync, readFileSync, rmSync, rmdirSync} from "node:fs";+import {tmpdir} from "node:os";+import {join} from "node:path";+import {fileURLToPath} from "node:url";+import {reportWorkflowOutcomes} from "./report-workflow-outcomes.mjs";++test("non-blocking failures remain visible despite a successful conclusion", () => {+ const {warnings, summary} = reportWorkflowOutcomes({+ tests: {outcome: "failure", conclusion: "success"},+ success: {outcome: "success", conclusion: "success"},+ skipped: {outcome: "skipped", conclusion: "skipped"},+ blocking: {outcome: "failure", conclusion: "failure"},+ });+ assert.equal(warnings.length, 1);+ assert.match(warnings[0], /^::warning.*tests failed/);+ assert.match(summary, /`tests`: failure/);+ assert.doesNotMatch(summary, /`success`|`skipped`|`blocking`/);+});++test("successful jobs still produce a clear summary", () => {+ const {warnings, summary} = reportWorkflowOutcomes({});+ assert.deepEqual(warnings, []);+ assert.match(summary, /No non-blocking step failures/);+});++test("workflow command writes the summary and emits an annotation", (t) => {+ const directory = mkdtempSync(join(tmpdir(), "siyuan-workflow-report-"));+ const summaryPath = join(directory, "summary.md");+ t.after(() => {+ rmSync(summaryPath, {force: true});+ rmdirSync(directory);+ });+ const output = execFileSync(process.execPath, [fileURLToPath(new URL("./report-workflow-outcomes.mjs", import.meta.url))], {+ env: {...process.env, WORKFLOW_STEPS: JSON.stringify({tests: {outcome: "failure", conclusion: "success"}}),+ GITHUB_STEP_SUMMARY: summaryPath}, encoding: "utf8",+ });+ assert.match(output, /::warning.*tests failed/);+ assert.match(readFileSync(summaryPath, "utf8"), /`tests`: failure/);+});diff --git a/scripts/test_editor_e2e_workflow.py b/scripts/test_editor_e2e_workflow.pyindex b1d64e6a0c..538779af53 100644--- a/scripts/test_editor_e2e_workflow.py+++ b/scripts/test_editor_e2e_workflow.py@@ -27,6 +27,21 @@ def snapshot_command():class EditorWorkflowTests(unittest.TestCase):+ def test_nonblocking_steps_have_ids_and_always_report_outcomes(self):+ for workflow in [CD, DESKTOP]:+ sections = re.split(r"^ [\w-]+:\n", workflow, flags=re.M)+ for section in sections:+ if "continue-on-error: true" not in section:+ continue+ for step in re.split(r"^ - ", section, flags=re.M)[1:]:+ if "continue-on-error: true" in step:+ self.assertRegex(step, r"(?m)^ id: [\w-]+$")+ report = section.split("- name: Report non-blocking step outcomes\n", 1)[1]+ self.assertIn("if: always()", report)+ self.assertIn("WORKFLOW_STEPS: ${{ toJSON(steps) }}", report)+ self.assertIn("scripts/report-workflow-outcomes.mjs", report)+ self.assertIn("node source/scripts/report-workflow-outcomes.mjs", job("editor_e2e"))+def test_builds_run_in_parallel_with_frontend_checks(self):for name in ["build", "build_macos_arm64", "build_android"]:dependencies = re.search(r"needs: \[(.*?)\]", job(name)).group(1).split(", ")@@ -69,7 +84,8 @@ class EditorWorkflowTests(unittest.TestCase):self.assertIn('--workspace="$HOME/SiYuan-Testing"', editor)self.assertNotIn("continue-on-error: true\n run: >-", editor)for name in ["Stop editor kernel", "Record editor outcome and collect logs", "Upload editor reports and logs"]:- self.assertIn(f"- name: {name}\n if: always()", editor)+ step = editor.split(f"- name: {name}\n", 1)[1].split(" - ", 1)[0]+ self.assertIn(" if: always()", step)self.assertIn("NOT RUN (test prerequisites did not complete)", editor)@unittest.skipUnless(os.name == "posix" and all(shutil.which(tool) for tool in ["bash", "node", "tar", "shasum"]),