Update ci config #57
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: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go: [ '1.18' , '1.19' , '1.20' , '1.21' , '1.22'] | |
# https://github.com/actions/setup-go?tab=readme-ov-file#using-stableoldstable-aliases | |
# If stable is provided, action will get the latest stable version from the go-versions repository manifest. | |
# If oldstable is provided, when current release is 1.19.x, action will resolve version as 1.18.x, where x is the latest patch release. | |
# go: [stable, oldstable] | |
steps: | |
- name: Set up Go ${{ matrix.go }} | |
uses: actions/setup-go@v5 | |
with: | |
# go-version: ^1.13 | |
go-version: ${{ matrix.go }} | |
id: go | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v4 | |
- name: Get dependencies | |
run: | | |
go version | |
go get -v -t -d ./... | |
# - name: Build | |
# run: go build -v . | |
- name: Test | |
# 在并发情况下,同时运行的测试的数量默认取决于 GOMAXPROCS。它可以通过 -parallel n 被指定(go test -parallel 4) | |
# run: go test -cover -v ./... | |
run: | | |
go test -cover -v ./... | |
go vet ./... | |
# golangci-lint run #golangci-lint run --enable-all 如果手动执行,需要提前下载golangci-lint | |
# CI是通过golangci-lint.yml配置文件启用的 | |
- name: Test Parallel | |
# 在并发情况下,同时运行的测试的数量默认取决于 GOMAXPROCS。它可以通过 -parallel n 被指定(go test -parallel 4) | |
run: go test -parallel 4 -cover -v ./... | |
# html格式查看cover信息: https://blog.golang.org/cover | |
# go test -covermode=count -coverprofile=count.out ./... && go tool cover -html=count.out | |
# -count=1可以跳过缓存(默认情况下,第一次执行过了,第二次就会有缓存) | |
# run: go test -count=1 |