Skip to content

Add golangci-lint CI #13

Add golangci-lint CI

Add golangci-lint CI #13

Workflow file for this run

name: ci
on:
pull_request:
push:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.head.repo.full_name || github.repository }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
env:
GOBIN: ${{ github.workspace }}/.cache/go/bin
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
cache: false
go-version-file: go.mod
- name: Resolve Go cache paths
id: go-cache-paths
run: |
echo "gomodcache=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
echo "gocache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
- name: Restore Go shared cache
uses: actions/cache/restore@v4
with:
path: |
${{ steps.go-cache-paths.outputs.gomodcache }}
${{ steps.go-cache-paths.outputs.gocache }}
key: go-shared-${{ runner.os }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-shared-${{ runner.os }}-
- name: Restore Go tool cache
uses: actions/cache/restore@v4
with:
path: ${{ env.GOBIN }}
key: go-tools-${{ runner.os }}-${{ hashFiles('hack/lint.sh') }}
restore-keys: |
go-tools-${{ runner.os }}-
- run: ./hack/lint.sh
- name: Save Go tool cache
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/cache/save@v4
with:
path: ${{ env.GOBIN }}
key: go-tools-${{ runner.os }}-${{ hashFiles('hack/lint.sh') }}
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
cache: false
go-version-file: go.mod
- name: Resolve Go cache paths
id: go-cache-paths
run: |
echo "gomodcache=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
echo "gocache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
- name: Restore Go shared cache
uses: actions/cache/restore@v4
with:
path: |
${{ steps.go-cache-paths.outputs.gomodcache }}
${{ steps.go-cache-paths.outputs.gocache }}
key: go-shared-${{ runner.os }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-shared-${{ runner.os }}-
- run: go test ./...
- name: Save Go shared cache
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/cache/save@v4
with:
path: |
${{ steps.go-cache-paths.outputs.gomodcache }}
${{ steps.go-cache-paths.outputs.gocache }}
key: go-shared-${{ runner.os }}-${{ hashFiles('go.sum') }}
readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
cache: false
go-version-file: go.mod
- name: Resolve Go cache paths
id: go-cache-paths
run: |
echo "gomodcache=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
echo "gocache=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
- name: Restore Go shared cache
uses: actions/cache/restore@v4
with:
path: |
${{ steps.go-cache-paths.outputs.gomodcache }}
${{ steps.go-cache-paths.outputs.gocache }}
key: go-shared-${{ runner.os }}-${{ hashFiles('go.sum') }}
restore-keys: |
go-shared-${{ runner.os }}-
- run: ./hack/update-readme.sh
- run: git diff --exit-code -- README.md