From 1fc6f332f3f437727d8aed8b357fbc72d23bae16 Mon Sep 17 00:00:00 2001 From: showxu <10173746+showxu@users.noreply.github.com> Date: Sat, 24 Oct 2026 15:40:34 +0800 Subject: [PATCH 1/2] ci: run each check once per pull-request push CI and source policy ran on pushes to every branch as well as on pull requests, so each pull-request push ran both workflows twice, and CI's own policy job ran the policy a third and fourth time. CI also reran every job when a pull request's title or description was edited. Both workflows now run on pushes to master and on pull requests. Only source policy reruns on edits, because it checks the title, and it is the one source of the required policy / policy check. The README's caller example follows the same split. --- .github/workflows/ci.yml | 16 +++------------- .github/workflows/source-policy.yml | 3 ++- README.md | 26 ++++++++++++++++++++++---- tests/test_ci.py | 2 +- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7ba292..6884e5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,9 @@ name: CI on: push: + branches: [master] pull_request: - types: [opened, edited, synchronize, reopened] + types: [opened, synchronize, reopened] workflow_dispatch: permissions: {} jobs: @@ -26,17 +27,6 @@ jobs: contents: read actions: read uses: ./.github/workflows/swift-package.yml - policy: - permissions: - contents: read - uses: ./.github/workflows/policy.yml - with: - allow-terms: | - ChatGPT - Codex - Cursor - Claude - dependabot-exception: true fixtures: runs-on: ${{ matrix.runner }} permissions: @@ -99,7 +89,7 @@ jobs: echo "$GITHUB_WORKSPACE/.build/venv/bin" >> "$GITHUB_PATH" - run: python3 scripts/test-fixtures.py demo --toolchain .build/presentation-source/skills/github-readme-design/scripts result: - needs: [checks, validate, policy, fixtures, demo-fixture] + needs: [checks, validate, fixtures, demo-fixture] if: always() runs-on: ubuntu-24.04 permissions: diff --git a/.github/workflows/source-policy.yml b/.github/workflows/source-policy.yml index 19a3189..e5cf572 100644 --- a/.github/workflows/source-policy.yml +++ b/.github/workflows/source-policy.yml @@ -1,6 +1,7 @@ name: Source policy on: - push: {} + push: + branches: [master] pull_request: types: [opened, edited, synchronize, reopened] workflow_dispatch: {} diff --git a/README.md b/README.md index 73fd4bc..4c30f1a 100644 --- a/README.md +++ b/README.md @@ -73,23 +73,40 @@ publishes them. ## Calling validation and policy +Callers run validation once for each pull-request push and once for each push +to the default branch. Source policy runs on the same events and also when a +pull request is edited, because it checks the title: + ```yaml name: CI on: push: + branches: [master] pull_request: - types: [opened, edited, synchronize, reopened] + types: [opened, synchronize, reopened] permissions: contents: read actions: read +jobs: + validate: + uses: swift-library/github-workflows/.github/workflows/swift-package.yml@ # vX.Y.Z +``` + +```yaml +name: Source policy +on: + push: + branches: [master] + pull_request: + types: [opened, edited, synchronize, reopened] +permissions: + contents: read jobs: policy: uses: swift-library/github-workflows/.github/workflows/policy.yml@ # vX.Y.Z with: allow-terms: '' dependabot-exception: false - validate: - uses: swift-library/github-workflows/.github/workflows/swift-package.yml@ # vX.Y.Z ``` `allow-terms` is a newline-separated, case-insensitive product-name allowlist. @@ -245,7 +262,8 @@ changed-step diagnostic and recording diff. Build and toolchain errors fail the harness. Regenerate the passing recording with the same toolchain's `node /src/cli.ts terminal record --script --executable --out `. -CI calls the validation and policy workflows with passing fixture packages. +CI calls the validation workflow with passing fixture packages, and the source +policy workflow calls the policy workflow for this repository's own changes. The root configuration targets `fixtures/passing` and declares every validation job type. The scripts exercise each job's rejection path against failing fixtures on its matching runner. A failing reusable-workflow call cannot be an diff --git a/tests/test_ci.py b/tests/test_ci.py index feb76d8..00a2dff 100644 --- a/tests/test_ci.py +++ b/tests/test_ci.py @@ -12,7 +12,7 @@ class CIResultTests(unittest.TestCase): def test_all_dependencies_must_succeed(self): needs = {name: {'result': 'success'} - for name in ('checks', 'validate', 'policy', 'fixtures', 'demo-fixture')} + for name in ('checks', 'validate', 'fixtures', 'demo-fixture')} ci.check(needs) for name in needs: for result in ('failure', 'cancelled', 'skipped'): From c70a626f961481d9cdbb0283e12432afc6573dda Mon Sep 17 00:00:00 2001 From: showxu <10173746+showxu@users.noreply.github.com> Date: Sat, 24 Oct 2026 15:47:04 +0800 Subject: [PATCH 2/2] docs: run validation callers on manual dispatch The caller example includes workflow_dispatch, as the organization's validation callers do. --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4c30f1a..ce3a4fc 100644 --- a/README.md +++ b/README.md @@ -73,9 +73,10 @@ publishes them. ## Calling validation and policy -Callers run validation once for each pull-request push and once for each push -to the default branch. Source policy runs on the same events and also when a -pull request is edited, because it checks the title: +Callers run validation once for each pull-request push, once for each push to +the default branch and on manual dispatch. Source policy runs on pull requests +and default-branch pushes, and also when a pull request is edited, because it +checks the title: ```yaml name: CI @@ -84,6 +85,7 @@ on: branches: [master] pull_request: types: [opened, synchronize, reopened] + workflow_dispatch: permissions: contents: read actions: read