-
Notifications
You must be signed in to change notification settings - Fork 8
155 lines (128 loc) · 4.22 KB
/
interface2_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
name: Build interface2
on:
push:
paths:
- interface2/**
- .github/workflows/interface2_build.yml
# Required by aws-actions/configure-aws-credentials for GitHub OIDC.
permissions:
id-token: write
contents: read
jobs:
test_fpga:
name: Test FPGA
runs-on: ubuntu-latest
defaults:
run:
working-directory: interface2/fpga
steps:
- uses: actions/checkout@v3
- name: Install Icarus Verilog
run: |
sudo apt-get update
sudo apt-get install iverilog
- name: Run tests
run: make tests
build_fpga:
name: Build FPGA
needs: test_fpga
runs-on: ubuntu-latest
defaults:
run:
working-directory: interface2/fpga
steps:
- uses: actions/checkout@v3
with:
# All history is required to determine the bitstream source SHA, otherwise
# it may be unnecessarily rebuilt.
fetch-depth: 0
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_IAM_ROLE }}
aws-region: us-east-1
- name: Get bitstream cache key
run: |
BITSTREAM_SOURCE_SHA=$(git log -n 1 --format=%H rtl)
BITSTREAM_CACHE_KEY=interface2/fpga/$BITSTREAM_SOURCE_SHA.zip
echo Bitstream source SHA is $BITSTREAM_SOURCE_SHA
echo "BITSTREAM_SOURCE_SHA=$BITSTREAM_SOURCE_SHA" >> $GITHUB_ENV
echo "BITSTREAM_CACHE_KEY=$BITSTREAM_CACHE_KEY" >> $GITHUB_ENV
- name: Check bitstream cache
run: |
if aws s3api head-object --bucket ${{ vars.BITSTREAM_CACHE_BUCKET }} --key ${{ env.BITSTREAM_CACHE_KEY }}; then
echo Cached bitstream exists
echo "BITSTREAM_CACHE_EXISTS=true" >> $GITHUB_ENV
else
echo Cached bitstream does not exist
echo "BITSTREAM_CACHE_EXISTS=false" >> $GITHUB_ENV
fi
- name: Login to AWS ECR
if: env.BITSTREAM_CACHE_EXISTS == 'false'
id: aws_ecr_login
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Prepare iCEcube2
if: env.BITSTREAM_CACHE_EXISTS == 'false'
run: |
ICECUBE2_IMAGE=$REGISTRY/icecube2:latest
echo "ICECUBE2_IMAGE=$ICECUBE2_IMAGE" >> $GITHUB_ENV
docker pull $ICECUBE2_IMAGE
env:
REGISTRY: ${{ steps.aws_ecr_login.outputs.registry }}
- name: Build bitstream
if: env.BITSTREAM_CACHE_EXISTS == 'false'
run: make rtl
env:
ICECUBE2_MAC_ADDRESS: ${{ secrets.ICECUBE2_MAC_ADDRESS }}
- name: Cache bitstream
if: env.BITSTREAM_CACHE_EXISTS == 'false'
run: |
cd rtl
zip cache.zip top.bin top_timing_report.txt
aws s3 cp cache.zip s3://${{ vars.BITSTREAM_CACHE_BUCKET }}/${{ env.BITSTREAM_CACHE_KEY }}
rm cache.zip
- name: Download cached bitstream
if: env.BITSTREAM_CACHE_EXISTS == 'true'
run: |
cd rtl
aws s3 cp s3://${{ vars.BITSTREAM_CACHE_BUCKET }}/${{ env.BITSTREAM_CACHE_KEY }} cache.zip
unzip cache.zip
rm cache.zip
- name: Attach bitstream
uses: actions/upload-artifact@v3
with:
name: fpga_bitstream
path: |
interface2/fpga/rtl/top.bin
interface2/fpga/rtl/top_timing_report.txt
build_firmware:
name: Build Firmware
needs: build_fpga
runs-on: ubuntu-latest
defaults:
run:
working-directory: interface2/firmware
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install platformio
- name: Download bitstream
uses: actions/[email protected]
with:
name: fpga_bitstream
path: interface2/fpga/rtl
- name: Build firmware
run: pio run
- name: Attach firmware
uses: actions/upload-artifact@v3
with:
name: firmware
path: interface2/firmware/.pio/build/default/firmware.bin