This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
189 lines (187 loc) · 5.39 KB
/
build-and-test.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: build-and-test
on:
push:
branches: [ main ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
pull_request:
env:
TEST_RESULTS: testbed/tests/results/junit/results.xml
# See: https://github.com/actions/cache/issues/810#issuecomment-1222550359
# Cache downloads for this workflow consistently run in under 1 minute
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
setup-environment:
timeout-minutes: 30
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21.9"
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Install dependencies
# if: steps.go-cache.outputs.cache-hit != 'true'
run: make -j2 gomoddownload
- name: Install Tools
# if: steps.go-cache.outputs.cache-hit != 'true'
run: make install-builder-tools
lint-matrix:
strategy:
matrix:
group:
- exporter
- extension
runs-on: ubuntu-latest
needs: [setup-environment]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "~1.21.9"
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Install dependencies
# if: steps.go-cache.outputs.cache-hit != 'true'
run: make -j2 gomoddownload
- name: Install Tools
# if: steps.go-cache.outputs.cache-hit != 'true'
run: make install-builder-tools
- name: Cache Lint Build
uses: actions/cache@v3
with:
path: ~/.cache/go-build
key: go-lint-build-${{ matrix.group }}-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Lint
run: make -j2 golint GROUP=${{ matrix.group }}
lint:
if: ${{ github.actor != 'dependabot[bot]' && always() }}
runs-on: ubuntu-latest
needs: [setup-environment, lint-matrix]
steps:
- name: Print result
run: echo ${{ needs.lint-matrix.result }}
- name: Interpret result
run: |
if [[ success == ${{ needs.lint-matrix.result }} ]]
then
echo "All matrix jobs passed!"
else
echo "One or more matrix jobs failed."
false
fi
unittest-matrix:
strategy:
matrix:
go-version: ["~1.22.2", "~1.21.9"] # 1.20 is interpreted as 1.2 without quotes
group:
- processor
- exporter
- extension
- internal
runs-on: ubuntu-latest
needs: [setup-environment]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Cache Go
id: go-cache
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Install dependencies
#if: steps.go-cache.outputs.cache-hit != 'true'
run: make -j2 gomoddownload
- name: Install Tools
#if: steps.go-cache.outputs.cache-hit != 'true'
run: make install-tools
- name: Cache Test Build
uses: actions/cache@v3
with:
path: ~/.cache/go-build
key: go-test-build-${{ runner.os }}-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
- name: Run Unit Tests
run: make gotest GROUP=${{ matrix.group }}
cross-compile:
runs-on: ubuntu-latest
needs: [lint]
strategy:
matrix:
os:
- darwin
- linux
- windows
arch:
- 386
- amd64
- arm
- arm64
- ppc64le
include:
- os: linux
- arch: arm
- arm: 7
exclude:
- os: darwin
arch: 386
- os: darwin
arch: arm
- os: darwin
arch: ppc64le
- os: windows
arch: arm
- os: windows
arch: arm64
- os: windows
arch: ppc64le
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ~1.21.9
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Install dependencies
# if: steps.go-cache.outputs.cache-hit != 'true'
run: make -j2 gomoddownload
- name: Install Tools
# if: steps.go-cache.outputs.cache-hit != 'true'
run: make install-builder-tools
- name: Build Collector ${{ matrix.binary }}
run: make GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} build-openinsight