Create go.yml #1
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: Go | ||
on: | ||
push: | ||
branches: ['*'] | ||
tags: ['v*'] | ||
pull_request: | ||
branches: ['*'] | ||
permissions: | ||
contents: read | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go: ["1.20.x", "1.21.x"] | ||
include: | ||
- go: 1.21.x | ||
latest: true | ||
steps: | ||
- name: Setup Go | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
- name: Checkout code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Load cached dependencies | ||
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v.3.3.2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.54 | ||
- name: Test | ||
run: | | ||
go test -race -coverprofile=cover.out -v ./... | ||
go tool cover -html=cover.out -o cover.html | ||
- name: Upload coverage to codecov.io | ||
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 |