chore(ci): add autofix.ci workflow for automatic code fixes#840
chore(ci): add autofix.ci workflow for automatic code fixes#840
Conversation
Add autofix.ci GitHub workflow to automatically fix linting and formatting issues in pull requests. This includes: - Biome code formatting and linting fixes - Oxlint additional linting fixes - Website client/server linting fixes - Browser extension linting fixes The workflow runs on pull requests and pushes to main branch, helping maintain code quality standards automatically.
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughIntroduces a new GitHub Actions workflow (.github/workflows/autofix.yml) that runs on pull_request events and pushes to main. It installs Node.js and npm dependencies, runs multiple lint/fix tasks across subpackages with continue-on-error, and then executes the autofix-ci/action. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant GH as GitHub
participant Runner as Actions Runner
participant Repo as Repo
Dev->>GH: Open PR / Push to main
GH-->>Runner: Trigger workflow "autofix.ci"
rect rgb(240,248,255)
note right of Runner: Job on ubuntu-latest
Runner->>Repo: actions/checkout
Runner->>Runner: setup-node (node-version-file, npm cache)
Runner->>Runner: npm ci (install deps)
Runner->>Runner: biome lint/fix (continue-on-error)
Runner->>Runner: oxlint (continue-on-error)
Runner->>Runner: npm run lint/fix (website/client) (continue-on-error)
Runner->>Runner: npm run lint/fix (website/server) (continue-on-error)
Runner->>Runner: npm run lint/fix (browser) (continue-on-error)
Runner->>Repo: autofix-ci/action (commit fixes)
end
Repo-->>Dev: Pushes fixes to PR (if any)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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. Comment |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a GitHub Actions workflow for autofix.ci that automatically fixes linting and formatting issues in pull requests. The workflow integrates with the project's existing linting tools to provide programmatic code fixes.
Key changes:
- Adds autofix.ci workflow that runs on pull requests and main branch pushes
- Integrates with Biome, Oxlint, and component-specific linting tools
- Uses continue-on-error strategy to handle linting failures gracefully
Deploying repomix with
|
| Latest commit: |
56a5561
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f9322bd7.repomix.pages.dev |
| Branch Preview URL: | https://chore-autofix-ci.repomix.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #840 +/- ##
=======================================
Coverage 87.27% 87.27%
=======================================
Files 113 113
Lines 6839 6839
Branches 1408 1408
=======================================
Hits 5969 5969
Misses 870 870 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Update autofix.yml workflow to use pinned action versions: - Pin actions/checkout@v5 with commit hash - Pin actions/setup-node@v4 with commit hash - Pin autofix-ci/action@v1.3.2 with commit hash - Minor formatting improvements This improves security by using specific commit hashes instead of mutable tags.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
.github/workflows/autofix.yml (1)
8-10: Autofix will not be able to push without write perms; scope them at the job level.Top-level is least‑privilege (contents: read), but the job that runs autofix needs write to commit fixes back to PR branches.
Apply at the job level to avoid widening perms repo‑wide:
jobs: autofix: runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write steps:Also applies to: 11-14
🧹 Nitpick comments (8)
.github/workflows/autofix.yml (8)
55-55: Prevent loops and only run the push-back step on PRs (skip bot re-triggers).Without a guard, pushes from autofix-ci could retrigger this workflow. Gate the final step.
- - uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 # ratchet:autofix-ci/action@v1.3.2 + - if: ${{ github.event_name == 'pull_request' && github.actor != 'autofix-ci[bot]' }} + uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 # ratchet:autofix-ci/action@v1.3.2
23-24: Guard root npm ci in case the repo root has no package-lock.json.Prevents hard failures in mono-repos that install per package.
- - name: Install dependencies - run: npm ci + - name: Install dependencies (root) + if: ${{ hashFiles('package-lock.json') != '' }} + run: npm ci
34-39: Guard website/client install; don’t fail if the package doesn’t exist.Keeps the workflow resilient across optional packages.
- name: Fix website client linting working-directory: website/client + if: ${{ hashFiles('website/client/package-lock.json') != '' }} run: | npm ci npm run lint continue-on-error: true
41-47: Guard website/server install similarly.- name: Fix website server linting working-directory: website/server + if: ${{ hashFiles('website/server/package-lock.json') != '' }} run: | npm ci npm run lint continue-on-error: true
48-54: Guard browser extension install similarly.- name: Fix browser extension linting working-directory: browser + if: ${{ hashFiles('browser/package-lock.json') != '' }} run: | npm ci npm run lint continue-on-error: true
15-15: Harden checkout for bot-based commits.Use full history and avoid persisting default credentials so pushes (if any) come from the bot/token you intend.
- - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # ratchet:actions/checkout@v5 + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # ratchet:actions/checkout@v5 + with: + fetch-depth: 0 + persist-credentials: false
11-14: Add concurrency and a job timeout to avoid overlapping runs.Prevents racey double-pushes and hung jobs.
autofix: runs-on: ubuntu-latest + timeout-minutes: 20 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true
1-6: Consider removing the push-to-main trigger or split it into a non-fixing job.Running autofix on pushes to main is usually unnecessary and risks loops. If you need lint-on-main, split to a separate workflow without the autofix push-back step.
Option A — restrict this workflow to PRs only:
on: pull_request: - push: - branches: ["main"]Option B — keep push but skip the autofix step (already suggested with
if:on the final step).
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/autofix.yml(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-11-02T17:45:31.561Z
Learnt from: chenrui333
PR: yamadashy/repomix#151
File: .github/workflows/release.yml:13-13
Timestamp: 2024-11-02T17:45:31.561Z
Learning: For `.github/workflows/release.yml`, the project prefers to use `master` for GitHub Actions instead of pinning specific versions.
Applied to files:
.github/workflows/autofix.yml
🔇 Additional comments (3)
.github/workflows/autofix.yml (3)
55-55: Nice: pinned to a commit SHA with a ratchet tag.The inline ratchet comment documents the version (v1.3.2). No further action.
15-55: Note on action pinning vs. floating refs.A past preference in this repo favored floating refs like master in release.yml. Here you’re pinning to SHAs with ratchet tags, which is the more secure default. Confirm the current repo standard so we keep it consistent across workflows.
If needed, I can open a follow-up PR to align the other workflows.
17-22: No change required — actions/setup-node@v4 supports .tool-versions
The action's node-version-file accepts an asdf .tool-versions file (format example:nodejs 16.14.0; comments and multiple versions allowed). Ensure .tool-versions contains explicit/full versions; usenode-version: "lts/*"if you want an explicit fallback.
Add autofix.ci GitHub workflow to automatically fix linting and formatting issues in pull requests.
This workflow integrates with the existing project linting tools to provide automatic code fixes:
The workflow runs on pull requests and pushes to the main branch, helping maintain code quality standards automatically by fixing common issues that can be resolved programmatically.
Checklist
npm run testnpm run lint