-
Notifications
You must be signed in to change notification settings - Fork 103
275 lines (238 loc) · 8.21 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
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
name: ci
on:
workflow_dispatch:
push:
branches: [main, master]
tags: '*'
pull_request:
branches: '**'
merge_group:
types: [checks_requested]
jobs:
build_and_test:
name: launcher
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Consider changing this sometime
matrix:
os:
- ubuntu-20.04
- macos-12
- windows-latest
steps:
- name: Check out code
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # need a full checkout for `git describe`
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
check-latest: true
cache: false
id: go
# use bash, because the powershell syntax is different and this is a cross platform workflow
- id: go-cache-paths
shell: bash
run: |
echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
- name: Go Build Cache
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Get dependencies
run: make deps
- name: Set up zig
if: ${{ contains(matrix.os, 'ubuntu') }}
uses: goto-bus-stop/setup-zig@v2
- name: Build
run: make -j2 github-build
- name: Check macOS build target
if: contains(matrix.os, 'macos')
# this uses grep's exit code
run: otool -l build/launcher | grep -A1 "minos 11"
- name: Lipo
run: make github-lipo
if: ${{ contains(matrix.os, 'macos') }}
- name: App Bundle
run: make github-launcherapp
if: ${{ contains(matrix.os, 'macos') }}
- name: Test
run: make test
- name: Cache build output
uses: actions/cache@v4
with:
path: ./build
key: ${{ runner.os }}-${{ github.run_id }}
enableCrossOsArchive: true
# upload coverage here, because we don't cache it with the build
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-coverage.out
path: ./coverage.out
if-no-files-found: error
# this job captures the version of launcher on one of the runners then that version is
# compared to the version of all other runners during exec testing. This is to ensure
# that the version of launcher is the same across all runners.
version_baseline:
name: Version Baseline
runs-on: ubuntu-20.04
needs: build_and_test
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: cache restore build output
uses: actions/cache/restore@v4
with:
path: ./build
key: ${{ runner.os }}-${{ github.run_id }}
enableCrossOsArchive: true
- id: version
name: Launcher Version
working-directory: build
shell: bash
run: ./launcher --version 2>/dev/null | awk '/version /{print "version="$4}' >> "$GITHUB_OUTPUT"
exec_testing:
name: Exec Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
# See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
- ubuntu-20.04
- ubuntu-22.04
- macos-12
- macos-13
- macos-14
- windows-2019
- windows-2022
needs: version_baseline
steps:
- name: cache restore build output
uses: actions/cache/restore@v4
with:
path: ./build
key: ${{ runner.os }}-${{ github.run_id }}
enableCrossOsArchive: true
- name: Launcher Version
working-directory: build
shell: bash
run: |
./launcher --version
thisVersion=$(./launcher --version 2>/dev/null | grep "version" | awk '{print $4}')
baseVersion="${{ needs.version_baseline.outputs.version }}"
if [[ "$thisVersion" != "$baseVersion" ]]; then
printf "launcher version %s does not match baseline version %s" "$thisVersion" "$baseVersion"
exit 1
fi
- name: Download Osquery
working-directory: build
run: ./launcher download-osquery --directory .
- name: Osquery Version
working-directory: build
run: ./osqueryd --version
- name: Launcher Doctor
working-directory: build
run: ./launcher doctor
# If the prior exec tests suceeded, this grabs the cached things, and moves them to artifacts. We ought
# be able to do this entirely on ubuntu, so let's try!
store_artifacts:
name: Store Artifacts
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
artifactos:
# artifactos needs to match the runner.os set by the builds. (Which is not quite the same as matrix.os)
- linux
- macos
- windows
needs: exec_testing
steps:
- name: cache restore build output
uses: actions/cache/restore@v4
with:
path: ./build
key: ${{ matrix.artifactos }}-${{ github.run_id }}
enableCrossOsArchive: true
- name: Upload Build
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifactos }}-build
path: build/
if-no-files-found: error
package_builder_test:
name: package_builder
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-20.04
- macos-12
- windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # need a full checkout for `git describe`
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
check-latest: true
cache: false
id: go
- id: go-cache-paths
shell: bash
run: |
echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
- name: Go Build Cache
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- run: make deps
- id: build
run: make package-builder
- name: package
id: run-package-builder
run: ${{ steps.build.outputs.binary }} make --i-am-a-kolide-customer --debug --hostname=localhost --enroll_secret=secret --launcher_version=nightly --osquery_version=nightly --output_dir=./
- name: Test install macOS
if: ${{ contains(matrix.os, 'macos') }}
run: |
# Check that we can install
sudo installer -dumplog -pkg ./launcher.darwin-launchd-pkg.pkg -target /
# Quick check that at least a couple of the files we expect now exist
if [ ! -f /Library/LaunchDaemons/com.launcher.launcher.plist ]; then echo "missing launchd entry" && exit 1; fi
if [ ! -f /usr/local/launcher/osquery.app/Contents/MacOS/osqueryd ]; then echo "missing osqueryd binary" && exit 1; fi
if [ ! -L /usr/local/launcher/bin/osqueryd ]; then echo "missing osquery symlink" && exit 1; fi
if [ ! -e /usr/local/launcher/bin/osqueryd ]; then echo "osquery symlink is present but broken" && exit 1; fi
if [ ! -f /usr/local/launcher/Kolide.app/Contents/MacOS/launcher ]; then echo "missing launcher binary" && exit 1; fi
if [ ! -L /usr/local/launcher/bin/launcher ]; then echo "missing launcher symlink" && exit 1; fi
if [ ! -e /usr/local/launcher/bin/launcher ]; then echo "launcher symlink is present but broken" && exit 1; fi
# This job is here as a github status check -- it allows us to move
# the merge dependency from being on all the jobs to this single
# one.
ci_mergeable:
runs-on: ubuntu-latest
steps:
- run: true
needs:
- build_and_test
- package_builder_test
- exec_testing