build: Use golangci action and make parallel. #5090
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | ||
on: [push, pull_request] | ||
permissions: | ||
contents: read | ||
env: [ | ||
Check failure on line 6 in .github/workflows/go.yml GitHub Actions / Build and TestInvalid workflow file
|
||
CHECKOUT_ACTION_REV: 'c85c95e3d7251135ab7dc9ce3241c5835cc595a9', # v3.5.3 | ||
SETUP_GO_ACTION_REV: 'fac708d6674e30b6ba41289acaab6d4b75aa0753', # v4.0.1 | ||
CACHE_ACTION_REV: '88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8', # v3.3.1 | ||
GOLANGCI_LINT_ACTION_REV: '639cd343e1d3b897ff35927a75193d57cfcba299', #v3.6.0 | ||
GOLANGCI_LINT_VER: '2dcd82f331c9e834f283075b23ef289435be9354' # v1.53.3 | ||
] | ||
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@${{ env.CHECKOUT_ACTION_REV }} | ||
- 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@${{ env.CHECKOUT_ACTION_REV }} | ||
- name: Set up Go | ||
uses: actions/setup-go@${{ env.SETUP_GO_ACTION_REV }} | ||
with: | ||
go-version: ${{ matrix.go }} | ||
- name: Use test and module cache | ||
uses: actions/cache@${{ env.CACHE_ACTION_REV }} | ||
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@${{ env.CHECKOUT_ACTION_REV }} | ||
- name: Set up Go | ||
uses: actions/setup-go@${{ env.SETUP_GO_ACTION_REV }} | ||
with: | ||
go-version: "1.20" | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@${{ env.GOLANGCI_LINT_ACTION_REV }} | ||
with: | ||
install-mode: "goinstall" | ||
version: ${{ env.GOLANGCI_LINT_VER }} | ||
working-directory: ${{ matrix.workdir }} |