| name: go-lint |
| on: |
| push: |
| branches: |
| - master |
| paths: |
| - 'api/**' |
| pull_request: |
| branches: |
| - master |
| paths: |
| - 'api/**' |
| |
| jobs: |
| golangci: |
| runs-on: ubuntu-latest |
| needs: go-filter |
| if: needs.go-filter.outputs.matches == 'true' |
| steps: |
| - uses: actions/checkout@v3 |
| |
| - name: golangci-lint |
| uses: golangci/golangci-lint-action@v3 |
| with: |
| version: latest |
| working-directory: api |
| args: --tests=false |
| only-new-issues: true |
| gofmt: |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v3 |
| - name: setup go |
| uses: actions/setup-go@v4 |
| with: |
| go-version: '1.18' |
| |
| - uses: actions/cache@v3 |
| with: |
| path: | |
| ~/.cache/go-build |
| ~/go/pkg/mod |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| restore-keys: | |
| ${{ runner.os }}-go- |
| |
| - name: check gofmt |
| run: | |
| diffs=`gofmt -l ${{ needs.go-filter.outputs.files }}` |
| if [[ -n $diffs ]]; then |
| echo "Files are not formatted by gofmt:" |
| echo $diffs |
| exit 1 |
| fi |