Skip to content

feat: implement issue #360 — [Fleet Monitor] petry-projects/ContentTwin — .github/workflows/ci.yml - #362

Merged
don-petry merged 5 commits into
mainfrom
dev-lead/issue-360-20260718-0821
Jul 18, 2026
Merged

feat: implement issue #360 — [Fleet Monitor] petry-projects/ContentTwin — .github/workflows/ci.yml#362
don-petry merged 5 commits into
mainfrom
dev-lead/issue-360-20260718-0821

Conversation

@don-petry

@don-petry don-petry commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Closes #360

Implemented by dev-lead agent. Please review.

Summary by CodeRabbit

  • CI Improvements

    • Added time limits to automated linting, formatting, testing, and security checks.
    • Improved resilience when installing test and formatting tools by retrying temporary download or package installation failures.
  • Tests

    • Added automated validation for CI configuration, including YAML validity, security settings, concurrency controls, job time limits, and installation retry behavior.

Copilot AI review requested due to automatic review settings July 18, 2026 08:26
@don-petry
don-petry requested a review from a team as a code owner July 18, 2026 08:26
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7ef991ad-5b90-4aba-92f7-4b3f78fdc048

📥 Commits

Reviewing files that changed from the base of the PR and between 3a6b282 and 8638279.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • scripts/tests/ci-workflow.bats

📝 Walkthrough

Walkthrough

The CI workflow adds job timeouts and retry loops for external tool installation. A new Bats suite parses the workflow and verifies triggers, permissions, concurrency, timeout bounds, and retry behavior.

Changes

CI workflow hardening

Layer / File(s) Summary
Workflow limits and dependency retries
.github/workflows/ci.yml
Lint, format, test, and secret-scan jobs receive timeout limits. The format job retries HTTPS-only shfmt downloads, and the test job retries apt-get setup for bats with backoff.
Workflow regression coverage
scripts/tests/ci-workflow.bats
Adds YAML parsing and structural checks for workflow existence, triggers, permissions, SHA-scoped concurrency, timeout bounds, and dependency-installation retry behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

✨ 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 dev-lead/issue-360-20260718-0821

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.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) July 18, 2026 08:27

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a new BATS test suite (scripts/tests/ci-workflow.bats) to validate the GitHub Actions CI workflow configuration, ensuring triggers, permissions, concurrency, timeouts, and retry loops are correctly defined. The reviewer's feedback focuses on hardening the inline Python scripts used in these tests. Specifically, they recommend using safe navigation and fallbacks (such as yaml.safe_load(...) or {}) and avoiding chained .get() calls to prevent potential TypeError or KeyError exceptions when parsing YAML elements that might be missing or null.

Comment thread scripts/tests/ci-workflow.bats
Comment thread scripts/tests/ci-workflow.bats
Comment thread scripts/tests/ci-workflow.bats
Comment thread scripts/tests/ci-workflow.bats
Comment thread scripts/tests/ci-workflow.bats
Comment thread scripts/tests/ci-workflow.bats
@don-petry
don-petry disabled auto-merge July 18, 2026 08:28

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.

Pull request overview

This PR addresses Fleet Monitor issue #360 by hardening the repository’s CI workflow to reduce transient failures and prevent long-running hangs, helping keep .github/workflows/ci.yml reliability within the monitored failure-rate threshold.

Changes:

  • Added per-job timeout-minutes values across CI jobs to prevent 6-hour default timeouts from inflating failure metrics.
  • Wrapped shfmt download (curl) and bats installation (apt-get) in bounded retry loops to mitigate transient network/mirror/CDN failures.
  • Added a Bats test suite that validates the CI workflow’s YAML integrity and asserts the presence of the new resiliency controls (timeouts + retries).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
scripts/tests/ci-workflow.bats Adds regression tests that assert CI workflow structure and the new timeout/retry resilience requirements.
.github/workflows/ci.yml Implements timeouts and bounded retries to reduce CI flakiness and prevent hung jobs.

@github-actions

Copy link
Copy Markdown
Contributor

CI Failure: SonarCloud Code Analysis

Step: Quality Gate check — C Security Rating on New Code (required ≥ A)
Root cause: Lint/style

SonarCloud flagged .github/workflows/ci.yml:47, the new curl -sSfL ... -o /usr/local/bin/shfmt download step added to retry-harden the format job. The -L flag makes curl follow redirects without pinning the protocol, so if the release URL ever redirected to a non-HTTPS location, the binary could be fetched over plaintext — a security-sensitivity rule, not a functional bug. This is a security rating gate on new code, so it blocks the merge even though the workflow logic itself is correct.

Suggested fix: Add --proto =https --tlsv1.2 to the curl invocation on line 47 (curl -sSfL --proto '=https' --tlsv1.2 https://github.com/mvdan/sh/releases/download/v3.10.0/shfmt_v3.10.0_linux_amd64 -o /usr/local/bin/shfmt) to explicitly reject any redirect that is not HTTPS, satisfying the SonarCloud security rule.

View run logs

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) July 18, 2026 08:30
Comment thread .github/workflows/ci.yml Fixed
@don-petry
don-petry disabled auto-merge July 18, 2026 08:32
@github-actions

Copy link
Copy Markdown
Contributor

CI Failure: SonarCloud Code Analysis

Step: Quality Gate — Security Rating on New Code
Root cause: Lint/style

The Quality Gate failed because new code got a Security Rating of C (required A). SonarCloud flagged .github/workflows/ci.yml:47, the new curl -sSfL ... -o /usr/local/bin/shfmt retry step added for the shfmt download: using -L (follow redirects) without pinning the protocol lets a compromised/misconfigured server redirect the download to plain HTTP, silently downgrading the connection and enabling a MITM to swap in a malicious shfmt binary. This is a static-analysis security-sensitivity rule (similar to a shellcheck/lint finding), not a test or build failure — the workflow YAML itself is valid and the retry logic works fine.

Suggested fix: Add --proto '=https' to the curl invocation on line 47 (e.g. curl -sSfL --proto '=https' https://github.com/...) so any redirect is restricted to HTTPS and cannot be downgraded.

View run logs

Use Python context managers (with statements) for all file operations in the
BATS tests to properly close file handles and address SonarCloud's C Security
Rating failure (unclosed file handle vulnerability).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@don-petry

Copy link
Copy Markdown
Contributor Author

Fixed in scripts/tests/ci-workflow.bats: replaced unclosed file handles with proper Python context managers (with statements) to address the C Security Rating failure.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) July 18, 2026 08:34
@don-petry
don-petry disabled auto-merge July 18, 2026 08:35
@github-actions

Copy link
Copy Markdown
Contributor

CI Failure: SonarCloud Code Analysis

Step: Quality Gate analysis
Root cause: Lint/style

No GitHub Actions run backs this check (it is the external SonarCloud Quality Gate), so this is inferred from the diff. The PR only touches .github/workflows/ci.yml and adds a new scripts/tests/ci-workflow.bats file. The two new retry loops (shfmt curl download, bats apt-get install) share near-identical "for attempt in 1 2 3; do ... sleep ...; done" structure, and the new bats file repeats the same python3 -c "import yaml; ..." snippet across roughly 7 test cases -- a classic pattern SonarCloud flags as code duplication, which can fail the "Duplicated Lines on New Code" quality gate condition. It's also possible the gate failed on "Coverage on New Code," since the new bats tests and workflow YAML aren't measured by a coverage tool SonarCloud recognizes.

Suggested fix: Extract the shared retry logic into a single reusable script (e.g. scripts/retry.sh attempts delay -- cmd...) and factor the repeated python3 -c "import yaml..." snippet in the bats tests into one helper function, then re-run the analysis to confirm the duplication metric drops below threshold.

View run logs

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) July 18, 2026 08:40
@don-petry
don-petry disabled auto-merge July 18, 2026 08:40
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) July 18, 2026 08:41

@donpetry-bot donpetry-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review — APPROVED ✓

Risk: LOW
Reviewed commit: feb41ee48c525858e0ec3d59220ff4260e786a99
Review mode: triage-approved (single reviewer)

Summary

CI-hardening PR for Fleet Monitor issue #360: adds per-job timeout-minutes (all within org cap 1-59), bounded 3-attempt retry loops for the shfmt curl download and bats apt-get install, curl --proto '=https' hardening, and a bats regression suite guarding all of it. All CI green, all 7 review threads resolved, triage low-risk assessment confirmed.

Linked issue analysis

Issue #360 flagged ci.yml at an 11.1% failure rate (2/18 runs) over the monitored window. The PR substantively addresses both identified transient-failure modes: (1) unretried network installs (shfmt via curl, bats via apt-get) now retry 3x with linear backoff, and (2) jobs without timeout-minutes that could run to GitHub's 6h default and count as timed_out failures now declare bounded timeouts (15/15/20/30 min). The new bats suite prevents regression of both fixes and of existing trigger/permission/concurrency config.

Findings

No blocking findings.

  • Security posture preserved: job-level permissions unchanged (contents: read), actions/checkout remains SHA-pinned, no new actions or dependencies introduced.
  • The SonarCloud finding (HTTPS not enforced on redirects) was fixed with curl --proto '=https' and is guarded by two new test assertions; the thread is resolved.
  • All 6 gemini-code-assist suggestions (safe YAML navigation in the inline Python test helpers) were applied and their threads resolved.
  • Retry loop logic is correct: bounded at 3 attempts, backs off (5s/10s/15s), exits non-zero after exhaustion so genuine outages still fail the job.
  • Non-blocking note: the shfmt binary is downloaded without checksum verification. This is pre-existing behavior (version-pinned URL) and the PR improves it with --proto '=https'; consider adding a sha256 check in a follow-up.
  • Secret-scanning MCP tool unavailable in this environment; the gitleaks CI check passed on this head SHA.
  • Branch is BEHIND main but MERGEABLE; no conflict.

CI status

All required checks green on feb41ee: Lint, Format, Test, Secret scan (gitleaks), CodeQL, Analyze (actions), SonarCloud, agent-shield, dependency-audit (applicable ecosystems skipped as expected).


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

@sonarqubecloud

Copy link
Copy Markdown

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.

[Fleet Monitor] petry-projects/ContentTwin — .github/workflows/ci.yml

4 participants