Skip to content

Commit

Permalink
Update CI config
Browse files Browse the repository at this point in the history
  • Loading branch information
taobig committed Jun 8, 2024
1 parent 45fa793 commit 83379fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 43 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Go

on:
push:
branches: [ master ]
branches: [ master , develop ]
pull_request:
branches: [ master ]

Expand Down Expand Up @@ -38,24 +38,24 @@ jobs:

- name: Test
# 在并发情况下,同时运行的测试的数量默认取决于 GOMAXPROCS。它可以通过 -parallel n 被指定(go test -parallel 4)
# run: go test -cover -v ./...
# 需要注意的是:
# 1. 并行测试的限制:仅当测试函数使用 t.Parallel() 来标记它们时,-parallel 参数才会生效。否则,测试函数会按顺序执行。
# 2. CPU 核心数:-parallel 的值不应超过可用 CPU 核心数。Go 运行时会自动调整并行度来避免过载。
#
# run: go test -cover -v ./...
# 从go1.20开始test子命令才支持-skip参数
run: |
if [[ "${{ matrix.go-version }}" < "1.20" ]]; then
nproc --all || sysctl -n hw.ncpu || grep -c ^processor /proc/cpuinfo || date
if [[ "${{ matrix.go }}" < "1.20" ]]; then
go test -cover -v ./...
go test -race -v ./...
else
go test -skip "^TestSendMail$" -cover -v ./...
go test -race -skip "^TestSendMail$" -skip "^TestDataRaceError$" -v ./...
fi
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 ./...
# golangci-lint run #golangci-lint run --enable-all 如果手动执行,需要提前下载golangci-lint
# CI是通过golangci-lint.yml配置文件启用的
# html格式查看cover信息: https://blog.golang.org/cover
# go test -covermode=count -coverprofile=count.out ./... && go tool cover -html=count.out

Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/golangci-lint.yml

This file was deleted.

0 comments on commit 83379fe

Please sign in to comment.