-
Notifications
You must be signed in to change notification settings - Fork 32
287 lines (282 loc) · 11.1 KB
/
build.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
name: Build installers
on: [push, pull_request]
jobs:
build-test-linux:
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
MYSQL_TEST_USER: root
MYSQL_TEST_PASS: root
MYSQL_TEST_ADDR: 127.0.0.1:3306
MYSQL_TEST_E2E_DB: e2e_test_db
steps:
- uses: actions/checkout@v3
- name: Set up MySQL
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE ${{ env.MYSQL_TEST_E2E_DB }};' -u${{ env.MYSQL_TEST_USER }} -p${{ env.MYSQL_TEST_PASS }}
- uses: actions/setup-go@v3
with:
go-version: '^1.21'
- name: Set up Go
run: |
go get -u golang.org/x/lint/golint
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('*_python/**') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python
run: |
pip install wheel pytest
pip install -e ./fleetspeak_python[test]
pip install -e ./frr_python
- name: Lint
# We want to address all golint warnings, except for
# https://github.com/golang/go/wiki/CodeReviewComments#doc-comments
# TODO(mbushkov): make golint and go vet checks actionable.
run: |
golint ./... | grep -v 'should have comment or be unexported' || true
go vet ./... || true
- name: Check generated protos
run: |
fleetspeak/generate_go_py_protos.sh
if [[ "$(git status --porcelain | grep .pb.go)" != "" ]]; then
echo "At least one generated proto file is not in sync with the committed generated proto files."
echo "Please run \`PATH=~/go/bin:\$PATH fleetspeak/generate_go_py_protos.sh\`."
echo "pip packages:"
pip freeze
echo "git diff:"
git diff
exit 1;
fi;
echo "git status is clean; generated protos are consistent"
- name: Build
run: |
fleetspeak/build.sh
- name: Test
run: |
fleetspeak/test.sh
- name: Check DEB installation
# Install the built package and check that the fleetspeak-config program
# doesn't error out.
timeout-minutes: 10
run: |
mysql -e 'DROP DATABASE ${{ env.MYSQL_TEST_E2E_DB }}; CREATE DATABASE ${{ env.MYSQL_TEST_E2E_DB }};' -u${{ env.MYSQL_TEST_USER }} -p${{ env.MYSQL_TEST_PASS }}
sudo apt-get update
sudo apt install debhelper devscripts fakeroot libparse-debcontrol-perl
cd fleetspeak
./build-pkgs.sh
# Pass through MySQL config environment variables to sudo.
sudo -E ./test-package.sh ./fleetspeak-server_$(cat ../VERSION)_amd64.deb ./fleetspeak-client_$(cat ../VERSION)_amd64.deb
- name: Build installers
run: |
DEPLOY_PATH=$GITHUB_WORKSPACE/deploy/
mkdir -p $DEPLOY_PATH
cd fleetspeak
cp ./fleetspeak-client_$(cat ../VERSION)_amd64.deb $DEPLOY_PATH
cp ./fleetspeak-server_$(cat ../VERSION)_amd64.deb $DEPLOY_PATH
# pypi doesn't support linux_x86_64, which is the plafrom name targeted by default.
# We generate manylinux1_x86_64 manylinux2010_x86_64 packages, which are supported.
# Create client wheel
dpkg --extract ./fleetspeak-client_$(cat ../VERSION)_amd64.deb client-package-root
python client-wheel/setup.py --package-root=client-package-root --version=$(cat ../VERSION) -- bdist_wheel --platform-name=manylinux1_x86_64
python client-wheel/setup.py --package-root=client-package-root --version=$(cat ../VERSION) -- bdist_wheel --platform-name=manylinux2010_x86_64
# Create server wheel
dpkg --extract ./fleetspeak-server_$(cat ../VERSION)_amd64.deb server-package-root
python server-wheel/setup.py --package-root=server-package-root --version=$(cat ../VERSION) -- bdist_wheel --platform-name=manylinux1_x86_64
python server-wheel/setup.py --package-root=server-package-root --version=$(cat ../VERSION) -- bdist_wheel --platform-name=manylinux2010_x86_64
# Copy wheels
cp dist/*.whl $DEPLOY_PATH
- if: ${{ github.event_name == 'push' }}
name: Upload installers to GitHub artifacts
uses: actions/upload-artifact@v2
with:
name: linux-installers
path: deploy/
retention-days: 1
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.21'
- uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install dependencies
run: |
powershell Install-WindowsFeature Net-Framework-Core
pip install wheel
- name: Build installers
shell: bash
run: |
go build -v -x -o fleetspeak-client.exe ./fleetspeak/src/client/client/client.go
cd fleetspeak/client-win
powershell -ExecutionPolicy Bypass -File ./build.ps1
cd ../..
DEPLOY_PATH=$GITHUB_WORKSPACE/deploy/
mkdir -p $DEPLOY_PATH
cp ${TMP}/fleetspeak-build-*/fleetspeak-pkg/fleetspeak-client-*.msi $DEPLOY_PATH
# Build client wheel
mkdir pkg-root
cp fleetspeak-client.exe pkg-root
cp fleetspeak/client-win/fleetspeak_lib.wxs pkg-root
python fleetspeak/client-wheel/setup.py --package-root pkg-root --version=$(cat VERSION) bdist_wheel
cp dist/*.whl $DEPLOY_PATH
ls -la $DEPLOY_PATH
- if: ${{ github.event_name == 'push' }}
name: Upload installers to GitHub artifacts
uses: actions/upload-artifact@v3
with:
name: windows-installers
path: deploy/
retention-days: 1
build-osx:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.21'
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install wheel
- name: Build installers
run: |
go build -o fleetspeak-client ./fleetspeak/src/client/client/client.go
DEPLOY_PATH=$GITHUB_WORKSPACE/deploy/
mkdir -p $DEPLOY_PATH
cd fleetspeak/client-mac
./build.sh ../../fleetspeak-client
sudo installer -pkg ./work/fleetspeak-client-*.pkg -target / -verbose
cd ../..
cp ./fleetspeak/client-mac/work/fleetspeak-client-*.pkg $DEPLOY_PATH
# Build client wheel
python fleetspeak/client-wheel/setup.py --package-root=fleetspeak/client-mac/work/pkg_root --version=$(cat VERSION) bdist_wheel
cp dist/*.whl $DEPLOY_PATH
ls -la $DEPLOY_PATH
- if: ${{ github.event_name == 'push' }}
name: Upload installers to GitHub artifacts
uses: actions/upload-artifact@v3
with:
name: osx-installers
path: deploy/
retention-days: 1
test-osx:
runs-on: macos-latest
env:
MYSQL_TEST_USER: root
MYSQL_TEST_ADDR: 127.0.0.1:3306
MYSQL_TEST_E2E_DB: e2e_test_db
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.21'
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install wheel pytest
go get -v -t ./...
- uses: ankane/setup-mysql@v1
with:
database: ${{ env.MYSQL_TEST_E2E_DB }}
- name: Build
run: |
pip install -e ./fleetspeak_python[test]
pip install -e ./frr_python
fleetspeak/build.sh
- name: Test
run: |
fleetspeak/test.sh
test-windows:
runs-on: windows-latest
env:
GOPATH: ${{ github.workspace }}
GO111MODULE: off
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/google/fleetspeak
steps:
- uses: actions/setup-go@v3
with:
go-version: '^1.21'
- uses: actions/checkout@v3
with:
path: ${{ env.GOPATH }}/src/github.com/google/fleetspeak
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
shell: bash
run: |
# TODO: The dependency installation fails, but good enough to make the tests pass.
# Ideally, required dependencies should be installed in a non-hacky, proper way.
go get -v -t ./... || echo "Dependency installation failed, continuing anyway ¯\_(ツ)_/¯"
pip install wheel
- name: Build
shell: bash
run: |
go build -o fleetspeak/src/client/socketservice/testclient/testclient.exe github.com/google/fleetspeak/fleetspeak/src/client/socketservice/testclient
go build -o fleetspeak/src/client/daemonservice/testclient/testclient.exe github.com/google/fleetspeak/fleetspeak/src/client/daemonservice/testclient
pip install -e ./fleetspeak_python
- name: Test
shell: bash
run: |
go test -race github.com/google/fleetspeak/fleetspeak/src/common/... --timeout 180s
go test -race github.com/google/fleetspeak/fleetspeak/src/client/... --timeout 180s
# TODO: Move src/windows to src/client.
go test -race github.com/google/fleetspeak/fleetspeak/src/windows/... --timeout 180s
upload-installers:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-22.04
env:
GCS_BUCKET: autobuilds-fleetspeak
needs:
- build-test-linux
- build-windows
- build-osx
- test-osx
- test-windows
steps:
- uses: actions/checkout@v3
- name: Download installers from GitHub artifacts
id: download
uses: actions/download-artifact@v3
with:
path: ~/_artifacts
- name: Merge artifacts
run: |
BUILD_TIMESTAMP=$(git show -s --format=%ci ${GITHUB_SHA} | sed -e "s/[ :\\+]/_/g")
DEPLOY_PATH=$HOME/deploy/${BUILD_TIMESTAMP}_${GITHUB_SHA}/
echo "DEPLOY_PATH=$DEPLOY_PATH" >> $GITHUB_ENV
mkdir -p $DEPLOY_PATH
ls -la ${{ steps.download.outputs.download-path }}/*
mv -v ${{ steps.download.outputs.download-path }}/*/* $DEPLOY_PATH
ls -la $DEPLOY_PATH
echo "BUILD_TIMESTAMP=${BUILD_TIMESTAMP}" >> $GITHUB_ENV
- name: Authenticate
uses: 'google-github-actions/auth@v1'
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
export_environment_variables: true
- name: Upload installers to GCS
uses: google-github-actions/[email protected]
with:
path: ${{ env.DEPLOY_PATH }}
destination: ${{ env.GCS_BUCKET }}/${{ env.BUILD_TIMESTAMP }}_${{ github.sha }}
# Omit `path` (e.g. /home/runner/deploy/) in final GCS path.
parent: false