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    - name: Initialize CodeQL
39      uses: github/codeql-action/init@v3
40      with:
41        languages: go, javascript
42
43    - name: Autobuild
44      uses: github/codeql-action/autobuild@v3
45
46    - name: Perform CodeQL Analysis
47      uses: github/codeql-action/analyze@v3
48
49  spelling:
50    runs-on: ubuntu-latest
51    steps:
52      - name: Checkout
53        uses: actions/checkout@v4
54
55      - name: Check spelling
56        uses: codespell-project/actions-codespell@v2
57
58  go:
59    runs-on: ubuntu-latest
60    needs:
61      - filter
62    if: needs.filter.outputs.golang == 'true'
63    steps:
64      - name: Install Go
65        uses: actions/setup-go@v5
66        with:
67          go-version: 1.22.5
68
69      - name: Checkout code
70        uses: actions/checkout@v4
71
72      - name: Check Code Formatting
73        run: |
74          test -z "$(gofmt -d ${{ needs.filter.outputs.golang_files }})" || exit 1