Skip to content

build: Use golangci action and make parallel. #5089

build: Use golangci action and make parallel.

build: Use golangci action and make parallel. #5089

Workflow file for this run

name: Build and Test
on: [push, pull_request]
permissions:
contents: read
jobs:
resolve-modules:
name: Resolve Go modules
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out source
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- id: set-matrix
run: |
echo "Resolving modules in $(pwd)" && \
MODPATHS=$(find . -mindepth 2 -type f -name go.mod -printf '{"workdir":"%h"},') && \
echo "matrix={\"include\":[${MODPATHS%,}]}" >> $GITHUB_OUTPUT
build:
name: Go CI
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.19", "1.20"]
steps:
- name: Check out source
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ matrix.go }}
- name: Use test and module cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-test-${{ matrix.go }}-${{ github.sha }}
restore-keys: go-test-${{ matrix.go }}
- name: Stablilize testdata timestamps
run: |
bash ./.github/stablilize_testdata_timestamps.sh "${{ github.workspace }}"
- name: Build
run: go build ./...
- name: Test
run: |
sh ./run_tests.sh
lint:
name: Lint
needs: resolve-modules
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.resolve-modules.outputs.matrix ) }}
steps:
- name: Check out source
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: "1.20"
- name: golangci-lint
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 #v3.6.0
with:
install-mode: "goinstall"
version: 2dcd82f331c9e834f283075b23ef289435be9354 # v1.53.3
working-directory: ${{ matrix.workdir }}