diff --git a/.github/workflows/claude-pr-review.yml b/.github/workflows/claude-pr-review.yml index 0aae2518d7..e5db8adb5a 100644 --- a/.github/workflows/claude-pr-review.yml +++ b/.github/workflows/claude-pr-review.yml @@ -22,7 +22,7 @@ jobs: uses: lewagon/wait-on-check-action@v1.3.1 with: ref: ${{ github.event.pull_request.head.sha }} - check-regexp: '^(eslint|prettier|test|playwright-tests)' + check-regexp: '^(lint-and-format|test|playwright-tests)' wait-interval: 30 repo-token: ${{ secrets.GITHUB_TOKEN }} @@ -30,7 +30,7 @@ jobs: id: check-status run: | # Get all check runs for this commit - CHECK_RUNS=$(gh api repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }}/check-runs --jq '.check_runs[] | select(.name | test("eslint|prettier|test|playwright-tests")) | {name, conclusion}') + CHECK_RUNS=$(gh api repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }}/check-runs --jq '.check_runs[] | select(.name | test("lint-and-format|test|playwright-tests")) | {name, conclusion}') # Check if any required checks failed if echo "$CHECK_RUNS" | grep -q '"conclusion": "failure"'; then diff --git a/.github/workflows/eslint.yaml b/.github/workflows/eslint.yaml deleted file mode 100644 index c3735ff5f5..0000000000 --- a/.github/workflows/eslint.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: ESLint - -on: - pull_request: - branches-ignore: [ wip/*, draft/*, temp/* ] - -jobs: - eslint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: 'lts/*' - - run: npm ci - - run: npm run lint diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml deleted file mode 100644 index 5d71c34522..0000000000 --- a/.github/workflows/format.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: Prettier Check - -on: - pull_request: - branches-ignore: [ wip/*, draft/*, temp/* ] - -jobs: - prettier: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: 'lts/*' - - - name: Install dependencies - run: npm ci - - - name: Run Prettier check - run: npm run format:check diff --git a/.github/workflows/lint-and-format.yaml b/.github/workflows/lint-and-format.yaml new file mode 100644 index 0000000000..4eb24db9d9 --- /dev/null +++ b/.github/workflows/lint-and-format.yaml @@ -0,0 +1,71 @@ +name: Lint and Format + +on: + pull_request: + branches-ignore: [wip/*, draft/*, temp/*] + +permissions: + contents: write + pull-requests: write + +jobs: + lint-and-format: + runs-on: ubuntu-latest + steps: + - name: Checkout PR + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + ref: ${{ github.head_ref }} + fetch-depth: 0 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run ESLint with auto-fix + run: npm run lint:fix + + - name: Run Prettier with auto-format + run: npm run format + + - name: Check for changes + id: verify-changed-files + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "changed=true" >> $GITHUB_OUTPUT + else + echo "changed=false" >> $GITHUB_OUTPUT + fi + + - name: Commit changes + if: steps.verify-changed-files.outputs.changed == 'true' + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add . + git commit -m "[auto-fix] Apply ESLint and Prettier fixes" + git push + + - name: Final validation + if: steps.verify-changed-files.outputs.changed == 'true' + run: | + npm run lint + npm run format:check + + - name: Comment on PR + if: steps.verify-changed-files.outputs.changed == 'true' + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '## 🔧 Auto-fixes Applied\n\nThis PR has been automatically updated to fix linting and formatting issues.\n\n**⚠️ Important**: Your local branch is now behind. Run `git pull` before making additional changes to avoid conflicts.\n\n### Changes made:\n- ESLint auto-fixes\n- Prettier formatting' + })