Skip to content

auto lint fix in CI #2060

@donaldkuck

Description

@donaldkuck

🌟 Feature Description

Could we add a CI job for automated lint fixing?

Motivation

This would enable automatic lint checking and fixing within our CI pipeline, saving manual effort and freeing up developers' time.

sample code:

name: Lint Fix

on:
  pull_request:
    branches:
      - main

jobs:

  lint-fix:
    name: Fix linting issues
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write

    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}
          repository: ${{ github.event.pull_request.head.repo.full_name }}
          fetch-depth: 0
          token: ${{ secrets.GITHUB_TOKEN }}

... ...

      - name: run format
        run:
          make format
      # Commit and push changes if any
      - name: Check for changes
        id: git-check
        run: |
          git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT
      - name: Commit and push if there are changes
        if: steps.git-check.outputs.changes == 'true'
        run: |
          git config --local user.email "XXX"
          git config --local user.name "XXX"
          git commit -a -m "🤖 Auto-fix linting issues"
          git push

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions