Skip to content

fix(ci): correct compounding indentation in reusable-ci-pipeline.yml#4

Open
chitcommit wants to merge 5 commits into
mainfrom
fix/reusable-ci-pipeline-yaml-indentation
Open

fix(ci): correct compounding indentation in reusable-ci-pipeline.yml#4
chitcommit wants to merge 5 commits into
mainfrom
fix/reusable-ci-pipeline-yaml-indentation

Conversation

@chitcommit
Copy link
Copy Markdown
Member

@chitcommit chitcommit commented Apr 18, 2026

Problem

The YAML in reusable-ci-pipeline.yml has compounding indentation corruption — each nested level adds 6+ extra spaces, causing every caller repo to fail with:

error parsing called workflow ... You have an error in your yaml syntax on line 10

Fix

Rewrote the file with correct 2-space indentation. No logic changed — all inputs, secrets, and job steps are identical.

Downstream impact

All repos using uses: chittyfoundation/.github/.github/workflows/reusable-ci-pipeline.yml@main are currently broken. This unblocks them immediately on merge.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Corrected the CI workflow configuration so CI checks (detect, lint, test, security, ai-review) run reliably with intended inputs/secrets and job scope.
  • Tests
    • Added comprehensive tests validating the reusable CI workflow structure, inputs/secrets, job definitions, step presence, and language-detection behavior to prevent regressions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

Warning

Rate limit exceeded

@coderabbitai[bot] has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 minutes and 41 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c1deade-d0d6-4e46-b54e-4400dbc1e8d2

📥 Commits

Reviewing files that changed from the base of the PR and between 61c0c9e and 5710389.

⛔ Files ignored due to path filters (1)
  • tests/__pycache__/test_reusable_ci_pipeline.cpython-311.pyc is excluded by !**/*.pyc
📒 Files selected for processing (1)
  • tests/test_reusable_ci_pipeline.py
📝 Walkthrough

Walkthrough

Reformatted the GitHub Actions reusable workflow YAML to correct workflow_call nesting: inputs, secrets, and jobs are now declared at the proper top-level scope under on.workflow_call while retaining the same job definitions and conditional logic; additionally, a comprehensive pytest suite validating the workflow was added.

Changes

Cohort / File(s) Summary
Workflow Structure Fix
.github/workflows/reusable-ci-pipeline.yml
Re-indented and moved workflow_call keys so inputs, secrets, and jobs are declared at the correct scope under on.workflow_call. No job steps or logic were added/removed.
Workflow Validation Tests
tests/test_reusable_ci_pipeline.py
Added extensive pytest suite that parses and validates the workflow YAML structure, inputs, secrets, job definitions, step presence, conditionals, caching, and includes a shell-based language-detection regression check.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hopped through lines of space and light,
Found indents wrong and set them right,
I tested flows with careful cheer,
Now CI sings — the path is clear! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.93% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(ci): correct compounding indentation in reusable-ci-pipeline.yml' clearly and specifically summarizes the main change: fixing indentation issues in the reusable CI workflow file.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/reusable-ci-pipeline-yaml-indentation

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
Review rate limit: 0/1 reviews remaining, refill in 43 minutes and 41 seconds.

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/reusable-ci-pipeline.yml:
- Around line 123-128: The workflow uses secrets in step-level if conditions
(the "Snyk scan" step with if: secrets.SNYK_TOKEN != '') which actionlint
disallows; move SNYK_TOKEN into the parent job's env block (e.g., add
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} under the job-level env) and update the
step's if to reference env.SNYK_TOKEN (e.g., if: env.SNYK_TOKEN != '') so the
"Snyk scan" step (uses: snyk/actions/node@master) conditions on env.* instead of
secrets.*.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 37c1971b-160e-4b8a-b659-8143270da1da

📥 Commits

Reviewing files that changed from the base of the PR and between 8cd6fe0 and da2d504.

📒 Files selected for processing (1)
  • .github/workflows/reusable-ci-pipeline.yml

Comment on lines +123 to +128
- name: Snyk scan
if: secrets.SNYK_TOKEN != ''
uses: snyk/actions/node@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

workflow="$(fd -a '^reusable-ci-pipeline\.yml$' .github/workflows | head -n 1)"

echo "Checking for direct secrets context in if conditionals..."
rg -n '^\s*if:\s*(\$\{\{\s*)?secrets\.' "$workflow"

echo "If actionlint is installed, run the full workflow validation:"
if command -v actionlint >/dev/null 2>&1; then
  actionlint "$workflow"
fi

Repository: chittyfoundation/.github

Length of output: 1112


Move secrets to job-level env and condition on env.* instead.

actionlint validation fails because secrets context is not allowed in if: conditionals at lines 124 and 140. Move these secrets to job-level env and reference env.* in the conditions.

Proposed fix
   security:
     name: Security Scan
     needs: detect
     if: inputs.run-security
     runs-on: ubuntu-latest
+    env:
+      SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
     steps:
       - uses: actions/checkout@v4
       - name: npm audit
         if: needs.detect.outputs.language == 'node'
         working-directory: ${{ inputs.working-directory }}
         run: npm audit --audit-level=moderate || true
       - name: Snyk scan
-        if: secrets.SNYK_TOKEN != ''
+        if: env.SNYK_TOKEN != ''
         uses: snyk/actions/node@master
         continue-on-error: true
         env:
-          SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
+          SNYK_TOKEN: ${{ env.SNYK_TOKEN }}

   ai-review:
     name: AI Review
     if: inputs.run-ai-review && github.event_name == 'pull_request'
     runs-on: ubuntu-latest
     permissions:
       contents: read
       pull-requests: write
+    env:
+      ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
     steps:
       - uses: actions/checkout@v4
       - name: Claude Review
-        if: secrets.ANTHROPIC_API_KEY != ''
+        if: env.ANTHROPIC_API_KEY != ''
         uses: anthropics/claude-code-action@beta
         with:
-          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
+          anthropic_api_key: ${{ env.ANTHROPIC_API_KEY }}
           model: "claude-sonnet-4-20250514"
           timeout_minutes: 10
🧰 Tools
🪛 actionlint (1.7.12)

[error] 124-124: context "secrets" is not allowed here. available contexts are "env", "github", "inputs", "job", "matrix", "needs", "runner", "steps", "strategy", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/reusable-ci-pipeline.yml around lines 123 - 128, The
workflow uses secrets in step-level if conditions (the "Snyk scan" step with if:
secrets.SNYK_TOKEN != '') which actionlint disallows; move SNYK_TOKEN into the
parent job's env block (e.g., add SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} under
the job-level env) and update the step's if to reference env.SNYK_TOKEN (e.g.,
if: env.SNYK_TOKEN != '') so the "Snyk scan" step (uses:
snyk/actions/node@master) conditions on env.* instead of secrets.*.

@chitcommit
Copy link
Copy Markdown
Member Author

Additional finding from chittyschema audit (2026-04-30)

Confirming this PR's diagnosis from a downstream perspective and adding two items the reviewer should know before merging:

1. The dispatch failure has been silent across the entire org for 8+ months

The malformed YAML was committed in e500847 (initial commit, 2025-08-26) — meaning this reusable workflow has never successfully dispatched at any caller. Every caller's ci.yml run shows conclusion: failure, jobs: 0, "workflow file issue". CI on those repos has been passing via other workflows; the reusable's lint/test/security/ai-review jobs have been a phantom gate the whole time.

This is bigger than "callers are broken" — it's "no caller has ever actually run these jobs in production." Reviewers should expect new failures to surface on next PRs after merge.

2. run-governance input dependency — blocks merging this PR alone

Two of three known callers pass run-governance: true:

Caller Inputs passed
chittyfoundation/chittyschema node-version, run-ai-review, run-governance
chittyfoundation/chittyid node-version, run-tests, run-lint, run-ai-review, run-governance
chittyos/chittyentity python-version, run-tests, run-lint, run-ai-review

This PR fixes the YAML indentation but doesn't declare run-governance. The moment dispatch starts working, chittyschema and chittyid PRs will fail with an unknown-input error — trading one dispatch failure for another. Either declare run-governance here (as a no-op input until governance steps are wired) or remove the input from the callers in the same atomic change.

I have a draft local diff that adds run-governance as a declared no-op input — happy to push it onto this branch if helpful, or open a stacked PR after this merges.

3. Considered alternative

chittyfoundation/chittyschema recently added a standalone tests.yml (PR #32) that doesn't depend on this reusable and works fine. Deleting the reusable + having each caller use standalone workflows is genuinely simpler — but pushes governance/ai-review/security boilerplate to N callers. Centralization still has value once the file actually runs, so my vote is fix-then-merge here, not delete.

Risk callout for the reviewer

Once this merges, expect new red CI on next PRs in chittyschema, chittyid, chittyentity as long-suppressed lint / test / audit issues surface. Triage as they appear.

Doctrine: chittycanon://gov/governance#no-mocks-no-fakes — a CI job that has never dispatched is the same shape of lie as mocked test data.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

⛔ CodeRabbit does not have permission to push changes to this repository. Please ensure CodeRabbit has Contents: Read and write permission.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

✅ Unit tests committed locally. Commit: 61c0c9eacdcee481ec5f028479a2b653e528f68d

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/test_reusable_ci_pipeline.py`:
- Around line 551-565: Tests define a local DETECT_SCRIPT string and use it
instead of the workflow's actual detect step, so they can drift from
jobs.detect.steps[id=detect].run; update the remaining tests that use
DETECT_SCRIPT (including those around lines 568-586) to accept and pass a
detect_script argument and wire that argument through to the helper that
executes the detection so the tests invoke jobs.detect.steps[id=detect].run
content instead of the hardcoded DETECT_SCRIPT constant; look for references to
DETECT_SCRIPT and the test helper functions and replace calls to use the
detect_script parameter (defaulting to the workflow step content when not
provided).
- Around line 93-103: The test_all_inputs_present currently asserts
inputs.keys() equals a fixed set, which breaks callers that include optional
keys like "run-governance"; change the assertion to ensure the required keys are
a subset of inputs (e.g., assert
expected_required_keys.issubset(set(inputs.keys()))) or explicitly allow
optional keys by checking equality with a superset (e.g.,
set(inputs.keys()).issuperset(expected_required_keys)), updating the
test_all_inputs_present function to use the subset/superset check so callers
that pass "run-governance" or other optional inputs do not fail.
- Around line 659-662: The test calls subprocess.run(["bash","-c",
DETECT_SCRIPT], cwd=str(tmp_path), env=env) but doesn't assert it succeeded and
also uses the ambiguous variable name `l` in the list comprehension; update the
subprocess invocation to ensure success (e.g., pass check=True or capture the
CompletedProcess and assert result.returncode == 0) and change the comprehension
to use a clear variable name like `line` when building `lines = [line for line
in f.read().splitlines() if line.startswith("language=")]`, leaving the
subsequent assert len(lines) == 1 unchanged.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 033aec4b-00c4-4f31-96c7-c2401067a448

📥 Commits

Reviewing files that changed from the base of the PR and between da2d504 and 61c0c9e.

⛔ Files ignored due to path filters (1)
  • tests/__pycache__/test_reusable_ci_pipeline.cpython-311-pytest-9.0.3.pyc is excluded by !**/*.pyc
📒 Files selected for processing (1)
  • tests/test_reusable_ci_pipeline.py

Comment on lines +93 to +103
def test_all_inputs_present(self, inputs):
expected = {
"node-version",
"python-version",
"run-tests",
"run-lint",
"run-security",
"run-ai-review",
"working-directory",
}
assert set(inputs.keys()) == expected
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Input-schema assertions currently lock in a known caller incompatibility.

The suite enforces exactly 7 inputs, but PR context already identifies active callers passing run-governance. This test currently blesses a contract that will fail those callers once dispatch is restored.

Suggested change
     def test_all_inputs_present(self, inputs):
         expected = {
             "node-version",
             "python-version",
             "run-tests",
             "run-lint",
             "run-security",
             "run-ai-review",
+            "run-governance",
             "working-directory",
         }
         assert set(inputs.keys()) == expected
@@
     def test_inputs_count_is_seven(self, workflow):
         inputs = workflow[True]["workflow_call"]["inputs"]
-        assert len(inputs) == 7
+        assert len(inputs) == 8

Also applies to: 678-680

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_reusable_ci_pipeline.py` around lines 93 - 103, The
test_all_inputs_present currently asserts inputs.keys() equals a fixed set,
which breaks callers that include optional keys like "run-governance"; change
the assertion to ensure the required keys are a subset of inputs (e.g., assert
expected_required_keys.issubset(set(inputs.keys()))) or explicitly allow
optional keys by checking equality with a superset (e.g.,
set(inputs.keys()).issuperset(expected_required_keys)), updating the
test_all_inputs_present function to use the subset/superset check so callers
that pass "run-governance" or other optional inputs do not fail.

Comment thread tests/test_reusable_ci_pipeline.py
Comment thread tests/test_reusable_ci_pipeline.py
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings and committed to branch fix/reusable-ci-pipeline-yaml-indentation (commit: f058e429005af1593ba2d1b880f93c61ef938ea5)

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

⛔ CodeRabbit does not have permission to push changes to this repository. Please ensure CodeRabbit has Contents: Read and write permission.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

⚠️ Branch updated during autofix.

The branch was updated while autofix was in progress. Please try again.

Docstrings generation was requested by @chitcommit.

The following files were modified:

* `tests/test_reusable_ci_pipeline.py`

These file types are not supported:
* `.github/workflows/reusable-ci-pipeline.yml`
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

✅ Unit tests committed locally. Commit: f8f73f9506d4d2fa5ed99638a15bf852563bde03

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

✅ Unit tests committed locally. Commit: 57103893861ad48f6cd017a1f2e2771f7ac9587d

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.

1 participant