Skip to content
name: Build and Test
on:
push:
branches:
- main
pull_request:
jobs:
setup-env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21.8"
- name: install gomods
run: make gomoddownload
- name: install tools
run: make install-gotools
lint:
name: Lint
runs-on: ubuntu-latest
needs: [setup-env]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21.8"
- name: install gomods
run: make gomoddownload
- name: install tools
run: make install-gotools
- name: lint code
run: make golint
go-versions:
name: lookup Go versions
runs-on: ubuntu-latest
needs: [setup-env]
outputs:
matrix: ${{ steps.versions.outputs.matrix }}
version: ${{ steps.versions.outputs.go-mod-version }}
latest: ${{ steps.versions.outputs.latest }}
steps:
- uses: actions/checkout@v3
- uses: arnested/go-version-action@v1
id: versions
test:
name: Test
strategy:
matrix:
go-version: ${{ fromJSON(needs.go-versions.outputs.matrix) }}
runs-on: ubuntu-latest
needs: [go-versions]
steps:
- uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
check-latest: true
- name: Go test 1.21
if: startsWith( matrix.go-version , needs.go-versions.outputs.version )
run: echo "test 1.21"
- name: Go test 1.22
if: startsWith( matrix.go-version , needs.go-versions.outputs.latest )
run: echo "test 1.22"
build:
name: Build
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.22
- name: Check out code
uses: actions/checkout@v1
- name: Build
run: make build