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
104 changes: 104 additions & 0 deletions .github/tests/check-issue-forms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env bash
# Offline fixtures for conformance/check-issue-forms.sh: the shared forms in .github, and the local
# templates or configuration that would replace them in any other repo.
set -euo pipefail
project="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
failed=0

# run_case <label> <expected-exit> <expected-output-substring-or-empty> <repo>
run_case() {
local label=$1 want=$2 needle=$3 repo=$4 out rc=0
out=$("$project/conformance/check-issue-forms.sh" --local "$tmp/fx" --repo "$repo" 2>&1) || rc=$?
if [[ "$rc" != "$want" ]] || { [[ -n "$needle" ]] && ! grep -qF -- "$needle" <<<"$out"; }; then
echo "FAIL $label: exit $rc (want $want), output: $out" >&2
failed=1
else
echo "ok $label"
fi
}
reset() { rm -rf "$tmp/fx"; mkdir -p "$tmp/fx/.github/ISSUE_TEMPLATE"; }
# form <file> <type> <label>: write a valid form
form() {
cat > "$tmp/fx/.github/ISSUE_TEMPLATE/$1" <<YML
name: Some form
description: Describe the work
type: $2
labels: [$3]
body:
- type: textarea
id: what
attributes: {label: What}
YML
}
valid_set() {
reset
form bug-report.yml Bug needs-triage
form feature-request.yml Feature needs-triage
form tracking-issue.yml Task tracking
form follow-up-action.yml Task follow-up
printf 'blank_issues_enabled: true\n' > "$tmp/fx/.github/ISSUE_TEMPLATE/config.yml"
}

valid_set
run_case "valid shared forms" 0 "ok .github" .github

valid_set; rm "$tmp/fx/.github/ISSUE_TEMPLATE/tracking-issue.yml"
run_case "missing form" 1 "tracking-issue.yml: missing form" .github

valid_set; form bug-report.yml Task needs-triage
run_case "wrong issue type" 1 "bug-report.yml: invalid form" .github

valid_set; form follow-up-action.yml Task tracking
run_case "wrong initial label" 1 "follow-up-action.yml: invalid form" .github

valid_set; printf 'name: [unclosed\n' > "$tmp/fx/.github/ISSUE_TEMPLATE/bug-report.yml"
run_case "invalid YAML" 1 "bug-report.yml: invalid YAML" .github

valid_set; printf '%s\n---\n%s\n' 'name: a' 'name: b' > "$tmp/fx/.github/ISSUE_TEMPLATE/bug-report.yml"
run_case "multi-document YAML" 1 "bug-report.yml: invalid YAML" .github

valid_set; printf 'blank_issues_enabled: false\n' > "$tmp/fx/.github/ISSUE_TEMPLATE/config.yml"
run_case "blank issues disabled" 1 "config.yml: blank issues must be enabled" .github

valid_set; rm "$tmp/fx/.github/ISSUE_TEMPLATE/config.yml"
run_case "missing config" 1 "config.yml: blank issues must be enabled" .github

reset
run_case "no local templates" 0 "ok r" r

reset; form bug.yml Bug needs-triage
run_case "local form overrides" 1 "local issue template or configuration overrides" r

reset; printf 'blank_issues_enabled: true\n' > "$tmp/fx/.github/ISSUE_TEMPLATE/config.yml"
run_case "config only overrides" 1 "ISSUE_TEMPLATE/config.yml" r

reset; printf '# bug\n' > "$tmp/fx/.github/ISSUE_TEMPLATE/bug.md"
run_case "local markdown template overrides" 1 "ISSUE_TEMPLATE/bug.md" r

reset; mkdir -p "$tmp/fx/docs"; printf '# t\n' > "$tmp/fx/docs/ISSUE_TEMPLATE.md"
run_case "docs single template overrides" 1 "docs/ISSUE_TEMPLATE.md" r

reset; mkdir -p "$tmp/fx/docs/ISSUE_TEMPLATE"; printf '# t\n' > "$tmp/fx/docs/ISSUE_TEMPLATE/a.md"
run_case "docs template directory overrides" 1 "docs/ISSUE_TEMPLATE/a.md" r

reset; printf '# t\n' > "$tmp/fx/ISSUE_TEMPLATE.md"
run_case "root single template overrides" 1 "ISSUE_TEMPLATE.md" r

reset; mkdir -p "$tmp/fx/ISSUE_TEMPLATE"; printf '# t\n' > "$tmp/fx/ISSUE_TEMPLATE/a.md"
run_case "root template directory overrides" 1 "ISSUE_TEMPLATE/a.md" r

reset; printf 'x\n' > "$tmp/fx/.github/ISSUE_TEMPLATE/notes.txt"
run_case "any file in the template folder overrides" 1 "notes.txt" r

reset; mkdir -p "$tmp/fx/.github/ISSUE_TEMPLATE/sub"; printf 'x\n' > "$tmp/fx/.github/ISSUE_TEMPLATE/sub/a.md"
run_case "nested template overrides" 1 "sub/a.md" r

reset; ln -s /nonexistent "$tmp/fx/.github/ISSUE_TEMPLATE/link.yml"
run_case "symlinked template overrides" 1 "link.yml" r

reset; mkdir -p "$tmp/fx/.github/workflows"; printf 'on: push\n' > "$tmp/fx/.github/workflows/ci.yml"
run_case "unrelated files are ignored" 0 "ok r" r

exit "$failed"
6 changes: 6 additions & 0 deletions .github/workflows/org-conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# conformance/rules.json.
# - Workflow concurrency: conformance/check-concurrency.sh on the caller's checkout, with the
# exemptions of its .github/org-conformance.json.
# - Shared issue forms: conformance/check-issue-forms.sh; only .github keeps issue templates.
# Rules and scripts are read at this workflow's own commit (job.workflow_sha), so the caller's pin
# selects them; there is no second pin to keep in sync.
name: Org conformance
Expand Down Expand Up @@ -46,3 +47,8 @@ jobs:
env:
REPO: ${{ github.event.repository.name }}
run: foundation/conformance/check-concurrency.sh --local caller --repo "$REPO"
- name: Shared issue forms
if: ${{ !cancelled() && steps.engine.outcome == 'success' }}
env:
REPO: ${{ github.event.repository.name }}
run: foundation/conformance/check-issue-forms.sh --local caller --repo "$REPO"
5 changes: 4 additions & 1 deletion .github/workflows/test-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ jobs:
# Org conformance shares this required context so adding it needs no ruleset change.
- name: Lint org conformance scripts
if: ${{ !cancelled() }}
run: shellcheck conformance/check-concurrency.sh .github/tests/check-concurrency.sh .github/tests/examples.sh
run: shellcheck conformance/check-concurrency.sh conformance/check-issue-forms.sh .github/tests/check-concurrency.sh .github/tests/check-issue-forms.sh .github/tests/examples.sh
- name: Verify workflow concurrency fixtures
if: ${{ !cancelled() }}
run: bash .github/tests/check-concurrency.sh
- name: Verify shared issue form fixtures
if: ${{ !cancelled() }}
run: bash .github/tests/check-issue-forms.sh
- name: Install actionlint
if: ${{ !cancelled() }}
run: |
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Practical notes for a workspace whose root depends on a published member:

### Org conformance

Required organization check for every repository, run on push and pull request. One job, `org-conformance`, reports two findings (both run even when the first fails):
Required organization check for every repository, run on push and pull request. One job, `org-conformance`, reports three findings (all run even when one fails):

- **Agent instructions**: `AGENTS.md`/`CLAUDE.md` adapters checked by the agent-config engine pinned in [`conformance/rules.json`](conformance/rules.json) (`agent_config`).
- **Workflow concurrency**: [`conformance/check-concurrency.sh`](conformance/check-concurrency.sh) on the caller's checkout. Every workflow triggered by `push` or `pull_request` declares workflow-level `concurrency` in one of three forms, where `<stem>` is the workflow file name without `.yml`/`.yaml`:
Expand All @@ -217,6 +217,7 @@ Required organization check for every repository, run on push and pull request.
The CI group uses the PR number for every pull request event, including `closed`, and the full ref for pushes. Org conformance also accepts `<stem>-${{ github.head_ref || github.ref }}` during the rollout. Update the checker pin before switching existing caller workflows to the new group.

A workflow triggered only by `workflow_call` must not declare workflow-level concurrency: its callers do.
- **Shared issue forms**: [`conformance/check-issue-forms.sh`](conformance/check-issue-forms.sh) on the caller's checkout. GitHub replaces the whole organization default folder when a repository has a valid local template or `config.yml` in `.github/ISSUE_TEMPLATE`, so any repository other than `.github` fails on a file there, in `ISSUE_TEMPLATE/` or `docs/ISSUE_TEMPLATE/`, or on `ISSUE_TEMPLATE.md` (root, `docs/` or `.github/`). The `.github` repository must instead keep `bug-report.yml` (type `Bug`, label `needs-triage`), `feature-request.yml` (`Feature`, `needs-triage`), `tracking-issue.yml` (`Task`, `tracking`), `follow-up-action.yml` (`Task`, `follow-up`) as valid single-document YAML forms, and a `config.yml` with `blank_issues_enabled: true`.

Rules and scripts are read at the reusable workflow's own commit (`job.workflow_sha`): the caller's pin selects them. Add `.github/workflows/org-conformance.yml` to the caller, pinned to the same github-workflows commit as its other calls (`release/check-workflow-pins.py` requires one commit in release-tag callers):

Expand Down
41 changes: 41 additions & 0 deletions conformance/check-issue-forms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Check the community forms or detect local templates that override them.
set -euo pipefail
[[ ${1:-} == --local && -d ${2:-} && ${3:-} == --repo && -n ${4:-} && $# == 4 ]] || { echo 'usage: check-issue-forms.sh --local <dir> --repo <name>' >&2; exit 2; }
root=$2 repo=$4
command -v jq >/dev/null || { echo 'FAIL: jq is required' >&2; exit 2; }
yq --version 2>/dev/null | grep -q mikefarah || { echo 'FAIL: yq (mikefarah) is required' >&2; exit 2; }
errors=0
if [[ "$repo" == .github ]]; then
while IFS='|' read -r file type label; do
path="$root/.github/ISSUE_TEMPLATE/$file"
if [[ ! -f "$path" ]]; then echo "FAIL $file: missing form"; errors=1; continue; fi
if ! data=$(yq -o=json -I=0 '.' "$path" | jq -s 'if length == 1 then .[0] else error("expected one document") end'); then
echo "FAIL $file: invalid YAML"; errors=1; continue
fi
if ! jq -e --arg type "$type" --arg label "$label" '
(.name | type == "string" and length > 3) and
(.description | type == "string" and length > 0) and
(.body | type == "array" and length > 0 and any(.[]; .type == "textarea" or .type == "input" or .type == "dropdown" or .type == "checkboxes")) and
.type == $type and .labels == [$label]
' <<<"$data" >/dev/null; then echo "FAIL $file: invalid form structure, type or initial labels (expected $type / $label)"; errors=1; fi
done <<'FORMS'
bug-report.yml|Bug|needs-triage
feature-request.yml|Feature|needs-triage
tracking-issue.yml|Task|tracking
follow-up-action.yml|Task|follow-up
FORMS
path="$root/.github/ISSUE_TEMPLATE/config.yml"
if [[ ! -f "$path" ]] || ! yq -o=json -I=0 '.' "$path" | jq -se 'length == 1 and .[0].blank_issues_enabled == true' >/dev/null; then
echo 'FAIL config.yml: blank issues must be enabled'; errors=1
fi
else
found=$(cd -- "$root" && find . -maxdepth 4 \( -type f -o -type l \) \( -ipath './.github/ISSUE_TEMPLATE/*' -o -ipath './ISSUE_TEMPLATE/*.md' -o -ipath './docs/ISSUE_TEMPLATE/*.md' -o -ipath './ISSUE_TEMPLATE.md' -o -ipath './.github/ISSUE_TEMPLATE.md' -o -ipath './docs/ISSUE_TEMPLATE.md' \) -print) || { echo 'FAIL: cannot scan the checkout for local issue templates' >&2; exit 2; }
while IFS= read -r path; do
[[ -n "$path" ]] || continue
echo "FAIL ${path#./}: local issue template or configuration overrides shared forms"
errors=1
done <<<"$found"
fi
if (( errors )); then exit 1; fi
echo "ok $repo: issue forms"