summaryrefslogtreecommitdiff
path: root/.github/workflows/ruff-lint.yml
blob: 890962166011c81604fbf8a8e1ab083009c73166 (plain)
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
---
name: Ruff Lint

on: pull_request

jobs:
  ruff-lint:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
      contents: read
    steps:
      - name: Checkout head
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          ref: ${{ github.event.pull_request.head.ref }}
          repository: ${{ github.event.pull_request.head.repo.full_name }}

      - name: Setup python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11' 

      - name: Fetch base ruff config
        run: |
          git fetch https://github.com/${{ github.event.pull_request.base.repo.full_name }} ${{ github.event.pull_request.base.ref }}:refs/remotes/origin/base
          if git ls-tree -r origin/base --name-only | grep -q '^ruff.toml$'; then
            git checkout origin/base -- ruff.toml
            echo "Using ruff.toml from base repo"
            cat ruff.toml
          else
            echo "No ruff.toml found in base repo"
          fi          

      - name: Lint
        uses: chartboost/ruff-action@491342200cdd1cf4d5132a30ddc546b3b5bc531b
        with:
          args: check
          changed-files: 'true'