Skip to content

fix: wire workflow template validation - #839

Merged
keito4 merged 2 commits into
mainfrom
fix/workflow-template-validation-followup
Jun 17, 2026
Merged

keito4 merged 2 commits into
mainfrom
fix/workflow-template-validation-followup

Conversation

@keito4

@keito4 keito4 commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix Claude Code issue_comment handling so draft PR comments are skipped by fetching the PR draft state via the Pulls API.
  • Make CI path filtering connect workflow/template/label YAML changes to lint, unit tests, integration tests, and workflow lint.
  • Extend actionlint coverage to workflow templates and fix the existing terraform drift template issues that blocked full template linting.
  • Add regression coverage for draft PR issue comments and template/label workflow validation triggers.

Verification

  • actionlint
  • actionlint .github/workflows/.yml .github/workflows/templates/.yml templates/workflows/*.yml
  • npm run format:check
  • npm run lint
  • npm test
  • npm run shellcheck
  • npx bats test/integration/workflows.bats
  • npx bats test/integration/
  • bash script/update-agents-md.sh --check
  • git diff --check
  • npm audit --audit-level=high

Notes

PR #838 was merged before these follow-up fixes could be included. This PR contains only the additional fixes found during review.

Summary by CodeRabbit

  • Bug Fixes

    • Improved draft pull request handling in AI-assisted code review workflows by adding explicit draft state detection.
  • Chores

    • Enhanced CI workflow to detect additional configuration file changes and trigger appropriate validation jobs.
    • Refined environment selection logic for infrastructure drift detection with manual input options.
  • Tests

    • Added validation tests for workflow draft PR handling and CI configuration change detection.

@claude

claude Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Claude finished @keito4's task in 0s —— View job


I'll analyze this and get back to you.

@keito4 keito4 self-assigned this Jun 17, 2026

@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: 524f56f387

ℹ️ 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/ci.yml Outdated
Comment on lines +206 to +209
actionlint_flags: >-
.github/workflows/*.yml
.github/workflows/templates/*.yml
templates/workflows/*.yml

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include .yaml workflows in actionlint flags

The path filters at the top of this workflow still trigger CI for **.yaml and .github/workflows/**, but this new explicit file list only passes *.yml globs to actionlint (the pinned reviewdog entrypoint runs actionlint -oneline ${INPUT_ACTIONLINT_FLAGS}). When someone adds or changes a valid GitHub Actions .yaml workflow/template, the Workflow Lint job runs but never checks that file, so syntax or expression errors in the changed workflow can merge. Include the .yaml globs or generate the file list from both extensions.

Useful? React with 👍 / 👎.

@keito4

keito4 commented Jun 17, 2026

Copy link
Copy Markdown
Owner Author

Addressed in 5284d48: actionlint now uses .yml for .github/workflows, .github/workflows/templates, and templates/workflows so both .yml and .yaml files are covered. Local actionlint and CI Workflow Lint passed after the change.

@keito4
keito4 merged commit 00f0fe9 into main Jun 17, 2026
15 checks passed
@keito4
keito4 deleted the fix/workflow-template-validation-followup branch June 17, 2026 09:42
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6d8a7e92-b643-42e2-907e-5355174e25fe

📥 Commits

Reviewing files that changed from the base of the PR and between 1c8519b and 5284d48.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • .github/workflows/claude.yml
  • templates/workflows/claude.yml
  • templates/workflows/terraform-drift.yml
  • test/claude-workflow-contract.test.js
  • test/integration/workflows.bats

📝 Walkthrough

Walkthrough

Three independent workflow changes: Claude workflows (live and template) replace inline draft-PR job-condition filtering with explicit step-based detection using github.rest.pulls.get; CI workflow expands paths-filter and job trigger conditions to include template workflow files and extends actionlint flags; Terraform drift workflow replaces empty-string environment defaulting with an explicit all option and step-level eligibility gates.

Changes

Claude Workflow Draft PR Detection

Layer / File(s) Summary
Draft-PR step gating in live and template Claude workflows
.github/workflows/claude.yml, templates/workflows/claude.yml
Job-level if conditions drop the inline draft-PR exclusion. New github.rest.pulls.get steps emit is_draft output; a skip step and if: guards on Checkout repository and Run Claude Code enforce draft-PR filtering at step level in both files.
Contract test for draft PR skip behavior
test/claude-workflow-contract.test.js
New test.each contract test asserts both claude workflow files implement draft detection via github.rest.pulls.get, set is_draft output, and conditionally skip draft PR issue comments.

CI Workflow Paths-Filter and Actionlint Expansion

Layer / File(s) Summary
CI paths-filter, job conditions, and actionlint flags
.github/workflows/ci.yml, test/integration/workflows.bats
Paths-filter gains .github/labels.yml, templates/workflows/**, and templates/github/labels.yml. Three downstream job if: conditions add workflows == 'true'. The actionlint step gains actionlint_flags targeting template workflow globs. Integration test gains corresponding grep assertions.

Terraform Drift Step-Based Environment Selection

Layer / File(s) Summary
Select environment step and per-step run gates
templates/workflows/terraform-drift.yml
workflow_dispatch input environment defaults to all with an explicit choice. Old job-level if: removed. New Select environment step writes run=true/false; Checkout, Terraform setup, init, plan, and Slack error notification all gate on steps.selected.outputs.run == 'true'.

Sequence Diagram(s)

sequenceDiagram
  participant Webhook as issue_comment event
  participant Job as claude job (if: `@claude` mentioned)
  participant Script as Check PR draft state
  participant GH as github.rest.pulls.get
  participant Skip as Skip draft PR
  participant Checkout as Checkout repository
  participant Runner as Run Claude Code

  Webhook->>Job: trigger on `@claude` mention
  Job->>Script: execute github-script
  Script->>GH: pulls.get(pull_number)
  GH-->>Script: isDraft boolean
  Script-->>Job: outputs.is_draft = 'true'/'false'
  alt is_draft == 'true'
    Job->>Skip: log and exit
  else is_draft != 'true'
    Job->>Checkout: run checkout
    Checkout->>Runner: run Claude Code action
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • keito4/config#16: This PR extends the Claude workflow introduced in #16 by replacing the inline draft-PR if: guard with explicit step-based draft detection.
  • keito4/config#267: Both PRs modify .github/workflows/ci.yml's changes paths-filter outputs and downstream job if:/actionlint gating to run when workflow-related files change.
  • keito4/config#564: Both PRs modify Claude workflow logic to handle draft PRs, with this PR adding the explicit github.rest.pulls.get step-based approach.

Suggested labels

released

🐇 A bunny hops through the CI gate,
Draft PRs now checked before it's too late.
is_draft outputs with a gentle true,
Templates and workflows all tested anew.
Terraform picks all with a clear little bow —
Every step gated, a tidy new flow! 🌿

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/workflow-template-validation-followup

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

test/claude-workflow-contract.test.js

Oops! Something went wrong! :(

ESLint: 10.5.0

ReferenceError: describe is not defined
at Object. (/test/eslint-config.test.js:4:1)
at Module._compile (node:internal/modules/cjs/loader:1830:14)
at Object..js (node:internal/modules/cjs/loader:1961:10)
at Module.load (node:internal/modules/cjs/loader:1553:32)
at Module._load (node:internal/modules/cjs/loader:1355:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
at loadCJSModuleWithModuleLoad (node:internal/modules/esm/translators:326:3)
at ModuleWrap. (node:internal/modules/esm/translators:231:7)
at ModuleJob.run (node:internal/modules/esm/module_job:437:25)
at async node:internal/modules/esm/loader:639:26


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.117.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released リリース済み label Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant