-
Notifications
You must be signed in to change notification settings - Fork 1
154 lines (133 loc) · 4.33 KB
/
ci.yml
File metadata and controls
154 lines (133 loc) · 4.33 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
name: CI
on:
push:
branches: [ '*' ]
pull_request:
branches: [ main ]
jobs:
goimports:
name: goimports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Check goimports
run: |
go install golang.org/x/tools/cmd/goimports@latest
files=$(goimports -local lesiw.io -l .)
if [ -n "$files" ]; then
echo "The following files need goimports -local lesiw.io:"
echo "$files"
exit 1
fi
tidy:
name: go mod tidy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Check go mod tidy
run: |
go mod tidy
git diff --exit-code go.mod go.sum
test:
needs: [goimports, tidy]
name: ${{ matrix.os }} (${{ matrix.go-version }}) ${{ matrix.target }} ${{ matrix.race && '(race)' || '' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ['stable', 'oldstable']
race: [true, false]
target: ['main', 'example']
steps:
- name: Configure git for Windows
if: runner.os == 'Windows'
run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Run main tests
if: matrix.target == 'main' && matrix.race
run: go test -race -v ./...
- name: Run main tests
if: matrix.target == 'main' && !matrix.race
env:
CGO_ENABLED: 0
run: go test -v ./...
- name: Run example tests
if: matrix.target == 'example' && matrix.race
working-directory: internal/example/go
run: go test -race -v
- name: Run example tests
if: matrix.target == 'example' && !matrix.race
env:
CGO_ENABLED: 0
working-directory: internal/example/go
run: go test -v
- name: Run example with container support
if: matrix.target == 'example' && !matrix.race && matrix.os == 'ubuntu-latest'
working-directory: internal/example/go
run: go run . -ctr
test-alpine:
needs: [goimports, tidy]
name: Alpine (${{ matrix.go-version }})
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['stable', 'oldstable']
steps:
- uses: actions/checkout@v4
- name: Get Go version
id: go-version
run: |
if [ "${{ matrix.go-version }}" = "stable" ]; then
VERSION=$(curl -s 'https://go.dev/VERSION?m=text' | head -1)
else
VERSION=$(curl -s 'https://go.dev/dl/?mode=json' | jq -r '.[1].version')
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Test in Alpine container
run: |
docker run --rm -v $PWD:/work -w /work alpine:latest sh -c '
apk add --no-cache curl tar
VERSION="${{ steps.go-version.outputs.version }}"
curl -L "https://go.dev/dl/${VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xz
export PATH=/usr/local/go/bin:$PATH
go test -v ./...
'
test-freebsd:
needs: [goimports, tidy]
name: FreeBSD (${{ matrix.go-version }})
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['stable', 'oldstable']
steps:
- uses: actions/checkout@v4
- name: Get Go version
id: go-version
run: |
if [ "${{ matrix.go-version }}" = "stable" ]; then
VERSION=$(curl -s 'https://go.dev/VERSION?m=text' | head -1)
else
VERSION=$(curl -s 'https://go.dev/dl/?mode=json' | jq -r '.[1].version')
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Test on FreeBSD VM
uses: vmactions/freebsd-vm@v1
with:
run: |
pkg install -y curl jq
VERSION="${{ steps.go-version.outputs.version }}"
curl -L "https://go.dev/dl/${VERSION}.freebsd-amd64.tar.gz" | tar -C /usr/local -xz
export PATH=/usr/local/go/bin:$PATH
go test -v ./...