From 0625335c2cab147fc7f29a34640c3f767740d02f Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 16:47:48 +0100 Subject: [PATCH 01/12] fix(ci): run tests for Poetry dependency changes Replace the obsolete requirements.txt test and skip filters with pyproject.toml and poetry.lock, and update the skip-job message. Signed-off-by: Eike Waldt On-behalf-of: SAP Assisted-by: opencode:gpt-6.1-sol --- .github/workflows/tests-skip.yml | 8 +++++--- .github/workflows/tests.yml | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests-skip.yml b/.github/workflows/tests-skip.yml index 13d57f8..25b0879 100644 --- a/.github/workflows/tests-skip.yml +++ b/.github/workflows/tests-skip.yml @@ -6,7 +6,8 @@ on: paths-ignore: - 'src/**' - 'tests/**' - - 'requirements.txt' + - 'pyproject.toml' + - 'poetry.lock' - 'Makefile' - '.github/workflows/tests.yml' - '.github/workflows/tests-skip.yml' @@ -15,7 +16,8 @@ on: paths-ignore: - 'src/**' - 'tests/**' - - 'requirements.txt' + - 'pyproject.toml' + - 'poetry.lock' - 'Makefile' - '.github/workflows/tests.yml' - '.github/workflows/tests-skip.yml' @@ -29,5 +31,5 @@ jobs: runs-on: ubuntu-latest steps: - run: | - echo "No changes under src/, tests/, requirements.txt, or Makefile." + echo "No changes under src/, tests/, pyproject.toml, poetry.lock, or Makefile." echo "Skipping test run; reporting success so a required check is satisfied." diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7cfbf0d..fdd3b4c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,8 @@ on: paths: - 'src/**' - 'tests/**' - - 'requirements.txt' + - 'pyproject.toml' + - 'poetry.lock' - 'Makefile' - '.github/workflows/tests.yml' - '.github/workflows/tests-skip.yml' @@ -15,7 +16,8 @@ on: paths: - 'src/**' - 'tests/**' - - 'requirements.txt' + - 'pyproject.toml' + - 'poetry.lock' - 'Makefile' - '.github/workflows/tests.yml' - '.github/workflows/tests-skip.yml' From bb29caef0a03d3f28d5fefd23e372666b573ab2a Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 16:48:03 +0100 Subject: [PATCH 02/12] fix(ci): align reusable workflow permissions Remove unused actions and packages permissions so nested docs checks do not request permissions their caller cannot grant. Signed-off-by: Eike Waldt On-behalf-of: SAP Assisted-by: opencode:gpt-6.1-sol --- .github/workflows/docs-checks.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index 9225478..3aea9ed 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -2,8 +2,6 @@ name: Documentation Quality Checks permissions: contents: read - actions: read - packages: read on: workflow_call: From 98be646a863ab9d2c0a54c68acb190fc19e5bb0c Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 16:48:15 +0100 Subject: [PATCH 03/12] fix(ci): fail docs gate when change detection fails Require successful change detection and an explicit false result before skipping checks; failed or missing detection outputs can no longer pass the gate. Signed-off-by: Eike Waldt On-behalf-of: SAP Assisted-by: opencode:gpt-6.1-sol --- .github/workflows/aggregated-repo-docs.yml | 14 ++- Makefile | 12 ++- tests/conftest.py | 5 +- tests/unit/test_auto_glossary_advanced.py | 2 + tests/unit/test_auto_glossary_format.py | 2 + tests/unit/test_auto_glossary_integration.py | 2 + tests/unit/test_generate_anchor.py | 2 + tests/workflows/conftest.py | 100 +++++++++++++++++++ tests/workflows/test_gate.py | 26 +++++ 9 files changed, 158 insertions(+), 7 deletions(-) create mode 100644 tests/workflows/conftest.py create mode 100644 tests/workflows/test_gate.py diff --git a/.github/workflows/aggregated-repo-docs.yml b/.github/workflows/aggregated-repo-docs.yml index 8dd0314..5d3ebbe 100644 --- a/.github/workflows/aggregated-repo-docs.yml +++ b/.github/workflows/aggregated-repo-docs.yml @@ -113,14 +113,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Evaluate docs checks result + env: + DETECT_RESULT: ${{ needs.detect-changes.result }} + DOCS_CHANGED: ${{ needs.detect-changes.outputs.docs }} + DOCS_RESULT: ${{ needs.docs-checks.result }} run: | - DOCS_CHANGED="${{ needs.detect-changes.outputs.docs }}" - DOCS_RESULT="${{ needs.docs-checks.result }}" - if [[ "$DOCS_CHANGED" != "true" ]]; then + if [[ "$DETECT_RESULT" != "success" ]]; then + echo "Change detection result: $DETECT_RESULT" + exit 1 + fi + if [[ "$DOCS_CHANGED" == "false" ]]; then echo "Docs paths not changed; skipping docs checks — gate passes." exit 0 fi - if [[ "$DOCS_RESULT" == "success" ]]; then + if [[ "$DOCS_CHANGED" == "true" && "$DOCS_RESULT" == "success" ]]; then echo "Docs checks passed." exit 0 fi diff --git a/Makefile b/Makefile index d4edeb8..d74d7ca 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help run build preview publish transform aggregate aggregate-repo aggregate-update-repo aggregate-repo-single aggregate-update-repo-single test-aggregate-local clean clean-projects clean-aggregated-git test test-unit test-integration check spelling linkcheck woke glossary glossary-check docs-check docs-check-strict format check-system-deps check-python-deps check-npm-deps +.PHONY: help run build preview publish transform aggregate aggregate-repo aggregate-update-repo aggregate-repo-single aggregate-update-repo-single test-aggregate-local clean clean-projects clean-aggregated-git test test-unit test-integration test-workflows check-workflow-deps check spelling linkcheck woke glossary glossary-check docs-check docs-check-strict format check-system-deps check-python-deps check-npm-deps help: @echo "Garden Linux Documentation Hub - Available targets:" @@ -14,6 +14,7 @@ help: @echo " test - Run full test suite (unit + integration)" @echo " test-unit - Run unit tests only" @echo " test-integration - Run integration tests only" + @echo " test-workflows - Run offline workflow regression tests" @echo "" @echo " Quality Checks:" @echo " check - Run all quality checks (spelling, links, inclusive language)" @@ -146,6 +147,15 @@ test-integration: install-python @echo "Running integration tests..." python3 -m pytest tests/integration/ -v +check-workflow-deps: check-python-deps + @for tool in bash git node; do \ + command -v "$$tool" >/dev/null 2>&1 || { echo "$$tool is required for workflow tests"; exit 1; }; \ + done + +test-workflows: check-workflow-deps install-python + @echo "Running workflow regression tests..." + python3 -m pytest tests/workflows/ -v + # Quality Checks check: spelling linkcheck woke @echo "All quality checks passed!" diff --git a/tests/conftest.py b/tests/conftest.py index 0ea0aea..857db86 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,6 @@ import sys from pathlib import Path -import nltk import pytest # Add project root to path so we can import src/aggregation @@ -11,8 +10,10 @@ sys.path.insert(0, str(project_root / "src")) -@pytest.fixture(scope="session", autouse=True) +@pytest.fixture(scope="session") def download_nltk_data(): + import nltk + try: nltk.data.find("corpora/wordnet") except LookupError: diff --git a/tests/unit/test_auto_glossary_advanced.py b/tests/unit/test_auto_glossary_advanced.py index 9af4130..87df505 100644 --- a/tests/unit/test_auto_glossary_advanced.py +++ b/tests/unit/test_auto_glossary_advanced.py @@ -4,6 +4,8 @@ from aggregation.auto_glossary import AutoGlossary +pytestmark = pytest.mark.usefixtures("download_nltk_data") + class TestAliasExtraction: """Tests for automatic alias extraction from glossary terms.""" diff --git a/tests/unit/test_auto_glossary_format.py b/tests/unit/test_auto_glossary_format.py index 4c8b97f..211d6d6 100644 --- a/tests/unit/test_auto_glossary_format.py +++ b/tests/unit/test_auto_glossary_format.py @@ -6,6 +6,8 @@ from aggregation.auto_glossary import GLOSSARY_ENTRY_FORMAT, AutoGlossary +pytestmark = pytest.mark.usefixtures("download_nltk_data") + class TestGlossaryEntryFormat: """Tests for glossary entry format configuration.""" diff --git a/tests/unit/test_auto_glossary_integration.py b/tests/unit/test_auto_glossary_integration.py index c080abf..a0614aa 100644 --- a/tests/unit/test_auto_glossary_integration.py +++ b/tests/unit/test_auto_glossary_integration.py @@ -6,6 +6,8 @@ from aggregation.auto_glossary import AutoGlossary, process_glossary_links +pytestmark = pytest.mark.usefixtures("download_nltk_data") + class TestAutoGlossaryIntegration: """Integration tests for complete glossary linking workflow.""" diff --git a/tests/unit/test_generate_anchor.py b/tests/unit/test_generate_anchor.py index f17fac7..7df8b8d 100644 --- a/tests/unit/test_generate_anchor.py +++ b/tests/unit/test_generate_anchor.py @@ -6,6 +6,8 @@ from aggregation.auto_glossary import AutoGlossary +pytestmark = pytest.mark.usefixtures("download_nltk_data") + class TestGenerateAnchor: """Tests for VitePress-compatible anchor generation.""" diff --git a/tests/workflows/conftest.py b/tests/workflows/conftest.py new file mode 100644 index 0000000..18b8688 --- /dev/null +++ b/tests/workflows/conftest.py @@ -0,0 +1,100 @@ +"""Fixtures for executing workflow snippets without a GitHub connection.""" + +import json +import os +import shutil +import subprocess +from pathlib import Path + +import pytest +import yaml + +ROOT = Path(__file__).resolve().parents[2] + + +@pytest.fixture +def workflow(): + def load(name): + return yaml.load( + (ROOT / ".github/workflows" / name).read_text(encoding="utf-8"), + Loader=yaml.BaseLoader, + ) + + return load + + +@pytest.fixture +def workflow_step(workflow): + def find(name, job, *, step_id=None, contains=None): + for step in workflow(name)["jobs"][job]["steps"]: + if step_id is not None and step.get("id") == step_id: + return step + script = step.get("run", step.get("with", {}).get("script", "")) + if contains is not None and contains in script: + return step + pytest.fail(f"Workflow step not found: {name}/{job}") + + return find + + +@pytest.fixture +def executable(): + def find(name): + path = shutil.which(name) + if path is None: + pytest.skip(f"{name} is needed for this workflow test") + return path + + return find + + +@pytest.fixture +def run_bash(executable): + bash = executable("bash") + + def run(script, *, env=None, cwd=ROOT): + return subprocess.run( + [bash, "-e", "-o", "pipefail", "-c", script], + env={**os.environ, **(env or {})}, + cwd=cwd, + text=True, + capture_output=True, + timeout=30, + ) + + return run + + +@pytest.fixture +def run_javascript(executable): + node = executable("node") + + def run(script, *, env=None, cwd=ROOT, **inputs): + return subprocess.run( + [node, str(ROOT / "tests/fixtures/workflows/run-script.cjs")], + input=json.dumps({"script": script, **inputs}), + env={**os.environ, **(env or {})}, + cwd=cwd, + text=True, + capture_output=True, + timeout=30, + ) + + return run + + +@pytest.fixture +def git_repo(tmp_path, executable): + git = executable("git") + + def run(*args): + return subprocess.check_output( + [git, *args], cwd=tmp_path, text=True, stderr=subprocess.STDOUT + ).strip() + + run("init") + run("config", "user.name", "Workflow Test") + run("config", "user.email", "workflow-test@example.test") + run("config", "commit.gpgsign", "false") + run("config", "core.hooksPath", str(tmp_path / "no-hooks")) + return tmp_path, run diff --git a/tests/workflows/test_gate.py b/tests/workflows/test_gate.py new file mode 100644 index 0000000..406a54f --- /dev/null +++ b/tests/workflows/test_gate.py @@ -0,0 +1,26 @@ +"""The docs gate must not turn failed or missing detection into success.""" + +import pytest + + +@pytest.mark.parametrize( + "detect,changed,checks,expected", + [ + ("failure", "", "skipped", 1), + ("cancelled", "", "skipped", 1), + ("success", "", "success", 1), + ("success", "false", "skipped", 0), + ("success", "true", "success", 0), + ("success", "true", "failure", 1), + ("success", "true", "skipped", 1), + ], +) +def test_docs_gate(workflow_step, run_bash, detect, changed, checks, expected): + step = workflow_step( + "aggregated-repo-docs.yml", "docs-checks-gate", contains="DOCS_CHANGED" + ) + result = run_bash( + step["run"], + env={"DETECT_RESULT": detect, "DOCS_CHANGED": changed, "DOCS_RESULT": checks}, + ) + assert result.returncode == expected, result.stderr From 2f9040a5b3781ab288d2da9f94b17c1fed2738b9 Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 16:48:24 +0100 Subject: [PATCH 04/12] fix(ci): validate docs dispatch payloads safely Validate repository, PR, SHA, event and Git ref before issuing an App token; pass payload values through environment variables instead of executable shell or JavaScript interpolation. Signed-off-by: Eike Waldt On-behalf-of: SAP Assisted-by: opencode:gpt-6.1-sol --- .github/workflows/aggregated-repo-docs.yml | 4 +- .github/workflows/docs-pr.yml | 98 ++++++++++++++-------- tests/fixtures/workflows/run-script.cjs | 38 +++++++++ tests/workflows/test_payload.py | 56 +++++++++++++ 4 files changed, 160 insertions(+), 36 deletions(-) create mode 100644 tests/fixtures/workflows/run-script.cjs create mode 100644 tests/workflows/test_payload.py diff --git a/.github/workflows/aggregated-repo-docs.yml b/.github/workflows/aggregated-repo-docs.yml index 5d3ebbe..9bfd91b 100644 --- a/.github/workflows/aggregated-repo-docs.yml +++ b/.github/workflows/aggregated-repo-docs.yml @@ -176,6 +176,8 @@ jobs: - name: Send repository dispatch to docs if: steps.creds.outputs.available == 'true' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + DOCS_REPO: ${{ inputs.repo }} with: github-token: ${{ steps.app-token.outputs.token }} script: | @@ -193,7 +195,7 @@ jobs: repo: 'docs', event_type: 'docs-pr', client_payload: { - repo: '${{ inputs.repo }}', + repo: process.env.DOCS_REPO, pr_number: `${context.payload.pull_request.number}`, commit_sha: isMergedPR ? context.payload.pull_request.merge_commit_sha diff --git a/.github/workflows/docs-pr.yml b/.github/workflows/docs-pr.yml index b2eacf9..f3f65e9 100644 --- a/.github/workflows/docs-pr.yml +++ b/.github/workflows/docs-pr.yml @@ -36,13 +36,46 @@ jobs: create-pr: runs-on: ubuntu-latest steps: + - name: Validate and extract payload + id: payload + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const payload = context.eventName === 'workflow_dispatch' + ? context.payload.inputs : context.payload.client_payload; + if (!payload || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(payload.repo || '')) { + throw new Error('Invalid repository name'); + } + if (!/^[1-9]\d*$/.test(String(payload.pr_number)) || + !Number.isSafeInteger(Number(payload.pr_number))) { + throw new Error('Invalid source PR number'); + } + if (!/^[a-fA-F0-9]{40}$/.test(payload.commit_sha || '')) { + throw new Error('Expected a full commit SHA'); + } + if (!['pr_success', 'merged'].includes(payload.event)) { + throw new Error('Invalid docs event'); + } + if (typeof payload.ref !== 'string' || !payload.ref || payload.ref === 'HEAD') { + throw new Error('Expected a source branch or tag'); + } + const refCheck = await exec.getExecOutput( + 'git', ['check-ref-format', '--branch', payload.ref], + {silent: true, ignoreReturnCode: true} + ); + if (refCheck.exitCode !== 0) throw new Error('Invalid source ref'); + for (const key of ['repo', 'pr_number', 'commit_sha', 'ref', 'event']) { + core.setOutput(key, String(payload[key])); + } + core.setOutput('payload', JSON.stringify(payload)); + - name: Generate GitHub App token id: app-token uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0 with: client-id: ${{ secrets.DOCS_BOT_APP_ID }} private-key: ${{ secrets.DOCS_BOT_PRIVATE_KEY }} - repositories: docs,${{ github.event.client_payload.repo || inputs.repo }} + repositories: docs,${{ steps.payload.outputs.repo }} - name: Checkout docs uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -51,42 +84,29 @@ jobs: fetch-depth: 0 - name: Configure git + env: + BOT_APP_ID: ${{ secrets.DOCS_BOT_APP_ID }} run: | git config user.name "gardenlinux-docs-bot[bot]" - git config user.email "${{ secrets.DOCS_BOT_APP_ID }}+gardenlinux-docs-bot[bot]@users.noreply.github.com" - - - name: Extract payload - id: payload - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 - with: - script: | - let payload; - if (context.eventName === 'workflow_dispatch') { - payload = context.payload.inputs; - } else { - payload = context.payload.client_payload; - } - core.setOutput('repo', payload.repo); - core.setOutput('pr_number', payload.pr_number); - core.setOutput('commit_sha', payload.commit_sha); - core.setOutput('ref', payload.ref); - core.setOutput('event', payload.event); + git config user.email "$BOT_APP_ID+gardenlinux-docs-bot[bot]@users.noreply.github.com" - name: Create or update branch + env: + DOCS_REPO: ${{ steps.payload.outputs.repo }} + SOURCE_PR: ${{ steps.payload.outputs.pr_number }} run: | - BRANCH="auto/${{ steps.payload.outputs.repo }}/${{ steps.payload.outputs.pr_number }}" + BRANCH="auto/$DOCS_REPO/$SOURCE_PR" git fetch origin main git checkout -B "$BRANCH" origin/main - name: Update repos-config.json uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + DOCS_PAYLOAD: ${{ steps.payload.outputs.payload }} with: script: | const fs = require('fs'); - const repoName = '${{ steps.payload.outputs.repo }}'; - const commitSha = '${{ steps.payload.outputs.commit_sha }}'; - const ref = '${{ steps.payload.outputs.ref }}'; - const event = '${{ steps.payload.outputs.event }}'; + const {repo: repoName, commit_sha: commitSha, ref} = JSON.parse(process.env.DOCS_PAYLOAD); const config = JSON.parse(fs.readFileSync('repos-config.json', 'utf8')); @@ -110,22 +130,25 @@ jobs: core.info(`Updated ${repoName}: ref=${ref}, commit=${commitSha}`); - name: Commit and push + env: + DOCS_REPO: ${{ steps.payload.outputs.repo }} + SOURCE_PR: ${{ steps.payload.outputs.pr_number }} + COMMIT_SHA: ${{ steps.payload.outputs.commit_sha }} run: | git add repos-config.json - git commit -m "docs(${{ steps.payload.outputs.repo }}): update commit lock to ${{ steps.payload.outputs.commit_sha }}" - git push -f origin "auto/${{ steps.payload.outputs.repo }}/${{ steps.payload.outputs.pr_number }}" + git commit -m "docs($DOCS_REPO): update commit lock to $COMMIT_SHA" + git push -f origin "auto/$DOCS_REPO/$SOURCE_PR" - name: Create or update PR id: docs_pr uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + DOCS_PAYLOAD: ${{ steps.payload.outputs.payload }} with: github-token: ${{ steps.app-token.outputs.token }} script: | - const branch = `auto/${{ steps.payload.outputs.repo }}/${{ steps.payload.outputs.pr_number }}`; - const prNumber = '${{ steps.payload.outputs.pr_number }}'; - const repo = '${{ steps.payload.outputs.repo }}'; - const event = '${{ steps.payload.outputs.event }}'; - const commitSha = '${{ steps.payload.outputs.commit_sha }}'; + const {repo, pr_number: prNumber, event, commit_sha: commitSha} = JSON.parse(process.env.DOCS_PAYLOAD); + const branch = `auto/${repo}/${prNumber}`; // Check if PR already exists const { data: existingPRs } = await github.rest.pulls.list({ @@ -204,13 +227,18 @@ jobs: - name: Comment on source PR if: steps.payload.outputs.pr_number != '' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + DOCS_PAYLOAD: ${{ steps.payload.outputs.payload }} + DOCS_PR_URL: ${{ steps.docs_pr.outputs.pr_url }} + DOCS_PR_NUMBER: ${{ steps.docs_pr.outputs.docs_pr_number }} with: github-token: ${{ steps.app-token.outputs.token }} script: | - const prNumber = parseInt('${{ steps.payload.outputs.pr_number }}'); - const repo = '${{ steps.payload.outputs.repo }}'; - const prUrl = '${{ steps.docs_pr.outputs.pr_url }}'; - const docsPrNumber = '${{ steps.docs_pr.outputs.docs_pr_number }}'; + const payload = JSON.parse(process.env.DOCS_PAYLOAD); + const prNumber = Number(payload.pr_number); + const repo = payload.repo; + const prUrl = process.env.DOCS_PR_URL; + const docsPrNumber = process.env.DOCS_PR_NUMBER; const commentBody = `📚 **Documentation Preview PR:** ${prUrl} 😎 **Deploy Preview:** https://deploy-preview-${docsPrNumber}--gardenlinux-docs.netlify.app diff --git a/tests/fixtures/workflows/run-script.cjs b/tests/fixtures/workflows/run-script.cjs new file mode 100644 index 0000000..959fb8a --- /dev/null +++ b/tests/fixtures/workflows/run-script.cjs @@ -0,0 +1,38 @@ +// Mock GitHub responses and capture calls; this does not validate GitHub's API schemas. +const fs = require('node:fs'); +const {spawnSync} = require('node:child_process'); +const input = JSON.parse(fs.readFileSync(0, 'utf8')); +const outputs = {}; +const calls = []; +const core = { + setOutput: (name, value) => { outputs[name] = value; }, + setFailed: message => { throw new Error(message); }, + info: () => {}, +}; +const exec = {getExecOutput: async (command, args) => { + const result = spawnSync(command, args, {encoding: 'utf8'}); + if (result.error) throw result.error; + return {exitCode: result.status, stdout: result.stdout}; +}}; +const github = { + paginate: async () => input.files || [], + rest: { + pulls: { + get: async () => ({data: input.source}), + listFiles: () => {}, + list: async () => ({data: input.prs || []}), + update: async args => { calls.push({method: 'update', args}); }, + create: async args => { + calls.push({method: 'create', args}); + return {data: {number: 42, html_url: 'https://example.test/pull/42'}}; + }, + }, + }, + graphql: async (query, args) => { calls.push({method: 'graphql', query, args}); }, +}; +const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; +(async () => { + const script = new AsyncFunction('context', 'core', 'exec', 'github', 'require', input.script); + await script(input.context || {}, core, exec, github, require); + console.log(JSON.stringify({outputs, calls})); +})().catch(error => { console.error(error.message); process.exitCode = 1; }); diff --git a/tests/workflows/test_payload.py b/tests/workflows/test_payload.py new file mode 100644 index 0000000..0930517 --- /dev/null +++ b/tests/workflows/test_payload.py @@ -0,0 +1,56 @@ +"""Dispatch validation accepts valid refs and rejects malformed identifiers.""" + +import json + +import pytest + + +@pytest.fixture +def payload(): + return { + "repo": "gardenlinux", + "pr_number": "123", + "commit_sha": "a" * 40, + "ref": "feature/o'connor", + "event": "pr_success", + } + + +@pytest.mark.parametrize( + "event,key", + [("workflow_dispatch", "inputs"), ("repository_dispatch", "client_payload")], +) +def test_valid_payload(workflow_step, run_javascript, payload, event, key): + step = workflow_step("docs-pr.yml", "create-pr", step_id="payload") + script = step["with"]["script"] + result = run_javascript( + script, context={"eventName": event, "payload": {key: payload}} + ) + assert result.returncode == 0, result.stderr + outputs = json.loads(result.stdout)["outputs"] + assert outputs["ref"] == payload["ref"] + assert json.loads(outputs["payload"]) == payload + + +@pytest.mark.parametrize( + "key,value", + [ + ("repo", "x,$(evil)"), + ("pr_number", "1;evil"), + ("commit_sha", "short"), + ("event", "unknown"), + ("ref", "bad\nref"), + ("ref", "-main"), + ], +) +def test_invalid_payload(workflow_step, run_javascript, payload, key, value): + step = workflow_step("docs-pr.yml", "create-pr", step_id="payload") + script = step["with"]["script"] + result = run_javascript( + script, + context={ + "eventName": "repository_dispatch", + "payload": {"client_payload": {**payload, key: value}}, + }, + ) + assert result.returncode != 0 From cf062e024ddd2a25889874d6cc74787ece63bf96 Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 16:48:35 +0100 Subject: [PATCH 05/12] fix(ci): update docs PR draft status with GraphQL Use the supported ready-for-review and convert-to-draft mutations when an existing PR changes state, rather than passing an unsupported draft field to the REST update API. Signed-off-by: Eike Waldt On-behalf-of: SAP Assisted-by: opencode:gpt-6.1-sol --- .github/workflows/docs-pr.yml | 16 ++++++++++++- tests/workflows/test_draft.py | 43 +++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/workflows/test_draft.py diff --git a/.github/workflows/docs-pr.yml b/.github/workflows/docs-pr.yml index f3f65e9..ba06945 100644 --- a/.github/workflows/docs-pr.yml +++ b/.github/workflows/docs-pr.yml @@ -185,10 +185,24 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, pull_number: existingPR.number, - draft: isDraft, body: updateBody }); + if (existingPR.draft !== isDraft) { + const mutation = isDraft + ? `mutation($pullRequestId: ID!) { + convertPullRequestToDraft(input: {pullRequestId: $pullRequestId}) { + pullRequest { id } + } + }` + : `mutation($pullRequestId: ID!) { + markPullRequestReadyForReview(input: {pullRequestId: $pullRequestId}) { + pullRequest { id } + } + }`; + await github.graphql(mutation, {pullRequestId: existingPR.node_id}); + } + prUrl = existingPR.html_url; docsPrNumber = existingPR.number; } else { diff --git a/tests/workflows/test_draft.py b/tests/workflows/test_draft.py new file mode 100644 index 0000000..f3935bc --- /dev/null +++ b/tests/workflows/test_draft.py @@ -0,0 +1,43 @@ +"""Existing PRs request a draft transition only when their state changes.""" + +import json + +import pytest + + +@pytest.mark.parametrize( + "draft,event,mutation", + [ + (True, "merged", "markPullRequestReadyForReview"), + (False, "pr_success", "convertPullRequestToDraft"), + (True, "pr_success", None), + (False, "merged", None), + ], +) +def test_draft_transition(workflow_step, run_javascript, draft, event, mutation): + step = workflow_step("docs-pr.yml", "create-pr", step_id="docs_pr") + result = run_javascript( + step["with"]["script"], + context={"repo": {"owner": "gardenlinux", "repo": "docs"}}, + prs=[{"number": 12, "node_id": "PR_node", "draft": draft, "html_url": "url"}], + env={ + "DOCS_PAYLOAD": json.dumps( + { + "repo": "gardenlinux", + "pr_number": "123", + "commit_sha": "a" * 40, + "event": event, + } + ) + }, + ) + assert result.returncode == 0, result.stderr + calls = json.loads(result.stdout)["calls"] + updates = [call for call in calls if call["method"] == "update"] + assert len(updates) == 1 + assert "draft" not in updates[0]["args"] + transitions = [call for call in calls if call["method"] == "graphql"] + assert len(transitions) == (1 if mutation else 0) + if mutation: + assert mutation in transitions[0]["query"] + assert transitions[0]["args"]["pullRequestId"] == "PR_node" From 467692b39df9a3acba668379320a65aa55c39cf2 Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 16:48:44 +0100 Subject: [PATCH 06/12] fix(ci): report tests through a single required check Replace overlapping test and skip workflows with one always-triggered check that detects relevant changes, runs regression tests, and preserves the existing required pytest check name. Signed-off-by: Eike Waldt On-behalf-of: SAP Assisted-by: opencode:gpt-6.1-sol --- .github/workflows/tests-skip.yml | 35 ------------ .github/workflows/tests.yml | 65 ++++++++++++++++------ docs/contributing/documentation/testing.md | 22 +++++++- tests/workflows/test_changes.py | 30 ++++++++++ 4 files changed, 99 insertions(+), 53 deletions(-) delete mode 100644 .github/workflows/tests-skip.yml create mode 100644 tests/workflows/test_changes.py diff --git a/.github/workflows/tests-skip.yml b/.github/workflows/tests-skip.yml deleted file mode 100644 index 25b0879..0000000 --- a/.github/workflows/tests-skip.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Tests (skip) - -on: - push: - branches: [main] - paths-ignore: - - 'src/**' - - 'tests/**' - - 'pyproject.toml' - - 'poetry.lock' - - 'Makefile' - - '.github/workflows/tests.yml' - - '.github/workflows/tests-skip.yml' - pull_request: - branches: [main] - paths-ignore: - - 'src/**' - - 'tests/**' - - 'pyproject.toml' - - 'poetry.lock' - - 'Makefile' - - '.github/workflows/tests.yml' - - '.github/workflows/tests-skip.yml' - -permissions: - contents: read - -jobs: - pytest: - name: pytest (unit + integration) - runs-on: ubuntu-latest - steps: - - run: | - echo "No changes under src/, tests/, pyproject.toml, poetry.lock, or Makefile." - echo "Skipping test run; reporting success so a required check is satisfied." diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fdd3b4c..3907d6e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,27 +3,12 @@ name: Tests on: push: branches: [main] - paths: - - 'src/**' - - 'tests/**' - - 'pyproject.toml' - - 'poetry.lock' - - 'Makefile' - - '.github/workflows/tests.yml' - - '.github/workflows/tests-skip.yml' pull_request: branches: [main] - paths: - - 'src/**' - - 'tests/**' - - 'pyproject.toml' - - 'poetry.lock' - - 'Makefile' - - '.github/workflows/tests.yml' - - '.github/workflows/tests-skip.yml' permissions: contents: read + pull-requests: read jobs: pytest: @@ -33,15 +18,63 @@ jobs: POETRY_VIRTUALENVS_CREATE: "false" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Detect test-relevant changes + id: changes + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + let files; + if (context.eventName === 'pull_request') { + files = (await github.paginate(github.rest.pulls.listFiles, { + ...context.repo, pull_number: context.payload.pull_request.number, + per_page: 100 + })).flatMap(file => [file.filename, file.previous_filename || '']); + } else { + const before = context.payload.before; + const exists = before && !/^0+$/.test(before) + ? await exec.getExecOutput('git', ['cat-file', '-e', `${before}^{commit}`], + {silent: true, ignoreReturnCode: true}) : null; + if (!exists || exists.exitCode !== 0) { + core.setOutput('tests', 'true'); + return; + } + const diff = await exec.getExecOutput('git', + ['diff', '--name-only', '--no-renames', '-z', before, context.sha], + {silent: true}); + files = diff.stdout.split('\0'); + } + const relevant = /^(src\/|tests\/|\.github\/|pyproject\.toml$|poetry\.lock$|Makefile$)/; + core.setOutput('tests', String(files.some(file => relevant.test(file)))); - name: Set up Python + if: steps.changes.outputs.tests == 'true' uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # pin@v7.1.0 with: python-version: "3.13" - name: Install Python dependencies + if: steps.changes.outputs.tests == 'true' run: | make install-python - name: Run tests + if: steps.changes.outputs.tests == 'true' run: make test + + - name: Set up Node.js for workflow regression tests + if: steps.changes.outputs.tests == 'true' + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: '22' + + - name: Run workflow tests + if: steps.changes.outputs.tests == 'true' + run: make test-workflows + + - name: Report documentation-only success + if: steps.changes.outputs.tests == 'false' + run: echo "No test-relevant changes; skipping tests in the single required check." diff --git a/docs/contributing/documentation/testing.md b/docs/contributing/documentation/testing.md index 2b37285..aba30df 100644 --- a/docs/contributing/documentation/testing.md +++ b/docs/contributing/documentation/testing.md @@ -32,8 +32,9 @@ tests/ │ ├── test_models.py │ ├── test_structure.py │ └── test_transformer.py -└── integration/ # Integration tests (filesystem) - └── test_aggregation.py +├── integration/ # Integration tests (filesystem) +│ └── test_aggregation.py +└── workflows/ # Offline tests of workflow scripts ``` ## Running Tests @@ -56,6 +57,23 @@ make test-unit make test-integration ``` +### Workflow Tests Only + +```bash +make test-workflows +``` + +These pytest tests require Bash, Git, and Node.js. They execute scripts extracted +from workflow YAML with temporary files and mocked GitHub responses. The tests do +not contact GitHub or download NLTK corpora. Python dependencies must be installed; +the Make target uses the same installation target as the other test targets. + +The mocks do not validate GitHub API schemas, permissions, job scheduling, or +deployment compatibility. Actual workflow runs are still needed to check those. + +CI runs `make test` and `make test-workflows` as separate steps. The `make test` +target continues to run only the unit and integration suites. + ### Direct pytest For more control, use pytest directly: diff --git a/tests/workflows/test_changes.py b/tests/workflows/test_changes.py new file mode 100644 index 0000000..72e1cb5 --- /dev/null +++ b/tests/workflows/test_changes.py @@ -0,0 +1,30 @@ +"""Mixed or renamed code changes must not be reported as documentation-only.""" + +import json + +import pytest + + +@pytest.mark.parametrize( + "files,expected", + [ + ([{"filename": "docs/index.md"}], "false"), + ([{"filename": "src/aggregate.py"}, {"filename": "docs/index.md"}], "true"), + ([{"filename": "poetry.lock"}], "true"), + ([{"filename": "tests/workflows/test_changes.py"}], "true"), + ([{"filename": "docs/old-code.md", "previous_filename": "src/old.py"}], "true"), + ], +) +def test_test_selection(workflow_step, run_javascript, files, expected): + step = workflow_step("tests.yml", "pytest", step_id="changes") + result = run_javascript( + step["with"]["script"], + context={ + "eventName": "pull_request", + "repo": {"owner": "gardenlinux", "repo": "docs"}, + "payload": {"pull_request": {"number": 1}}, + }, + files=files, + ) + assert result.returncode == 0, result.stderr + assert json.loads(result.stdout)["outputs"]["tests"] == expected From 8a1fe33f64f9045db7df1f737983f5fc9c816328 Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 16:48:54 +0100 Subject: [PATCH 07/12] fix(ci): handle unchanged docs commit locks Treat an already-current lock as a successful no-op and skip branch publication, PR creation and source comments when no configuration change is required. Signed-off-by: Eike Waldt On-behalf-of: SAP Assisted-by: opencode:gpt-6.1-sol --- .github/workflows/docs-pr.yml | 10 +++++++++- tests/workflows/test_noop.py | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/workflows/test_noop.py diff --git a/.github/workflows/docs-pr.yml b/.github/workflows/docs-pr.yml index ba06945..3602f64 100644 --- a/.github/workflows/docs-pr.yml +++ b/.github/workflows/docs-pr.yml @@ -130,16 +130,24 @@ jobs: core.info(`Updated ${repoName}: ref=${ref}, commit=${commitSha}`); - name: Commit and push + id: commit env: DOCS_REPO: ${{ steps.payload.outputs.repo }} SOURCE_PR: ${{ steps.payload.outputs.pr_number }} COMMIT_SHA: ${{ steps.payload.outputs.commit_sha }} run: | git add repos-config.json + if git diff --cached --quiet; then + echo "Commit lock is already current; no branch or PR update needed." + echo "changed=false" >> "$GITHUB_OUTPUT" + exit 0 + fi git commit -m "docs($DOCS_REPO): update commit lock to $COMMIT_SHA" git push -f origin "auto/$DOCS_REPO/$SOURCE_PR" + echo "changed=true" >> "$GITHUB_OUTPUT" - name: Create or update PR + if: steps.commit.outputs.changed == 'true' id: docs_pr uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: @@ -239,7 +247,7 @@ jobs: core.setOutput('docs_pr_number', docsPrNumber); - name: Comment on source PR - if: steps.payload.outputs.pr_number != '' + if: steps.docs_pr.outputs.pr_url != '' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: DOCS_PAYLOAD: ${{ steps.payload.outputs.payload }} diff --git a/tests/workflows/test_noop.py b/tests/workflows/test_noop.py new file mode 100644 index 0000000..f747c48 --- /dev/null +++ b/tests/workflows/test_noop.py @@ -0,0 +1,23 @@ +"""An unchanged lock succeeds without publishing a commit or branch.""" + + +def test_unchanged_lock(workflow_step, run_bash, git_repo): + directory, git = git_repo + (directory / "repos-config.json").write_text('{"repos": []}\n', encoding="utf-8") + git("add", "repos-config.json") + git("commit", "-m", "initial") + output = directory / "outputs" + step = workflow_step("docs-pr.yml", "create-pr", step_id="commit") + result = run_bash( + step["run"], + cwd=directory, + env={ + "GITHUB_OUTPUT": str(output), + "DOCS_REPO": "gardenlinux", + "SOURCE_PR": "1", + "COMMIT_SHA": "a" * 40, + }, + ) + assert result.returncode == 0, result.stderr + assert output.read_text(encoding="utf-8").strip() == "changed=false" + assert git("rev-list", "--count", "HEAD") == "1" From 568b472ed756badf14a2aa378202e7dc3ff53dde Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 16:49:02 +0100 Subject: [PATCH 08/12] fix(ci): serialize docs PR updates Serialize notifications per source PR and check the live source revision before updating a lock, preventing concurrent or stale notifications from overwriting newer state. Signed-off-by: Eike Waldt On-behalf-of: SAP Assisted-by: opencode:gpt-6.1-sol --- .github/workflows/docs-pr.yml | 29 ++++++++++++++++++ tests/workflows/test_stale.py | 57 +++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 tests/workflows/test_stale.py diff --git a/.github/workflows/docs-pr.yml b/.github/workflows/docs-pr.yml index 3602f64..cf4c6de 100644 --- a/.github/workflows/docs-pr.yml +++ b/.github/workflows/docs-pr.yml @@ -3,6 +3,10 @@ name: Create/Update Docs PR permissions: contents: read +concurrency: + group: docs-pr-${{ github.event.client_payload.repo || inputs.repo }}-${{ github.event.client_payload.pr_number || inputs.pr_number }} + cancel-in-progress: false + on: repository_dispatch: types: [docs-pr] @@ -90,7 +94,30 @@ jobs: git config user.name "gardenlinux-docs-bot[bot]" git config user.email "$BOT_APP_ID+gardenlinux-docs-bot[bot]@users.noreply.github.com" + - name: Verify source PR revision + id: source + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + DOCS_PAYLOAD: ${{ steps.payload.outputs.payload }} + with: + github-token: ${{ steps.app-token.outputs.token }} + script: | + const payload = JSON.parse(process.env.DOCS_PAYLOAD); + const {data: source} = await github.rest.pulls.get({ + owner: context.repo.owner, repo: payload.repo, + pull_number: Number(payload.pr_number) + }); + const expectedEvent = source.merged ? 'merged' : 'pr_success'; + const expectedSha = source.merged ? source.merge_commit_sha : source.head.sha; + const expectedRef = source.merged ? source.base.ref : source.head.ref; + const current = (source.state !== 'closed' || source.merged) && + payload.event === expectedEvent && payload.ref === expectedRef && + payload.commit_sha.toLowerCase() === expectedSha.toLowerCase(); + core.setOutput('current', String(current)); + if (!current) core.info('Ignoring a stale or abandoned source PR notification.'); + - name: Create or update branch + if: steps.source.outputs.current == 'true' env: DOCS_REPO: ${{ steps.payload.outputs.repo }} SOURCE_PR: ${{ steps.payload.outputs.pr_number }} @@ -100,6 +127,7 @@ jobs: git checkout -B "$BRANCH" origin/main - name: Update repos-config.json + if: steps.source.outputs.current == 'true' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: DOCS_PAYLOAD: ${{ steps.payload.outputs.payload }} @@ -130,6 +158,7 @@ jobs: core.info(`Updated ${repoName}: ref=${ref}, commit=${commitSha}`); - name: Commit and push + if: steps.source.outputs.current == 'true' id: commit env: DOCS_REPO: ${{ steps.payload.outputs.repo }} diff --git a/tests/workflows/test_stale.py b/tests/workflows/test_stale.py new file mode 100644 index 0000000..29c246b --- /dev/null +++ b/tests/workflows/test_stale.py @@ -0,0 +1,57 @@ +"""Old revisions and notifications sent before a merge cannot rewrite locks.""" + +import json + +import pytest + + +@pytest.mark.parametrize( + "source,expected", + [ + ( + { + "state": "open", + "merged": False, + "head": {"sha": "a" * 40, "ref": "feature/docs"}, + }, + "true", + ), + ( + { + "state": "open", + "merged": False, + "head": {"sha": "b" * 40, "ref": "feature/docs"}, + }, + "false", + ), + ( + { + "state": "closed", + "merged": True, + "merge_commit_sha": "a" * 40, + "base": {"ref": "main"}, + }, + "false", + ), + ], +) +def test_stale_notification(workflow_step, run_javascript, source, expected): + step = workflow_step("docs-pr.yml", "create-pr", step_id="source") + result = run_javascript( + step["with"]["script"], + source=source, + context={"repo": {"owner": "gardenlinux"}}, + env={ + "DOCS_PAYLOAD": json.dumps( + { + "repo": "gardenlinux", + "pr_number": "1", + "commit_sha": "a" * 40, + "ref": "feature/docs", + "event": "pr_success", + } + ) + }, + ) + assert result.returncode == 0, result.stderr + assert json.loads(result.stdout)["outputs"]["current"] == expected From f22fec852b7ef4fca22df9efa0eba4fc824adbf3 Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 16:49:10 +0100 Subject: [PATCH 09/12] fix(ci): check all Markdown files consistently Quote the recursive Markdown glob so lychee sees root and deeply nested files, and use the same index-file resolution as the local link-check command. Signed-off-by: Eike Waldt On-behalf-of: SAP Assisted-by: opencode:gpt-6.1-sol --- .github/workflows/docs-checks.yml | 2 +- tests/workflows/test_links.py | 39 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 tests/workflows/test_links.py diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index 3aea9ed..c25ac80 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -123,7 +123,7 @@ jobs: uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # unreleased with: lycheeVersion: v0.24.2 - args: --cache --max-cache-age 1d docs/**/*.md --config lychee.toml --root-dir "$(pwd)/docs/" --max-retries 10 --retry-wait-time 10 + args: --cache --max-cache-age 1d "docs/**/*.md" --config lychee.toml --root-dir "$(pwd)/docs/" --index-files "index.md,." --max-retries 10 --retry-wait-time 10 - name: Save lychee cache if: always() diff --git a/tests/workflows/test_links.py b/tests/workflows/test_links.py new file mode 100644 index 0000000..bfa8c5c --- /dev/null +++ b/tests/workflows/test_links.py @@ -0,0 +1,39 @@ +"""Shell argument handling must include root and deeply nested Markdown files.""" + +import glob +import json +import shlex +from pathlib import Path + + +def test_link_arguments(workflow, run_bash, tmp_path): + steps = workflow("docs-checks.yml")["jobs"]["linkcheck"]["steps"] + arguments = None + for step in steps: + if step.get("uses", "").startswith("lycheeverse/lychee-action@"): + arguments = step["with"]["args"] + for line in step.get("run", "").splitlines(): + if "/lychee " in line: + arguments = line.split(" ", 1)[1] + assert arguments is not None, "No lychee invocation found" + expected = {"docs/root.md", "docs/section/page.md", "docs/section/deep/page.md"} + for name in expected: + path = tmp_path / name + path.parent.mkdir(parents=True, exist_ok=True) + path.touch() + result = run_bash("printf '%s\\n' " + arguments, cwd=tmp_path) + assert result.returncode == 0, result.stderr + argv = result.stdout.splitlines() + found = { + Path(path).relative_to(tmp_path).as_posix() + for argument in argv + if argument.endswith(".md") + for path in glob.glob(str(tmp_path / argument), recursive=True) + } + assert found == expected + root = Path(__file__).resolve().parents[2] + package = json.loads((root / "package.json").read_text(encoding="utf-8")) + local = shlex.split(package["scripts"]["docs:linkcheck"]) + ci_indexes = argv[argv.index("--index-files") + 1] + local_indexes = local[local.index("--index-files") + 1] + assert ci_indexes == local_indexes From 8803ef049a8541666089ddbc80293f3262cc08bb Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 16:49:18 +0100 Subject: [PATCH 10/12] fix(ci): refresh lychee caches between runs Save each run under a unique cache key while restoring the latest cache for the same OS, lychee version and configuration, avoiding permanently stale immutable caches. Signed-off-by: Eike Waldt On-behalf-of: SAP Assisted-by: opencode:gpt-6.1-sol --- .github/workflows/docs-checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index c25ac80..0b49a92 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -115,8 +115,8 @@ jobs: uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: .lycheecache - key: cache-lychee - restore-keys: cache-lychee- + key: cache-lychee-${{ runner.os }}-v0.24.2-${{ hashFiles('lychee.toml') }}-${{ github.run_id }}-${{ github.run_attempt }} + restore-keys: cache-lychee-${{ runner.os }}-v0.24.2-${{ hashFiles('lychee.toml') }}- # installing lychee to call it via make target is hard - name: Run link check From 3acd1a8f7b9c25f07fda51e0aa04af72a17d00a0 Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 16:49:26 +0100 Subject: [PATCH 11/12] fix(ci): pin workflow tool dependencies Pin the remaining checkout actions to immutable SHAs and install woke v0.19.0 instead of latest so workflow tooling cannot change unexpectedly between runs. Signed-off-by: Eike Waldt On-behalf-of: SAP Assisted-by: opencode:gpt-6.1-sol --- .github/workflows/aggregated-repo-docs.yml | 4 ++-- .github/workflows/docs-checks.yml | 2 +- tests/workflows/test_pins.py | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tests/workflows/test_pins.py diff --git a/.github/workflows/aggregated-repo-docs.yml b/.github/workflows/aggregated-repo-docs.yml index 9bfd91b..36935b0 100644 --- a/.github/workflows/aggregated-repo-docs.yml +++ b/.github/workflows/aggregated-repo-docs.yml @@ -48,10 +48,10 @@ jobs: # push events it uses git and needs the source repository checked out. - name: Checkout source repository if: github.event_name != 'pull_request' - uses: actions/checkout@v7.0.1 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Checkout docs registry - uses: actions/checkout@v7.0.1 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: gardenlinux/docs path: .docs diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index 0b49a92..9249749 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -193,7 +193,7 @@ jobs: - name: Install dependencies run: | make install-npm - go install github.com/get-woke/woke@latest + go install github.com/get-woke/woke@v0.19.0 - name: Run inclusive language check run: | diff --git a/tests/workflows/test_pins.py b/tests/workflows/test_pins.py new file mode 100644 index 0000000..37c8b84 --- /dev/null +++ b/tests/workflows/test_pins.py @@ -0,0 +1,19 @@ +"""Check pinning policy without freezing a particular supported release.""" + +import re + + +def test_tool_pins(workflow): + for name in ["aggregated-repo-docs.yml", "docs-checks.yml"]: + for job in workflow(name)["jobs"].values(): + for step in job.get("steps", []): + action = step.get("uses", "") + if action and not action.startswith("./"): + assert re.search(r"@[a-f0-9]{40}$", action), action + installs = "\n".join( + step.get("run", "") + for step in workflow("docs-checks.yml")["jobs"]["woke"]["steps"] + ) + version = re.search(r"github\.com/get-woke/woke@([^\s]+)", installs) + assert version is not None + assert re.fullmatch(r"v\d+\.\d+\.\d+(?:[-+][\w.-]+)?|[a-f0-9]{40}", version[1]) From e4fe80da2d72f01129d815bad113776c08e4b7da Mon Sep 17 00:00:00 2001 From: Eike Waldt Date: Wed, 2 Dec 2026 17:40:20 +0100 Subject: [PATCH 12/12] ci: temporarily disable linkcheck Signed-off-by: Eike Waldt On-behalf-of: SAP --- .github/workflows/docs-checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index 9249749..3f95ec6 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -124,6 +124,8 @@ jobs: with: lycheeVersion: v0.24.2 args: --cache --max-cache-age 1d "docs/**/*.md" --config lychee.toml --root-dir "$(pwd)/docs/" --index-files "index.md,." --max-retries 10 --retry-wait-time 10 + # until links are fixed + continue-on-error: true - name: Save lychee cache if: always()