-
-
Notifications
You must be signed in to change notification settings - Fork 40
271 lines (259 loc) · 9.19 KB
/
Copy pathbuild.yml
File metadata and controls
271 lines (259 loc) · 9.19 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: build
on:
push:
branches: [main]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Detect code changes
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Filter changed paths
uses: dorny/paths-filter@v4
id: filter
with:
# "code" is true if any of these paths changed
filters: |
code:
- '**/*.go'
- 'go.mod'
- 'go.sum'
- '.golangci.yml'
- '.github/workflows/build.yml'
- '.github/workflows/pr.yml'
lint:
name: Lint (golangci-lint)
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
env:
TZ: UTC
CGO_ENABLED: "1"
GOTOOLCHAIN: local # avoid auto-upgrading the toolchain
GOFLAGS: -mod=readonly -tags=hashicorpmetrics
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
submodules: false
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: "1.26.6"
check-latest: false
cache-dependency-path: "**/*.sum"
- name: Restore Go build and module caches
uses: actions/cache@v6
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Tidy and vendor modules
run: go mod tidy && go mod vendor
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.12.2
args: --timeout 10m --config .golangci.yml
cross-compile:
# Every lint and test job runs on ubuntu, so the platform-specific files
# (notably memory/memory_darwin.go, memory/memory_bsd.go and
# memory/memory_windows.go) are otherwise never compiled and rot silently.
name: Cross-compile (${{ matrix.target }})
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
target:
- darwin/arm64
- darwin/amd64
- windows/amd64
- freebsd/amd64
- openbsd/amd64
- netbsd/amd64
- dragonfly/amd64
env:
TZ: UTC
CGO_ENABLED: "0" # no cross C toolchain on the runner
GOTOOLCHAIN: local # avoid auto-upgrading the toolchain
GOFLAGS: -mod=readonly -tags=hashicorpmetrics
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
submodules: false
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: "1.26.6"
check-latest: false
cache-dependency-path: "**/*.sum"
- name: Restore Go build and module caches
uses: actions/cache@v6
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-cross-${{ matrix.target }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-cross-${{ matrix.target }}-go-
- name: Tidy and vendor modules
run: go mod tidy && go mod vendor
- name: Compile module and type-check memory tests for ${{ matrix.target }}
shell: bash
run: |
TARGET="${{ matrix.target }}"
export GOOS="${TARGET%/*}" GOARCH="${TARGET#*/}"
go build -mod=vendor ./...
# Also type-check the platform-specific package's _test.go files,
# which go build skips. This is scoped to ./memory/... rather than
# ./... because the vendored testcontainers -> moby/term chain does
# not type-check on dragonfly (it references unix.TCGETS/TCSETS).
go vet -mod=vendor ./memory/...
memory-tests:
# A cross-compile cannot execute the per-GOOS memory implementations: a
# wrong sysctl name or integer width compiles cleanly and only fails at
# runtime, which is exactly the bug class these files are prone to. macOS
# and Windows runners are free for public repositories, so run the package
# for real there. The BSD files stay compile-only, as GitHub hosts no BSD
# runners.
name: Memory tests (${{ matrix.os }})
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
env:
TZ: UTC
CGO_ENABLED: "1"
GOTOOLCHAIN: local # avoid auto-upgrading the toolchain
GOFLAGS: -mod=readonly
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
submodules: false
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: "1.26.6"
check-latest: false
cache-dependency-path: "**/*.sum"
- name: Run memory package tests
run: go test -count=1 -timeout 5m -v ./memory/...
unit-tests:
name: Unit tests (${{ matrix.shard }})
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
# The actor package dominates the suite's wall-clock time: one test
# binary, strictly serial. It is split across three runners by a
# deterministic round-robin over the sorted top-level test list, so
# new tests distribute automatically.
- shard: actor-0
packages: "./actor/..."
flags: "-p 1 -timeout 30m"
- shard: actor-1
packages: "./actor/..."
flags: "-p 1 -timeout 30m"
- shard: actor-2
packages: "./actor/..."
flags: "-p 1 -timeout 30m"
# Packages that bind ports or spin up cluster, remoting, or discovery
# infrastructure keep the serialized -p 1 they have always run with.
- shard: infra
packages: "./internal/cluster/... ./internal/net/... ./internal/remoteclient/... ./remote/... ./client/... ./testkit/... ./discovery/... ./datacenter/..."
flags: "-p 1 -timeout 30m"
# Everything else is independent and runs with go's default
# package-level parallelism. The package list is computed in the run
# step as the complement of the two shards above.
- shard: core
packages: ""
flags: "-timeout 30m"
env:
TZ: UTC
CGO_ENABLED: "1"
GOTOOLCHAIN: local # avoid auto-upgrading the toolchain
# Stabilise tests that rely on randomness/time. The hashicorpmetrics tag
# routes memberlist's metrics through github.com/hashicorp/go-metrics
# instead of the deprecated github.com/armon/go-metrics fallback.
GOFLAGS: -mod=readonly -tags=hashicorpmetrics
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
submodules: false
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: "1.26.6"
check-latest: false
cache-dependency-path: "**/*.sum"
- name: Print Go version
run: go version
- name: Restore Go build and module caches
uses: actions/cache@v6
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Tidy and vendor modules
run: go mod tidy && go mod vendor
- name: Run unit tests (${{ matrix.shard }})
shell: bash
run: |
SHARD="${{ matrix.shard }}"
COVER="-race -covermode=atomic -coverprofile=coverage-${SHARD}.out"
if [[ "$SHARD" == actor-* ]]; then
INDEX="${SHARD#actor-}"
TESTS=$(go test -mod=vendor ./actor -list '^Test' | grep '^Test' | sort | awk -v i="$INDEX" 'NR % 3 == i' | paste -sd'|' -)
if [ -z "$TESTS" ]; then
echo "actor test slice $INDEX is empty" >&2
exit 1
fi
go test -mod=vendor ${{ matrix.flags }} -run "^(${TESTS})$" $COVER ./actor/...
elif [ "$SHARD" = "core" ]; then
PACKAGES=$(go list ./... | grep -vE '/(actor|internal/cluster|internal/net|internal/remoteclient|remote|client|testkit|discovery|datacenter|goaktpb|mocks|internal/internalpb|bench|playground)(/|$)')
go test -mod=vendor ${{ matrix.flags }} $COVER $PACKAGES
else
go test -mod=vendor ${{ matrix.flags }} $COVER ${{ matrix.packages }}
fi
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-${{ matrix.shard }}.out
fail_ci_if_error: false
verbose: true
slug: Tochemey/goakt