-
Notifications
You must be signed in to change notification settings - Fork 103
242 lines (206 loc) · 6.74 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
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@v3
with:
fetch-depth: 0 # need a full checkout for `git describe`
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: './go.mod'
check-latest: true
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@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Get dependencies
run: make deps
- name: Run govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest; govulncheck ./...
- 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@v3
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@v3
with:
name: ${{ runner.os }}-coverage.out
path: coverage.out
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#supported-software
- ubuntu-20.04
- ubuntu-22.04
- macos-11
- macos-12
- macos-13
- windows-2019
- windows-2022
needs: build_and_test
steps:
- name: cache restore build output
uses: actions/cache/restore@v3
with:
path: ./build
key: ${{ runner.os }}-${{ github.run_id }}
enableCrossOsArchive: true
- name: Launcher Version
working-directory: build
run: ./launcher --version
- 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@v3
with:
path: ./build
key: ${{ matrix.artifactos }}-${{ github.run_id }}
enableCrossOsArchive: true
- name: Upload Build
uses: actions/upload-artifact@v3
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@v3
with:
fetch-depth: 0 # need a full checkout for `git describe`
- uses: actions/setup-go@v3
with:
go-version-file: './go.mod'
check-latest: true
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@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v3
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 -debug --hostname=localhost --enroll_secret=secret --launcher_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/bin/osqueryd ]; then echo "missing osquery binary" && 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