aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/lint.yml
blob: 2a643989e0a8a652e47e209dbe92fbe6f29e2c64 (plain) (blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: lint

on:
  workflow_call:

jobs:
  filter:
    name: filter
    runs-on: ubuntu-latest
    outputs:
      golang: ${{ steps.filter.outputs.golang }}
      golang_files: ${{ steps.filter.outputs.golang_files }}
    steps:
      - uses: actions/checkout@v4
      - uses: dorny/paths-filter@v3
        id: filter
        with:
          list-files: shell
          filters: |
            golang:
              - added|modified: '**/*.go'
              - added|modified: '/go.sum'
              - added|modified: '/go.mod'

  codeql:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repository
      uses: actions/checkout@v4
      with:
        # We must fetch at least the immediate parents so that if this is
        # a pull request then we can checkout the head.
        fetch-depth: 2

    - run: git checkout HEAD^2
      if: ${{ github.event_name == 'pull_request' }}

    - name: Initialize CodeQL
      uses: github/codeql-action/init@v3
      with:
        languages: go, javascript

    - name: Autobuild
      uses: github/codeql-action/autobuild@v3

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v3

  spelling:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Check spelling
        uses: codespell-project/actions-codespell@v2

  go:
    runs-on: ubuntu-latest
    needs:
      - filter
    if: needs.filter.outputs.golang == 'true'
    steps:
      - name: Install Go
        uses: actions/setup-go@v5
        with:
          go-version: 1.22.5

      - name: Checkout code
        uses: actions/checkout@v4

      - name: Check Code Formatting
        run: |
          test -z "$(gofmt -d ${{ needs.filter.outputs.golang_files }})" || exit 1