-
Notifications
You must be signed in to change notification settings - Fork 646
108 lines (106 loc) · 3.23 KB
/
tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Tests
on: [push, pull_request]
jobs:
test-linux:
strategy:
fail-fast: false
matrix:
target:
- linux-amd64-unit-test-1-cpu
- linux-amd64-unit-test-2-cpu
- linux-amd64-unit-test-4-cpu
- linux-amd64-unit-test-4-cpu-race
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v3
with:
go-version: ${{ steps.goversion.outputs.goversion }}
- run: make fmt
- env:
TARGET: ${{ matrix.target }}
run: |
case "${TARGET}" in
linux-amd64-unit-test-1-cpu)
CPU=1 make test
;;
linux-amd64-unit-test-2-cpu)
CPU=2 make test
;;
linux-amd64-unit-test-4-cpu)
CPU=4 make test
;;
linux-amd64-unit-test-4-cpu-race)
# XXX: By default, the Github Action runner will terminate the process
# if it has high resource usage. Try to use GOGC to limit memory and
# cpu usage here to prevent unexpected terminating. It can be replaced
# with GOMEMLIMIT=2048MiB if the go-version is updated to >=1.19.x.
#
# REF: https://github.com/actions/runner-images/issues/6680#issuecomment-1335778010
GOGC=30 CPU=4 ENABLE_RACE=true make test
;;
*)
echo "Failed to find target"
exit 1
;;
esac
- name: golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
version: v1.60.1
test-windows:
strategy:
fail-fast: false
matrix:
target:
- windows-amd64-unit-test-4-cpu
# FIXME(fuweid):
#
# The windows will throws the following error when enable race.
# We skip it until we have solution.
#
# ThreadSanitizer failed to allocate 0x000200000000 (8589934592) bytes at 0x0400c0000000 (error code: 1455)
#
#- windows-amd64-unit-test-4-cpu-race
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v3
with:
go-version: ${{ steps.goversion.outputs.goversion }}
- run: make fmt
- env:
TARGET: ${{ matrix.target }}
run: |
case "${TARGET}" in
windows-amd64-unit-test-4-cpu)
CPU=4 make test
;;
*)
echo "Failed to find target"
exit 1
;;
esac
shell: bash
- name: golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
version: v1.60.1
coverage:
needs: ["test-linux", "test-windows"]
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- id: goversion
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v3
with:
go-version: ${{ steps.goversion.outputs.goversion }}
- run: make coverage