-
Notifications
You must be signed in to change notification settings - Fork 17
332 lines (292 loc) · 11.5 KB
/
code.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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
name: Code CI
on:
pull_request:
# Whenever a new branch or tag is created
# only on push for testing take out
create:
jobs:
make_boot:
strategy:
fail-fast: false
matrix:
include:
- platform: zynq
app: PandABox-no-fmc
- platform: zynqmp
app: xu5_st1-no-fmc
runs-on: ubuntu-latest
steps:
# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
path: PandABlocks-fpga
# require history to get back to last tag for version number of branches
fetch-depth: 0
- name: Checkout PandABlocks-rootfs
uses: actions/checkout@v2
with:
repository: PandABlocks/PandABlocks-rootfs
path: PandABlocks-rootfs
# Installation of go & temporary rclone patch applied until symlinks issue using rclone mount is resolved (see below):
# https://github.com/rclone/rclone/issues/2975
- name: Install rclone patch
run: bash PandABlocks-fpga/.github/scripts/rclone-patch.sh
# S3 bucket
- name: Mount Vivado S3 bucket
run: sudo bash PandABlocks-fpga/.github/scripts/mount-s3-bucket.sh ${{ secrets.VIVADO_S3_ACCESS_KEY_ID }} ${{ secrets.VIVADO_S3_SECRET_ACCESS_KEY }}
# Get container image
- name: login to github container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Mount in rclone bucket from runner into conatiner
- name: make boot
run: |
docker pull ghcr.io/pandablocks/pandablocks-dev-container:latest
docker run \
-v "${{ github.workspace }}:/repos" \
-v "${{ github.workspace }}/build:/build" \
-v "/scratch/Xilinx:/scratch/Xilinx" \
ghcr.io/pandablocks/pandablocks-dev-container:latest\
/bin/bash -c \
"cd PandABlocks-fpga && ln -s CONFIG.example CONFIG && make boot APP_NAME=${{ matrix.app }}"
# Make zpkg for FPGA apps
make_zpkg:
strategy:
fail-fast: false
matrix:
app: [
"PandABox-no-fmc",
"PandABox-fmc_24vio",
"PandABox-fmc_acq427",
"PandABox-fmc_acq430",
"PandABox-fmc_lback-sfp_lback",
"ZedBoard-no-fmc",
]
runs-on: ubuntu-latest
steps:
# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
path: PandABlocks-fpga
# require history to get back to last tag for version number of branches
fetch-depth: 0
- name: Checkout PandABlocks-rootfs
uses: actions/checkout@v2
with:
repository: PandABlocks/PandABlocks-rootfs
path: PandABlocks-rootfs
# Installation of go & temporary rclone patch applied until symlinks issue using rclone mount is resolved (see below):
# https://github.com/rclone/rclone/issues/2975
- name: Install rclone patch
run: bash PandABlocks-fpga/.github/scripts/rclone-patch.sh
# S3 bucket
- name: Mount Vivado S3 bucket
run: sudo bash PandABlocks-fpga/.github/scripts/mount-s3-bucket.sh ${{ secrets.VIVADO_S3_ACCESS_KEY_ID }} ${{ secrets.VIVADO_S3_SECRET_ACCESS_KEY }}
# Login into ghcr
- name: login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Mount in rclone bucket from runner into conatiner
- name: build carrier_ip and zpkg
run: |
docker pull ghcr.io/pandablocks/pandablocks-dev-container:latest
docker run \
-v "${{ github.workspace }}:/repos" \
-v "${{ github.workspace }}/build:/build" \
-v "/scratch/Xilinx:/scratch/Xilinx" \
ghcr.io/pandablocks/pandablocks-dev-container:latest\
/bin/bash -c \
"cd PandABlocks-fpga && ln -s CONFIG.example CONFIG && make carrier_ip APP_NAME=${{ matrix.app }} && make zpkg APP_NAME=${{ matrix.app }} "
# Artifacts
- name: Upload zpkg
uses: actions/upload-artifact@v2
with:
name: fgpa-zpkg-${{ matrix.app }}
path: ./build/PandA-FPGA/panda-fpga@*.zpg
# Seting up AWS runners for high memory apps
start-runner:
name: Start self hosted aws runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ${{ secrets.AWS_AMI_ID }}
ec2-instance-type: t3.xlarge
subnet-id: ${{ secrets.AWS_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_SECURITY_GROUP_ID }}
aws-resource-tags: >
[
{"Key": "Name", "Value": "ec2-github-runner"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
# Build rclone and mount S3 bucket
setup_aws_runner:
name: setup rclone and mount on runner
needs: start-runner
runs-on: ${{ needs.start-runner.outputs.label }}
steps:
# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
path: PandABlocks-fpga
# require history to get back to last tag for version number of branches
fetch-depth: 0
# Installation of go & temporary rclone patch applied until symlinks issue using rclone mount is resolved (see below):
# https://github.com/rclone/rclone/issues/2975
- name: Install rclone patch
run: bash PandABlocks-fpga/.github/scripts/rclone-patch.sh
# S3 bucket
- name: Mount Vivado S3 bucket
run: sudo bash PandABlocks-fpga/.github/scripts/mount-s3-bucket.sh ${{ secrets.VIVADO_S3_ACCESS_KEY_ID }} ${{ secrets.VIVADO_S3_SECRET_ACCESS_KEY }}
make_zpkg_aws:
strategy:
fail-fast: false
matrix:
app:
[
"xu5_st1-no-fmc",
"xu5_st1-fmc_acq430",
]
name: make zpkg on aws
needs:
- start-runner
- setup_aws_runner # required to start the main job when the runner is ready
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
steps:
# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
path: PandABlocks-fpga
# require history to get back to last tag for version number of branches
fetch-depth: 0
- name: Checkout PandABlocks-rootfs
uses: actions/checkout@v2
with:
repository: PandABlocks/PandABlocks-rootfs
path: PandABlocks-rootfs
# Login into ghcr
- name: login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Mount in rclone bucket from vm into conatiner
- name: build carrier_ip and zpkg
run: |
sudo docker pull ghcr.io/pandablocks/pandablocks-dev-container:latest
sudo docker run \
-v "${{ github.workspace }}:/repos" \
-v "${{ github.workspace }}/build:/build" \
-v "/scratch/Xilinx:/scratch/Xilinx" \
ghcr.io/pandablocks/pandablocks-dev-container:latest\
/bin/bash -c \
"cd PandABlocks-fpga && ln -s CONFIG.example CONFIG && make carrier_ip APP_NAME=${{ matrix.app }} && make zpkg APP_NAME=${{ matrix.app }}"
# Artifacts
- name: Upload zpkg
uses: actions/upload-artifact@v2
with:
name: fgpa-zpkg-${{ matrix.app }}
path: ./build/PandA-FPGA/panda-fpga@*.zpg
# Stop the AWS runner
stop-runner:
name: Stop self hosted EC2 runnner
needs:
- start-runner
- setup_aws_runner
- make_zpkg_aws
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
test:
runs-on: ubuntu-latest
steps:
# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
path: PandABlocks-fpga
# require history to get back to last tag for version number of branches
fetch-depth: 0
# Installation of go & temporary rclone patch applied until symlinks issue using rclone mount is resolved (see below):
# https://github.com/rclone/rclone/issues/2975
- name: Install rclone patch
run: bash PandABlocks-fpga/.github/scripts/rclone-patch.sh
# S3 bucket
- name: Mount Vivado S3 bucket
run: sudo bash PandABlocks-fpga/.github/scripts/mount-s3-bucket.sh ${{ secrets.VIVADO_S3_ACCESS_KEY_ID }} ${{ secrets.VIVADO_S3_SECRET_ACCESS_KEY }}
# Login into ghcr
- name: login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Run tests
- name: Make python and hdl tests
run: |
docker pull ghcr.io/pandablocks/pandablocks-dev-container:latest
docker run \
-v "${{ github.workspace }}:/repos" \
-v "${{ github.workspace }}/build:/build" \
-v "/scratch/Xilinx:/scratch/Xilinx" \
ghcr.io/pandablocks/pandablocks-dev-container:latest \
/bin/bash -c \
"cd PandABlocks-fpga && ln -s CONFIG.example CONFIG && make python_tests && make python_timing && \
make autogen && make hdl_test"
release:
needs: [ make_boot, make_zpkg, make_zpkg_aws, test ]
runs-on: ubuntu-latest
# make a release on every tag
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/download-artifact@v2
with:
name: zpkgs
path: zpkgs
- name: Github Release
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: softprops/action-gh-release@2d72d869af3bf23602f9593a1e3fd739b80ac1eb # v0.1.12
with:
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
files: zpkgs/*
body: See [Changelog](CHANGELOG.rst) for more details
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}