Skip to content

refactor(adr-lint): move the step scripts into files checked out at the workflow's own commit - #40

Merged
furedea merged 3 commits into
mainfrom
refactor/move-adr-lint-step-scripts-into-files
Dec 2, 2026
Merged

furedea merged 3 commits into
mainfrom
refactor/move-adr-lint-step-scripts-into-files

Conversation

@furedea

@furedea furedea commented Dec 2, 2026

Copy link
Copy Markdown
Owner

概要

adr-lint.yml の長いインライン Bash("Validate adr-dir","Check MADR headings","Check ADR files")を scripts/adr-lint/ のスクリプトに移し,bats テストがそれらを awk による抽出なしで直接実行するようにしました.呼び出し側から見た挙動(入力,チェック内容,エラーメッセージ,失敗の順序)は変わりません.

furedea/agent-config#293 の一部です.release PR #38(2.0.0)より先に merge する必要があります.

背景

reusable workflow は自分の ref を知れないと考えられていましたが,job コンテキストの job.workflow_repository と job.workflow_sha が,呼び出されたワークフロー自身のリポジトリとコミットを指します.これにより,自己 pin した SHA なしで,ワークフローと同じコミットのスクリプトを checkout できます.

変更内容

  • scripts/adr-lint/{validate_adr_dir,check_madr_headings,check_adr_files}.sh を追加(既存ステップの Bash を移したもの).
  • adr-lint.yml:呼び出し側 repository を checkout した後,スクリプトを .adr-lint-scripts に sparse checkout し,adr-dir 検証をその直後(ADR_DIR を使う他のステップより前)に実行.各ステップは 1 行.
  • tests/adr-lint/check_files.bats:スクリプトを直接実行(既存 19 ケースの期待値は同じ).check_madr_headings.bats を追加(偽の nix で madr-from の選別と skip を検証).
  • ci.yml:shell-lint ジョブ(shellcheck と shfmt)を追加し,all-green の needs に追加.
  • .github/actionlint.yaml:actionlint 1.7.12 は文書化されている job.workflow_repository と job.workflow_sha を未定義と報告するため(fix: add documented job workflow context properties rhysd/actionlint#707,#757),adr-lint.yml に限りそのエラーだけを ignore.actionlint が対応したら削除する.
  • README の adr-lint.yml の節を更新.

確認

  • ローカル:actionlint,shellcheck,shfmt,ls-lint,bats 21 件が通過.
  • hosted runner で job.workflow_* に値が入るかは,この PR の CI(adr-lint,adr-lint-madr-from)で確認する.

🤖 Generated with Claude Code

…he workflow's own commit

The steps Validate adr-dir, Check MADR headings and Check ADR files now live in
scripts/adr-lint, which the workflow checks out from job.workflow_repository at
job.workflow_sha. The bats tests run the scripts directly. actionlint 1.7.12 does not
know these job properties yet, so .github/actionlint.yaml ignores that error. A
shell-lint job runs shellcheck and shfmt on the scripts.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings December 2, 2026 12:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T12:20:21.537025Z b60c4fa Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@furedea

furedea commented Dec 2, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Comment thread .github/workflows/ci.yml Resolved
Comment thread README.md Resolved
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Review summary

The refactor is faithful. The script bodies match the old inline steps, and the bats tests now run the scripts directly instead of extracting them with awk. I found no correctness or security problems in the scripts themselves.

P1

  • ci.yml: shfmt --diff runs with no flags and the repo has no .editorconfig. The new scripts use 2-space indentation and indented case branches, so with shfmt's defaults (tabs, unindented case branches) shell-lint will likely fail and block all-green. Pass -i 2 -ci or add an .editorconfig. I couldn't run shfmt here, so this is unconfirmed.

P3

  • README.md: "before any other step runs" is no longer accurate, because Validate adr-dir now runs after both checkouts. Also, the scripts checkout uses the default GITHUB_TOKEN against job.workflow_repository, so it would break for cross-repo callers if this repo were ever made private.

Not verified

  • Whether job.workflow_repository and job.workflow_sha are populated on hosted runners. The PR description says this is to be confirmed by the adr-lint and adr-lint-madr-from CI jobs. Please check that those jobs pass before merging.

Review was read-only. I made no edits.

… order

shfmt in CI had no .editorconfig, so its defaults (tabs, unindented case branches) differed
from the scripts. The README now says that adr-dir is validated before any step that uses
it, after the two checkouts, and that this repository must stay public.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 828717f19d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/adr-lint.yml Resolved
…heckout

actions/checkout follows an existing symlink at its destination, so a caller repository
holding .adr-lint-scripts as a symlink could redirect the checkout. The step removes the
path itself (not its target) first.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Dec 2, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Review summary: no findings.

I read the diff for correctness, security and test coverage and found nothing that should block the merge.

  • Script move: the extracted scripts match the old inline Bash. set -euo pipefail and the ${BASE_SHA:-} default keep the old behaviour under bash -e. Renaming name to _name inside adr_number_of only stops it clobbering the global.
  • Security: the scripts come from the called workflow's own commit, so that checkout is trusted code. The rm -rf -- "$SCRIPTS_CHECKOUT" step removes a symlink itself rather than following it, so a caller repo can't redirect the second checkout.
  • Tests: the bats suites now run the real scripts. The new check_madr_headings.bats covers the madr-from selection and the skip path.

Two unverified points, neither a finding:

  • I couldn't check that job.workflow_repository and job.workflow_sha hold usable values on a hosted runner, including for the same-repo uses: ./... call from ci.yml on a PR. The PR text says the adr-lint and adr-lint-madr-from CI jobs will confirm this, so wait for those to pass.
  • The adr-dir validation now runs after both checkouts instead of before any step. This is a minor ordering change, and the README documents it.

check_madr_headings.sh leaves its mktemp directory behind. That is harmless on an ephemeral runner.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: b60c4faf14

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea
furedea merged commit 3a2bf67 into main Dec 2, 2026
19 checks passed
@furedea
furedea deleted the refactor/move-adr-lint-step-scripts-into-files branch December 2, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants