-
Notifications
You must be signed in to change notification settings - Fork 1.1k
175 lines (169 loc) · 5.46 KB
/
ci.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
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
name: ci
on:
push:
branches:
- main
pull_request:
env:
# Default version of Go to use by CI workflows. This should be the latest
# release of Go; developers likely use the latest release in development and
# we want to catch any bugs (e.g. lint errors, race detection) with this
# release before they are merged. The Go compatibility guarantees ensure
# backwards compatibility with the previous two minor releases and we
# explicitly test our code for these versions so keeping this at prior
# versions does not add value.
DEFAULT_GO_VERSION: "~1.23.0"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0 ## Needed for "Set internal/tools/go.mod timestamp" step.
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
check-latest: true
cache-dependency-path: "**/go.sum"
- name: Tools cache
uses: actions/cache@v4
env:
cache-name: go-tools-cache
with:
path: .tools
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('./internal/tools/**') }}
# The step below is needed to not rebuild all the build tools.
- name: Set internal/tools/go.mod timestamp
run: |
filename="internal/tools/go.mod"
unixtime=$(git log -1 --format="%at" -- "${filename}")
touchtime=$(date -d @$unixtime +'%Y%m%d%H%M.%S')
touch -t ${touchtime} "${filename}"
ls -la --time-style=full-iso "${filename}"
- name: Generate
run: make generate
- name: Run linters
run: make license-check lint vanity-import-check verify-readmes verify-mods
- name: Build
run: make build
- name: Check clean repository
run: make check-clean-work-tree
test-bench:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
cache-dependency-path: "**/go.sum"
- name: Run benchmarks to check functionality
run: make test-bench
test-race:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
check-latest: true
cache-dependency-path: "**/go.sum"
- name: Run tests with race detector
run: make test-race
test-concurrent-safe:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
check-latest: true
cache-dependency-path: "**/go.sum"
- name: Run ConcurrentSafe tests multiple times with race detector
run: make test-concurrent-safe
test-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
check-latest: true
cache-dependency-path: "**/go.sum"
- name: Run coverage tests
run: make test-coverage
- name: Store coverage test output
uses: actions/upload-artifact@v4
with:
name: coverage-artifacts-${{ env.DEFAULT_GO_VERSION }}
path: coverage.txt
codecov:
runs-on: ubuntu-latest
needs: [test-coverage]
steps:
- uses: actions/download-artifact@v4
with:
pattern: coverage-artifacts-${{ env.DEFAULT_GO_VERSION }}
- name: Upload coverage report
uses: codecov/codecov-action@v4.6.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./coverage.txt
verbose: true
compatibility-test:
strategy:
matrix:
go-version: ["1.23.0", "~1.22.5"]
platform:
- os: ubuntu-latest
arch: "386"
- os: ubuntu-latest
arch: amd64
- os: macos-13
arch: amd64
- os: macos-latest
arch: arm64
- os: windows-latest
arch: "386"
- os: windows-latest
arch: amd64
# ARM64 compatibility tests are using actuated runners
# See https://github.com/open-telemetry/community/blob/main/docs/using-actuated.md
- os: actuated-arm64-2cpu-8gb
arch: arm64
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
check-latest: true
cache-dependency-path: "**/go.sum"
- name: Run tests
env:
GOARCH: ${{ matrix.platform.arch }}
run: make test-short
test-compatibility:
runs-on: ubuntu-latest
needs: [compatibility-test]
steps:
- name: Test if compatibility-test passed
run: |
echo ${{ needs.compatibility-test.result }}
test ${{ needs.compatibility-test.result }} == "success"