Skip to content

Conversation

@kevalyq
Copy link
Contributor

@kevalyq kevalyq commented Nov 2, 2025

πŸ›‘οΈ Feature: Automate Pint & CHANGELOG Validation

Context: Post-PR #74 learnings documented in SELF_REVIEW_CHECKLIST.md were NOT integrated into automated quality gates. This PR closes that gap.

🎯 Problem Solved

Critical Gap: preflight.sh only ran pint --dirty (auto-fix), not pint --test --dirty (CI parity check). This meant:

πŸ“ Changes

1. scripts/preflight.sh - Pint Workflow (CRITICAL)

Before:

run_pint() {
  ${cmd_prefix} ./vendor/bin/pint --dirty  # Only auto-fix
}

After:

run_pint() {
  # Check-first workflow (see SELF_REVIEW_CHECKLIST.md)
  echo "β†’ Checking code style (pint --test --dirty)..."
  if ! ${cmd_prefix} ./vendor/bin/pint --test --dirty; then
    echo "β†’ Auto-fixing code style issues (pint --dirty)..."
    ${cmd_prefix} ./vendor/bin/pint --dirty
    echo "β†’ Verifying fix matches CI requirements (pint --test --dirty)..."
    ${cmd_prefix} ./vendor/bin/pint --test --dirty
  fi
}

Impact:

  • βœ… Ensures CI parity (prevents false confidence)
  • βœ… Matches documented workflow from SELF_REVIEW_CHECKLIST.md
  • βœ… Auto-fixes when needed, then validates

2. .pre-commit-config.yaml - Add Pint Hook

- repo: local
  hooks:
    - id: pint
      name: Laravel Pint
      entry: vendor/bin/pint --dirty
      language: system
      types: [php]

Impact:

  • βœ… Auto-fixes PHP files on commit
  • βœ… Works with preflight.sh verification
  • βœ… Fast (only changed files via --dirty)

3. scripts/preflight.sh - CHANGELOG Validation

# Checks for [Unreleased] section on feature/fix/refactor branches
# Exempts docs/* and chore/* branches
if [ -f CHANGELOG.md ] && [ "$CURRENT_BRANCH" != "main" ] && [[ ! "$CURRENT_BRANCH" =~ ^(docs|chore)/ ]]; then
  if ! grep -q "## \[Unreleased\]" CHANGELOG.md; then
    echo "❌ CHANGELOG.md missing [Unreleased] section"
    exit 1
  fi
fi

Impact:

πŸ”’ Why This Matters

Before this PR:

  • βœ… Best practices documented in SELF_REVIEW_CHECKLIST.md
  • ❌ Not enforced by scripts β†’ Relies on AI/human discipline
  • ❌ Gap between documentation and automation

After this PR:

  • βœ… Best practices documented
  • βœ… Enforced by scripts automatically
  • βœ… Documentation = Automation (aligned)

βœ… Testing

Ran ./scripts/preflight.sh successfully:

  • βœ… Pint check-fix-verify workflow executed correctly
  • βœ… CHANGELOG validation working
  • βœ… All 127 tests passing (376 assertions, 9.47s)
  • βœ… Pre-commit hook tested locally

πŸ”— Related


Review Focus: Verify Pint workflow matches SELF_REVIEW_CHECKLIST.md exactly. Check CHANGELOG validation logic for edge cases.

…n into automation

SPDX-FileCopyrightText: 2025 SecPal
SPDX-License-Identifier: AGPL-3.0-or-later

WHY:
Critical learnings from PR #74 were documented in SELF_REVIEW_CHECKLIST.md
but NOT integrated into automated quality gates. This created a gap where
the same Pint false-confidence issue could happen again.

WHAT CHANGED:

1. scripts/preflight.sh - Pint Workflow (CRITICAL FIX):
   - OLD: Only runs "pint --dirty" (auto-fix)
   - NEW: Runs "pint --test --dirty" β†’ "pint --dirty" β†’ "pint --test --dirty"
   - Matches documented workflow from SELF_REVIEW_CHECKLIST.md
   - Ensures CI parity (CI uses --test flag)
   - Prevents false confidence from auto-fix hiding issues

2. .pre-commit-config.yaml - Add Pint Hook:
   - Added local hook for Laravel Pint with --dirty flag
   - Auto-fixes code style on commit
   - Works in tandem with preflight.sh verification

3. scripts/preflight.sh - CHANGELOG Validation:
   - Checks for [Unreleased] section on feature/fix/refactor branches
   - Warns if section is empty
   - Exempts docs/* and chore/* branches
   - Enforces org-wide CHANGELOG policy automatically

IMPACT:
- Prevents PR #74 Pint issue from recurring (auto-fix masking problems)
- Reduces reliance on AI/human discipline
- Enforces CHANGELOG updates before push
- All documented best practices now automated

TESTING:
Ran ./scripts/preflight.sh successfully:
- Pint check-fix-verify workflow executed correctly
- All 127 tests passing
- CHANGELOG validation working
Copilot AI review requested due to automatic review settings November 2, 2025 17:09
@github-actions
Copy link

github-actions bot commented Nov 2, 2025

πŸ’‘ Tip: Consider Using Draft PRs

Benefits of opening PRs as drafts initially:

  • πŸ’° Saves CI runtime and Copilot review credits
  • 🎯 Automatically sets linked issues to "🚧 In Progress" status
  • πŸš€ Mark "Ready for review" when done to trigger full CI pipeline

How to convert:

  1. Click "Still in progress? Convert to draft" in the sidebar, OR
  2. Use gh pr ready when ready for review

This is just a friendly reminder - feel free to continue as is! 😊

Copy link
Contributor

Copilot AI left a comment

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 implements a check-first workflow for Laravel Pint and adds CHANGELOG validation to ensure CI parity and proper documentation maintenance. The changes align with established coding guidelines documented in SELF_REVIEW_CHECKLIST.md and .github/copilot-instructions.md.

Key Changes

  • Updated Pint workflow in preflight.sh to check first (--test --dirty), auto-fix if needed, then verify
  • Added Pint pre-commit hook to auto-fix changed files
  • Implemented CHANGELOG validation to ensure [Unreleased] section has content on non-docs branches

Reviewed Changes

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

File Description
scripts/preflight.sh Refactored run_pint() to implement check-first workflow and added CHANGELOG validation checks
.pre-commit-config.yaml Added Laravel Pint hook to auto-fix changed files during pre-commit

SPDX-FileCopyrightText: 2025 SecPal
SPDX-License-Identifier: AGPL-3.0-or-later

Address 3 Copilot review comments on PR #77:

1. Magic number 3 β†’ MIN_CHANGELOG_LINES variable with comment
2. Hardcoded branch pattern β†’ CHANGELOG_EXEMPT_PREFIXES config
3. Fragile sed/grep β†’ Robust line-number-based extraction

Changes:
- Extract config variables to top of CHANGELOG validation block
- Add ci/* and test/* to exempt branch prefixes
- Rewrite content extraction to handle [Unreleased] as last section
- Update CHANGELOG.md with new features from this PR
@github-actions
Copy link

github-actions bot commented Nov 2, 2025

πŸ’‘ Tip: Consider Using Draft PRs

Benefits of opening PRs as drafts initially:

  • πŸ’° Saves CI runtime and Copilot review credits
  • 🎯 Automatically sets linked issues to "🚧 In Progress" status
  • πŸš€ Mark "Ready for review" when done to trigger full CI pipeline

How to convert:

  1. Click "Still in progress? Convert to draft" in the sidebar, OR
  2. Use gh pr ready when ready for review

This is just a friendly reminder - feel free to continue as is! 😊

@kevalyq kevalyq merged commit d64dd0b into main Nov 2, 2025
12 checks passed
@kevalyq kevalyq deleted the feat/pint-changelog-validation branch November 2, 2025 17:23
@github-actions
Copy link

github-actions bot commented Nov 2, 2025

πŸ’‘ Tip: Consider Using Draft PRs

Benefits of opening PRs as drafts initially:

  • πŸ’° Saves CI runtime and Copilot review credits
  • 🎯 Automatically sets linked issues to "🚧 In Progress" status
  • πŸš€ Mark "Ready for review" when done to trigger full CI pipeline

How to convert:

  1. Click "Still in progress? Convert to draft" in the sidebar, OR
  2. Use gh pr ready when ready for review

This is just a friendly reminder - feel free to continue as is! 😊

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