lint.yml

 1name: lint
 2
 3on:
 4  workflow_call:
 5
 6jobs:
 7  filter:
 8    name: filter
 9    runs-on: ubuntu-latest
10    outputs:
11      golang: ${{ steps.filter.outputs.golang }}
12      golang_files: ${{ steps.filter.outputs.golang_files }}
13    steps:
14      - uses: actions/checkout@v4
15      - uses: dorny/paths-filter@v3
16        id: filter
17        with:
18          list-files: shell
19          filters: |
20            golang:
21              - added|modified: '**/*.go'
22              - added|modified: '/go.sum'
23              - added|modified: '/go.mod'
24
25  codeql:
26    runs-on: ubuntu-latest
27    steps:
28    - name: Checkout repository
29      uses: actions/checkout@v4
30      with:
31        # We must fetch at least the immediate parents so that if this is
32        # a pull request then we can checkout the head.
33        fetch-depth: 2
34
35    - run: git checkout HEAD^2
36      if: ${{ github.event_name == 'pull_request' }}
37
38  spelling:
39    runs-on: ubuntu-latest
40    steps:
41      - name: Checkout
42        uses: actions/checkout@v4
43
44      - name: Check spelling
45        uses: codespell-project/actions-codespell@v2
46
47  go:
48    runs-on: ubuntu-latest
49    needs:
50      - filter
51    if: needs.filter.outputs.golang == 'true'
52    steps:
53      - name: Install Go
54        uses: actions/setup-go@v5
55        with:
56          go-version: 1.22.5
57
58      - name: Checkout code
59        uses: actions/checkout@v4
60
61      - name: Check Code Formatting
62        run: |
63          test -z "$(gofmt -d ${{ needs.filter.outputs.golang_files }})" || exit 1