-
Notifications
You must be signed in to change notification settings - Fork 89
132 lines (112 loc) · 3.37 KB
/
go.yml
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
name: go
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
env:
# Use the local toolchain. Never download.
GOTOOLCHAIN: local
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.23.x
- name: go.mod tidy
run: go mod tidy && git diff --exit-code
- name: license header
run: go run github.com/elastic/[email protected] -d
- name: cross-compile
run: .ci/scripts/check-cross-compile.sh
test:
needs: check
strategy:
matrix:
go:
- 1.23.x
- 1.22.x
os:
- macos-12
- macos-13
- macos-14
- windows-2019
- windows-2022
- ubuntu-20.04
- ubuntu-22.04
cgo:
- cgo
- nocgo
exclude:
# Exclude cgo testing for platforms that don't use CGO.
- {cgo: cgo, os: windows-2019}
- {cgo: cgo, os: windows-2022}
- {cgo: cgo, os: ubuntu-20.04}
- {cgo: cgo, os: ubuntu-22.04}
# Limit the OS variants tested with the earliest supported Go version (save resources).
- {go: 1.22.x, os: macos-12}
- {go: 1.22.x, os: macos-13}
- {go: 1.22.x, os: windows-2019}
- {go: 1.22.x, os: ubuntu-22.04}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
id: setup_go
with:
go-version: ${{ matrix.go }}
- name: Set GO_VERSION
run: echo "GO_VERSION=${{ steps.setup_go.outputs.go-version }}" >> $GITHUB_ENV
- name: Set CGO_ENABLED=1
if: matrix.cgo == 'cgo'
run: echo "CGO_ENABLED=1" >> $GITHUB_ENV
- name: Set CGO_ENABLED=0
if: matrix.cgo == 'nocgo'
run: echo "CGO_ENABLED=0" >> $GITHUB_ENV
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
if: github.event_name == 'pull_request'
with:
version: latest
only-new-issues: true
args: --timeout=5m
# Don't cache or restore ~/go/pkg. It conflicts with caching from setup-go@v4.
skip-pkg-cache: true
- name: Test
if: runner.os != 'Windows'
run: .ci/scripts/test.sh
- name: Test
if: runner.os == 'Windows'
run: .ci/scripts/test.bat
test-freebsd:
runs-on: ubuntu-latest
env:
# Only GITHUB_* are passed into the VM.
GITHUB_GOLANG_VERSION: 1.23.0
name: test (1.23.0, freebsd-14.0, cgo)
steps:
- uses: actions/checkout@v4
- name: Test
# TODO: Skip until freebsd provider is merged. Then this 'if' should be removed.
if: ${{ hashFiles('providers/freebsd/') != '' }}
id: test
uses: vmactions/freebsd-vm@d7b8fcc7711aa41ad45e8d9b737cf90f035a7e3d #v1.1.3
with:
usesh: true
prepare: |
freebsd-version
pwd
ls -lah
whoami
pkg install -y curl
curl -sL -o /usr/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v0.5.2/gvm-freebsd-amd64
chmod +x /usr/bin/gvm
eval "$(gvm ${GITHUB_GOLANG_VERSION})"
go version
run: |
eval "$(gvm ${GITHUB_GOLANG_VERSION})"
go test -v ./...