Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Scripts
name: 'Self - Test Scripts'

on:
push:
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ panicboat アカウントのリポジトリで共有する GitHub の設定を
呼び出し側は `uses: panicboat/.github/.github/workflows/<file>@<sha> # vX.Y.Z` と書いて、release の commit SHA に固定する。
固定した SHA は Renovate が更新する。
`.github/workflows/internal--*.yaml` は、共通の workflow の中からだけ呼ぶ workflow で、他のリポジトリからは呼ばない。
`.github/workflows/self--*.yaml` は、このリポジトリ自身のイベントで動く workflow で、他のリポジトリからは呼ばない。

```yaml
jobs:
Expand Down
18 changes: 16 additions & 2 deletions scripts/workflows/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
Loading