From 3ab239ad493407ea8a2d7f0c5edb4072e93faf37 Mon Sep 17 00:00:00 2001 From: panicboat Date: Sun, 25 Oct 2026 11:55:04 +0900 Subject: [PATCH 1/2] refactor: mark the workflows triggered by this repository's own events as self Signed-off-by: panicboat --- ...atekeeper.yaml => self--ci-gatekeeper.yaml} | 2 +- ...int-actions.yml => self--lint-actions.yaml} | 2 +- ...-please.yaml => self--release--please.yaml} | 2 +- ...st.yml => self--semantic-pull-request.yaml} | 2 +- ...st-scripts.yaml => self--test-scripts.yaml} | 0 ...self--test-shared-workflows--checkout.yaml} | 2 +- ...> self--test-shared-workflows--nested.yaml} | 4 ++-- ...s.yaml => self--test-shared-workflows.yaml} | 4 ++-- README.md | 1 + scripts/workflows/test.sh | 18 ++++++++++++++++-- 10 files changed, 26 insertions(+), 11 deletions(-) rename .github/workflows/{ci-gatekeeper.yaml => self--ci-gatekeeper.yaml} (91%) rename .github/workflows/{lint-actions.yml => self--lint-actions.yaml} (86%) rename .github/workflows/{release--please.yaml => self--release--please.yaml} (93%) rename .github/workflows/{semantic-pull-request.yml => self--semantic-pull-request.yaml} (91%) rename .github/workflows/{test-scripts.yaml => self--test-scripts.yaml} (100%) rename .github/workflows/{test-shared-workflows--checkout.yaml => self--test-shared-workflows--checkout.yaml} (96%) rename .github/workflows/{test-shared-workflows--nested.yaml => self--test-shared-workflows--nested.yaml} (52%) rename .github/workflows/{test-shared-workflows.yaml => self--test-shared-workflows.yaml} (65%) diff --git a/.github/workflows/ci-gatekeeper.yaml b/.github/workflows/self--ci-gatekeeper.yaml similarity index 91% rename from .github/workflows/ci-gatekeeper.yaml rename to .github/workflows/self--ci-gatekeeper.yaml index da7d066..eef0eea 100644 --- a/.github/workflows/ci-gatekeeper.yaml +++ b/.github/workflows/self--ci-gatekeeper.yaml @@ -1,5 +1,5 @@ # Waits for every other workflow on a pull request so that one required check gates the merge. -name: 'CI Gatekeeper' +name: 'Self - CI Gatekeeper' on: pull_request: diff --git a/.github/workflows/lint-actions.yml b/.github/workflows/self--lint-actions.yaml similarity index 86% rename from .github/workflows/lint-actions.yml rename to .github/workflows/self--lint-actions.yaml index e41c2ca..ac9109a 100644 --- a/.github/workflows/lint-actions.yml +++ b/.github/workflows/self--lint-actions.yaml @@ -1,5 +1,5 @@ # Checks that every action is pinned to a full commit SHA. -name: Lint GitHub Actions +name: 'Self - Lint GitHub Actions' on: push: diff --git a/.github/workflows/release--please.yaml b/.github/workflows/self--release--please.yaml similarity index 93% rename from .github/workflows/release--please.yaml rename to .github/workflows/self--release--please.yaml index e2f4fbb..d4bea53 100644 --- a/.github/workflows/release--please.yaml +++ b/.github/workflows/self--release--please.yaml @@ -1,5 +1,5 @@ # Runs release-please for this repository to open release pull requests and publish releases. -name: 'Release - Please' +name: 'Self - Release - Please' on: push: diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/self--semantic-pull-request.yaml similarity index 91% rename from .github/workflows/semantic-pull-request.yml rename to .github/workflows/self--semantic-pull-request.yaml index 8d1ba09..6de15a2 100644 --- a/.github/workflows/semantic-pull-request.yml +++ b/.github/workflows/self--semantic-pull-request.yaml @@ -1,5 +1,5 @@ # Validates that the pull request title follows Conventional Commits. -name: Semantic Pull Request +name: 'Self - Semantic Pull Request' on: pull_request_target: diff --git a/.github/workflows/test-scripts.yaml b/.github/workflows/self--test-scripts.yaml similarity index 100% rename from .github/workflows/test-scripts.yaml rename to .github/workflows/self--test-scripts.yaml diff --git a/.github/workflows/test-shared-workflows--checkout.yaml b/.github/workflows/self--test-shared-workflows--checkout.yaml similarity index 96% rename from .github/workflows/test-shared-workflows--checkout.yaml rename to .github/workflows/self--test-shared-workflows--checkout.yaml index 55aa3f6..ab572be 100644 --- a/.github/workflows/test-shared-workflows--checkout.yaml +++ b/.github/workflows/self--test-shared-workflows--checkout.yaml @@ -1,5 +1,5 @@ # Checks that the self checkout resolves to the running workflow commit and that its scripts run. -name: 'Test Shared Workflows - Checkout' +name: 'Self - Test Shared Workflows - Checkout' on: workflow_call: diff --git a/.github/workflows/test-shared-workflows--nested.yaml b/.github/workflows/self--test-shared-workflows--nested.yaml similarity index 52% rename from .github/workflows/test-shared-workflows--nested.yaml rename to .github/workflows/self--test-shared-workflows--nested.yaml index 711d47d..b18aeb4 100644 --- a/.github/workflows/test-shared-workflows--nested.yaml +++ b/.github/workflows/self--test-shared-workflows--nested.yaml @@ -1,9 +1,9 @@ # Calls the self checkout test through `$/` the way the shared workflows call each other. -name: 'Test Shared Workflows - Nested' +name: 'Self - Test Shared Workflows - Nested' on: workflow_call: jobs: checkout: - uses: $/.github/workflows/test-shared-workflows--checkout.yaml + uses: $/.github/workflows/self--test-shared-workflows--checkout.yaml diff --git a/.github/workflows/test-shared-workflows.yaml b/.github/workflows/self--test-shared-workflows.yaml similarity index 65% rename from .github/workflows/test-shared-workflows.yaml rename to .github/workflows/self--test-shared-workflows.yaml index f346dd9..3663cfe 100644 --- a/.github/workflows/test-shared-workflows.yaml +++ b/.github/workflows/self--test-shared-workflows.yaml @@ -1,5 +1,5 @@ # Exercises the nested reusable workflow call and the self checkout that the shared workflows rely on. -name: Test Shared Workflows +name: 'Self - Test Shared Workflows' on: push: @@ -10,4 +10,4 @@ jobs: test: permissions: contents: read - uses: ./.github/workflows/test-shared-workflows--nested.yaml + uses: ./.github/workflows/self--test-shared-workflows--nested.yaml diff --git a/README.md b/README.md index 5dea5e2..3234baa 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ panicboat アカウントのリポジトリで共有する GitHub の設定を 呼び出し側は `uses: panicboat/.github/.github/workflows/@ # vX.Y.Z` と書いて、release の commit SHA に固定する。 固定した SHA は Renovate が更新する。 `.github/workflows/internal--*.yaml` は、共通の workflow の中からだけ呼ぶ workflow で、他のリポジトリからは呼ばない。 +`.github/workflows/self--*.yaml` は、このリポジトリ自身のイベントで動く workflow で、他のリポジトリからは呼ばない。 ```yaml jobs: diff --git a/scripts/workflows/test.sh b/scripts/workflows/test.sh index 5473209..591d5fa 100755 --- a/scripts/workflows/test.sh +++ b/scripts/workflows/test.sh @@ -42,8 +42,8 @@ test_kustomize_builder_checks_out_head_ref_only_for_helmfile() { } test_nested_test_workflow_uses_dollar_slash() { - local workflow="${workflows_dir}/test-shared-workflows--nested.yaml" - assert_eq '$/.github/workflows/test-shared-workflows--checkout.yaml' "$(yq '.jobs[].uses' "${workflow}")" + local workflow="${workflows_dir}/self--test-shared-workflows--nested.yaml" + assert_eq '$/.github/workflows/self--test-shared-workflows--checkout.yaml' "$(yq '.jobs[].uses' "${workflow}")" } test_nested_calls_resolve_to_existing_workflows() { @@ -53,6 +53,20 @@ test_nested_calls_resolve_to_existing_workflows() { done } +test_workflows_carry_matching_file_and_name_prefix() { + local workflow file prefix + for workflow in "${workflows_dir}"/*; do + file="$(basename "${workflow}")" + case "${file}" in + reusable--*.yaml) prefix='Reusable - ' ;; + internal--*.yaml) prefix='Internal - ' ;; + self--*.yaml) prefix='Self - ' ;; + *) echo " unknown prefix: ${file}" >&2; exit 1 ;; + esac + [[ "$(yq '.name' "${workflow}")" == "${prefix}"* ]] || { echo " name mismatch: ${file}" >&2; exit 1; } + done +} + failed=0 for test_name in $(compgen -A function test_); do set +e From d043fd13a0badde360539ace165eb9e0b3a48c59 Mon Sep 17 00:00:00 2001 From: panicboat Date: Sun, 25 Oct 2026 11:55:34 +0900 Subject: [PATCH 2/2] refactor: prefix the test scripts workflow name with Self Signed-off-by: panicboat --- .github/workflows/self--test-scripts.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/self--test-scripts.yaml b/.github/workflows/self--test-scripts.yaml index 2145863..25f8514 100644 --- a/.github/workflows/self--test-scripts.yaml +++ b/.github/workflows/self--test-scripts.yaml @@ -1,4 +1,4 @@ -name: Test Scripts +name: 'Self - Test Scripts' on: push: