forked from SumoLogic/sumologic-otel-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
307 lines (257 loc) · 9.9 KB
/
dev_builds.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
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
name: Dev builds
on:
push:
branches:
- main
- 'dev-build/*'
jobs:
# Add lint to dev builds as that's the only way for cache to be shared across branches.
# https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key
lint:
name: Lint (golangci-lint)
runs-on: ubuntu-20.04
strategy:
matrix:
arch_os: [ 'linux_amd64' ]
steps:
- uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: '1.18'
# As described in
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@v3
with:
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: ${{matrix.arch_os}}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{matrix.arch_os}}-go-
- uses: actions/cache@v3
with:
path: |
/home/runner/.cache/golangci-lint
key: ${{matrix.arch_os}}-golangcilint-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{matrix.arch_os}}-golangcilint-
- name: Install golangci-lint
run: make install-golangci-lint
- name: Add opentelemetry-collector-builder installation dir to PATH
run: echo "$HOME/bin" >> $GITHUB_PATH
- name: Run golangci-lint
run: make golint
build:
name: Build
runs-on: ${{ matrix.runs_on }}
strategy:
matrix:
include:
- arch_os: linux_amd64
runs_on: ubuntu-20.04
- arch_os: linux_arm64
runs_on: ubuntu-20.04
- arch_os: darwin_amd64
runs_on: macos-latest
- arch_os: darwin_arm64
runs_on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Fetch current branch
run: ./ci/fetch_current_branch.sh
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: '1.18'
# As described in
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@v3
with:
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
/Users/runner/go/pkg/mod
/Users/runner/Library/Caches/go-build
key: ${{matrix.arch_os}}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{matrix.arch_os}}-go-
- name: Add opentelemetry-collector-builder installation dir to PATH
run: echo "$HOME/bin" >> $GITHUB_PATH
- name: Install opentelemetry-collector-builder
run: make install-builder
working-directory: ./otelcolbuilder
- name: Build
run: make otelcol-sumo-${{matrix.arch_os}}
working-directory: ./otelcolbuilder
- name: Show included modules
working-directory: ./otelcolbuilder/cmd
run: |
go version -m otelcol-sumo-${{matrix.arch_os}} | \
grep -E "/(receiver|exporter|processor|extension)/" | \
tee otelcol-sumo-${{matrix.arch_os}}_modules.txt
# TODO:
# Move that out to a separate job and run on a corresponding's OS runner.
# - name: Run the binary
# run: ./otelcol-sumo-${{matrix.arch_os}} --version
# working-directory: ./otelcolbuilder/cmd/
- name: Store binary as action artifact
uses: actions/upload-artifact@v3
with:
name: otelcol-sumo-${{matrix.arch_os}}
path: ./otelcolbuilder/cmd/otelcol-sumo-${{matrix.arch_os}}
if-no-files-found: error
- name: Store list of included modules as action artifact
uses: actions/upload-artifact@v3
with:
name: otelcol-sumo-${{matrix.arch_os}}_modules.txt
path: ./otelcolbuilder/cmd/otelcol-sumo-${{matrix.arch_os}}_modules.txt
if-no-files-found: error
# pipeline to build FIPS compliance binary on Go+BoringCrypto
build-fips:
name: Build
runs-on: ubuntu-20.04
strategy:
matrix:
go: [ '1.18.2b7' ]
arch_os: [ 'linux_amd64']
steps:
- uses: actions/checkout@v3
- name: Fetch current branch
run: ./ci/fetch_current_branch.sh
- name: Install Go+BoringCrypto
run: |
curl -LJ "https://go-boringcrypto.storage.googleapis.com/go${{ matrix.go }}.linux-amd64.tar.gz" -o go.linux-amd64.tar.gz \
&& sudo rm -rf /usr/local/go \
&& sudo tar -C /usr/local -xzf go.linux-amd64.tar.gz \
&& sudo rm go.linux-amd64.tar.gz \
&& sudo ln -s /usr/local/go/bin/go /usr/local/bin
# As described in
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@v3
with:
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
/Users/runner/go/pkg/mod
/Users/runner/Library/Caches/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Add opentelemetry-collector-builder installation dir to PATH
run: echo "$HOME/bin" >> $GITHUB_PATH
- name: Install opentelemetry-collector-builder
run: make install-builder
working-directory: ./otelcolbuilder
- name: Build
run: make otelcol-sumo-${{matrix.arch_os}} FIPS_SUFFIX="-fips" CGO_ENABLED=1
working-directory: ./otelcolbuilder
- name: Show included modules
working-directory: ./otelcolbuilder/cmd
run: |
go version -m otelcol-sumo-fips-${{matrix.arch_os}} | \
grep -E "/(receiver|exporter|processor|extension)/" | \
tee otelcol-sumo-fips-${{matrix.arch_os}}_modules.txt
- name: Show BoringSSL symbols
working-directory: ./otelcolbuilder/cmd
run: |
go tool nm otelcol-sumo-fips-${{matrix.arch_os}} | \
grep "_Cfunc__goboringcrypto_"
- name: Store binary as action artifact
uses: actions/upload-artifact@v3
with:
name: otelcol-sumo-fips-${{matrix.arch_os}}
path: ./otelcolbuilder/cmd/otelcol-sumo-fips-${{matrix.arch_os}}
if-no-files-found: error
- name: Store list of included modules as action artifact
uses: actions/upload-artifact@v3
with:
name: otelcol-sumo-fips-${{matrix.arch_os}}_modules.txt
path: ./otelcolbuilder/cmd/otelcol-sumo-fips-${{matrix.arch_os}}_modules.txt
if-no-files-found: error
build-container-images:
name: Build container
runs-on: ubuntu-20.04
needs:
- build
- build-fips
strategy:
matrix:
arch_os: [ 'linux_amd64', 'linux_arm64' ]
steps:
- uses: actions/checkout@v3
- name: Extract tag
id: extract_tag
run: echo "::set-output name=tag::$(git rev-parse HEAD)"
- name: Print tag
run: echo "Running dev build for ${{ steps.extract_tag.outputs.tag }}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.0.0
- name: Set up Buildx
id: buildx
uses: docker/setup-buildx-action@v2.0.0
- name: Show Buildx platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to Open Source ECR
run: make login
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
- name: Download FIPS binary action artifact from build phase
if: matrix.arch_os == 'linux_amd64'
uses: actions/download-artifact@v3
with:
name: otelcol-sumo-fips-${{matrix.arch_os}}
- name: Build and push FIPS image to Open Source ECR
if: matrix.arch_os == 'linux_amd64'
run: |
cp otelcol-sumo-fips-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-multiplatform-dev-fips \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }}-fips \
PLATFORM=${{ matrix.arch_os }} \
LATEST_TAG_FIPS_SUFFIX="-fips"
- name: Download binary action artifact from build phase
uses: actions/download-artifact@v3
with:
name: otelcol-sumo-${{ matrix.arch_os }}
- name: Build and push image to Open Source ECR
run: |
cp otelcol-sumo-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-multiplatform-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORM=${{ matrix.arch_os }}
push-docker-manifest:
name: Push joint container manifest
runs-on: ubuntu-20.04
needs:
- build-container-images
steps:
- uses: actions/checkout@v3
- name: Extract tag
id: extract_tag
run: echo "::set-output name=tag::$(git rev-parse HEAD)"
- name: Print tag
run: echo "Running dev build for ${{ steps.extract_tag.outputs.tag }}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.0.0
- name: Set up Buildx
id: buildx
uses: docker/setup-buildx-action@v2.0.0
- name: Show Buildx platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to Open Source ECR
run: make login
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
- name: Push joint FIPS container manifest for all platforms to Open Source ECR
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }}-fips \
PLATFORMS="linux/amd64" \
LATEST_TAG_FIPS_SUFFIX="-fips"
- name: Push joint container manifest for all platforms to Open Source ECR
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
PLATFORMS="linux/amd64 linux/arm64"