name: Go test and lint on: pull_request: branches: 'master' jobs: go-test-lint: strategy: matrix: go: [1.18] golangcli: [v1.50.0] os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: - name: Set up Go uses: actions/setup-go@v3 with: go-version: ${{ matrix.go }} - name: Checkout uses: actions/checkout@v3 - name: Go Cache Paths id: go-cache-paths run: | echo "::set-output name=go-build::$(go env GOCACHE)" echo "::set-output name=go-mod::$(go env GOMODCACHE)" - name: Go Build Cache uses: actions/cache@v3 with: path: ${{ steps.go-cache-paths.outputs.go-build }} key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - name: Go Mod Cache uses: actions/cache@v3 with: path: ${{ steps.go-cache-paths.outputs.go-mod }} key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} - name: Validate go mod run: | go mod tidy git --no-pager diff && [[ 0 -eq $(git status --porcelain | wc -l) ]] - name: Go Lint uses: golangci/golangci-lint-action@v3 with: version: ${{ matrix.golangci }} args: "--out-${NO_FUTURE}format colored-line-number" skip-pkg-cache: true skip-build-cache: true - name: Go Build run: go build ./... - name: Go Test run: go test -race -v ./...