summaryrefslogtreecommitdiff
path: root/.github/workflows/ruff-lint-2.yml
blob: 1c5d54eedfbd4d5a856708cd7d123cfdad8af55c (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
name: Ruff Lint 2

on:
  pull_request:
    branches:
      - current

permissions:
  pull-requests: write
  contents: read

jobs:
  ruff-lint-2:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
      contents: read
    steps:
      - name: Checkout reusable actions repo
        uses: actions/checkout@v3
        with:
          repository: vyos/.github
          path: reusable-actions
          ref: current

      - name: Checkout head
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          fetch-tags: true
          ref: ${{ github.event.pull_request.head.ref }}
          repository: ${{ github.event.pull_request.head.repo.full_name }}
          path: repo

      - name: Fetch base
        run: |
          cd repo
          git fetch https://github.com/${{ github.event.pull_request.base.repo.full_name }} ${{ github.event.pull_request.base.ref }}:refs/remotes/origin/base

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

      - name: Get changed files
        id: changed-files
        run: |
          cd repo
          git diff --name-only origin/base...${{ github.event.pull_request.head.ref }} > changed_files.txt

      - name: Run ruff on changed files
        uses: ChartBoost/ruff-action@v1
        with:
          files: |
            $(cat repo/changed_files.txt)