2022-11-20 06:17:50 +03:00
|
|
|
name: Run tests
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
- dev
|
|
|
|
paths-ignore:
|
|
|
|
- '**.md'
|
2023-07-01 09:37:05 +03:00
|
|
|
- '**.yml'
|
|
|
|
- '**.yaml'
|
2023-06-29 10:16:32 +03:00
|
|
|
- 'examples/*'
|
2023-07-01 09:37:05 +03:00
|
|
|
- '!.github/workflows/test.yml'
|
2022-11-20 06:17:50 +03:00
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- master
|
2023-05-21 11:04:11 +03:00
|
|
|
- dev
|
2022-11-20 06:17:50 +03:00
|
|
|
paths-ignore:
|
|
|
|
- '**.md'
|
2023-07-01 09:37:05 +03:00
|
|
|
- '**.yml'
|
|
|
|
- '**.yaml'
|
2023-06-29 10:16:32 +03:00
|
|
|
- 'examples/*'
|
2023-07-01 09:37:05 +03:00
|
|
|
- '!.github/workflows/test.yml'
|
2022-11-20 06:17:50 +03:00
|
|
|
|
|
|
|
env:
|
|
|
|
GO111MODULE: on
|
|
|
|
GOPROXY: "https://proxy.golang.org"
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
lint:
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os:
|
|
|
|
- ubuntu-latest
|
|
|
|
- macos-latest
|
|
|
|
name: Run golangci-lint
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
2024-04-15 13:07:18 +03:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
2022-11-20 06:17:50 +03:00
|
|
|
- name: Setup Go
|
2024-02-05 13:59:34 +03:00
|
|
|
uses: actions/setup-go@v5
|
2022-11-20 06:17:50 +03:00
|
|
|
with:
|
|
|
|
go-version: '^1.16'
|
2024-04-15 13:07:18 +03:00
|
|
|
cache: false
|
2022-11-20 06:17:50 +03:00
|
|
|
|
|
|
|
- name: Setup and run golangci-lint
|
2024-04-15 13:07:18 +03:00
|
|
|
uses: golangci/golangci-lint-action@v4
|
2022-11-20 06:17:50 +03:00
|
|
|
with:
|
2024-04-15 13:07:18 +03:00
|
|
|
version: v1.57.2
|
2022-12-11 14:40:00 +03:00
|
|
|
args: --timeout 5m -v -E gofumpt -E gocritic -E misspell -E revive -E godot
|
2022-11-20 06:17:50 +03:00
|
|
|
test:
|
|
|
|
needs: lint
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2024-06-17 15:03:43 +03:00
|
|
|
go: [1.13, 1.22]
|
2022-11-20 06:17:50 +03:00
|
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
2024-06-17 15:03:43 +03:00
|
|
|
include:
|
|
|
|
# TODO(panjf2000): There is an uncanny issue arising when downloading
|
|
|
|
# go modules on macOS 13 for Go1.13. So we use macOS 12 for now,
|
|
|
|
# but try to figure it out and use macOS once it's resolved.
|
|
|
|
# https://github.com/panjf2000/ants/actions/runs/9546726268/job/26310385582
|
|
|
|
- go: 1.13
|
|
|
|
os: macos-12
|
|
|
|
exclude:
|
|
|
|
# Starting macOS 14 GitHub Actions runners are arm-based,
|
|
|
|
# but Go didn't support arm64 until 1.16. Thus, we must
|
|
|
|
# replace the macOS 14 runner with macOS 12 runner for Go 1.13.
|
|
|
|
# Ref: https://github.com/actions/runner-images/issues/9741
|
|
|
|
- go: 1.13
|
|
|
|
os: macos-latest
|
2022-11-20 06:17:50 +03:00
|
|
|
name: Go ${{ matrix.go }} @ ${{ matrix.os }}
|
|
|
|
runs-on: ${{ matrix.os}}
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2024-02-05 13:59:34 +03:00
|
|
|
uses: actions/checkout@v4
|
2022-11-20 06:17:50 +03:00
|
|
|
with:
|
|
|
|
ref: ${{ github.ref }}
|
|
|
|
|
|
|
|
- name: Setup Go
|
2024-02-05 13:59:34 +03:00
|
|
|
uses: actions/setup-go@v5
|
2022-11-20 06:17:50 +03:00
|
|
|
with:
|
2023-05-11 05:05:22 +03:00
|
|
|
go-version: ${{ matrix.go }}
|
2022-11-20 06:17:50 +03:00
|
|
|
|
|
|
|
- name: Print Go environment
|
|
|
|
id: go-env
|
|
|
|
run: |
|
|
|
|
printf "Using go at: $(which go)\n"
|
|
|
|
printf "Go version: $(go version)\n"
|
|
|
|
printf "\n\nGo environment:\n\n"
|
|
|
|
go env
|
|
|
|
printf "\n\nSystem environment:\n\n"
|
|
|
|
env
|
|
|
|
# Calculate the short SHA1 hash of the git commit
|
|
|
|
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
echo "GO_CACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
|
|
|
|
|
2023-09-18 17:37:02 +03:00
|
|
|
- name: Run unit tests and integrated tests
|
2022-11-20 06:17:50 +03:00
|
|
|
run: go test -v -race -coverprofile="codecov.report" -covermode=atomic
|
|
|
|
|
|
|
|
- name: Upload code coverage report to Codecov
|
2024-02-05 13:59:34 +03:00
|
|
|
uses: codecov/codecov-action@v4
|
2022-11-20 06:17:50 +03:00
|
|
|
with:
|
|
|
|
file: ./codecov.report
|
|
|
|
flags: unittests
|
|
|
|
name: codecov-ants
|
|
|
|
fail_ci_if_error: true
|
|
|
|
verbose: true
|
2024-02-05 13:59:34 +03:00
|
|
|
env:
|
|
|
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|