File size: 1,651 Bytes
d643072
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Auto Lint (triggered by "auto lint" label)
on:
  pull_request:
    types:
      - opened
      - edited
      - closed
      - reopened
      - synchronize
      - labeled
      - unlabeled
# run only one unit test for a branch / tag.
concurrency:
  group: ci-lint-${{ github.ref }}
  cancel-in-progress: true
jobs:
  lint-by-label:
    if: contains(github.event.pull_request.labels.*.name, 'lint wanted')
    runs-on: ubuntu-latest
    steps:
      - name: Check out Git repository
        uses: actions/checkout@v4
        with:
          token: ${{ secrets.PAT }}
          ref: ${{ github.event.pull_request.head.ref }}
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.10'
      - name: Test pre-commit hooks
        continue-on-error: true
        uses: pre-commit/[email protected] # sync with https://github.com/Efficient-Large-Model/VILA-Internal/blob/main/.github/workflows/pre-commit.yaml
        with:
          extra_args: --all-files
      - name: Check if there are any changes
        id: verify_diff
        run: |
          git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT
      - name: Commit files
        if: steps.verify_diff.outputs.changed == 'true'
        run: |
          git config --local user.email "[email protected]"
          git config --local user.name "GitHub Action"
          git add .
          git commit -m "[CI-Lint] Fix code style issues with pre-commit ${{ github.sha }}" -a
          git push
      - name: Remove label(s) after lint
        uses: actions-ecosystem/action-remove-labels@v1
        with:
          labels: lint wanted