-
Notifications
You must be signed in to change notification settings - Fork 37
211 lines (184 loc) · 7.19 KB
/
build-test-verilator.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
# docs: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Verilator
on:
push:
branches: ["main", "dev-goog", "dev-msft"]
workflow_call:
workflow_dispatch:
env:
CARGO_INCREMENTAL: 0
SCCACHE_VERSION: 0.3.3
RISCV_VERSION: v12.1.0
VERILATOR_VERSION: v5.012
PKG_CONFIG_PATH: /opt/verilator/share/pkgconfig
SCCACHE_GHA_CACHE_TO: sccache-verilator-10000
SCCACHE_GHA_CACHE_FROM: sccache-verilator-
# Change this to a new random value if you suspect the cache is corrupted
SCCACHE_C_CUSTOM_CACHE_BUSTER: f3e6951f0c1e
jobs:
build_tools:
name: Build Tools
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- name: Restore Cargo index
uses: actions/cache/restore@v3
id: cargo_index_restore
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}-${{ hashFiles('Cargo.lock') }}
- name: Restore sccache binary
uses: actions/cache/restore@v3
id: sccache_bin_restore
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Install sccache
if: steps.sccache_bin_restore.outputs.cache-hit != 'true'
run: |
cargo install sccache --locked --version ${SCCACHE_VERSION} --no-default-features --features=gha
- name: Save sccache binary
uses: actions/cache/save@v3
if: steps.sccache_bin_restore.outputs.cache-hit != 'true'
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Configure sccache
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Restore verilator dir
uses: actions/cache/restore@v3
id: verilator_restore
with:
path: /opt/verilator
key: verilator-${{ env.VERILATOR_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Install verilator
if: steps.verilator_restore.outputs.cache-hit != 'true'
run: |
sudo apt-get install flex bison libfl2 libfl-dev help2man
cd /tmp/
git clone -b "${VERILATOR_VERSION}" https://github.com/verilator/verilator
cd verilator
autoconf
./configure --prefix=/opt/verilator CXX="sccache g++"
make -j6
sudo make install
- name: Save verilator dir
uses: actions/cache/save@v3
if: steps.verilator_restore.outputs.cache-hit != 'true'
with:
path: /opt/verilator
key: verilator-${{ env.VERILATOR_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Setup verilator path
run: |
echo /opt/verilator/bin >> $GITHUB_PATH
- name: Restore Risc V Toolchain
uses: actions/cache/restore@v3
id: riscv_restore
with:
path: /opt/riscv
key: riscv-${{ env.RISCV_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Install Risc V Toolchain
if: steps.riscv_restore.outputs.cache-hit != 'true'
run: |
# Building from source takes around 6.65 GB of disk and download size
wget -O toolchain.tar.gz https://github.com/chipsalliance/caliptra-tools/releases/download/gcc-v12.1.0/riscv64-unknown-elf.gcc-12.1.0.tar.gz
tar -xzf toolchain.tar.gz -C /opt/
- name: Save riscv dir
uses: actions/cache/save@v3
if: steps.riscv_restore.outputs.cache-hit != 'true'
with:
path: /opt/riscv
key: riscv-${{ env.RISCV_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Setup riscv path
run: |
echo /opt/riscv/bin >> $GITHUB_PATH
build_matrix:
name: Build Smoke Test matrix
runs-on: ubuntu-22.04
needs: build_tools
outputs:
test_names: ${{ steps.output-matrix.outputs.test_names }}
env:
EXCLUDE_TESTS: "smoke_test_clk_gating, smoke_test_cg_wdt, smoke_test_mbox_cg, smoke_test_kv_cg, smoke_test_doe_cg"
steps:
- uses: actions/checkout@v3
- name: Install deps
run: |
sudo apt-get update -qy && sudo apt-get install -qy --no-install-recommends \
python3-minimal python3-yaml
- name: Build matrix
id: output-matrix
run: |
echo "test_names=$(python3 .github/scripts/build_tests_matrix.py)" >> $GITHUB_OUTPUT
build_and_test:
name: Verilator
runs-on: ubuntu-22.04
needs: build_matrix
strategy:
fail-fast: false
matrix:
test_name: ${{fromJSON(needs.build_matrix.outputs.test_names)}}
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- name: Restore Cargo index
uses: actions/cache/restore@v3
id: cargo_index_restore
with:
path: ~/.cargo/registry/index
key: cargo-index-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}-${{ hashFiles('Cargo.lock') }}
- name: Restore sccache binary
uses: actions/cache/restore@v3
id: sccache_bin_restore
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Restore verilator dir
uses: actions/cache/restore@v3
id: verilator_restore
with:
path: /opt/verilator
key: verilator-${{ env.VERILATOR_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Restore Risc V Toolchain
uses: actions/cache/restore@v3
id: riscv_restore
with:
path: /opt/riscv
key: riscv-${{ env.RISCV_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Setup verilator path
run: |
echo /opt/verilator/bin >> $GITHUB_PATH
- name: Setup riscv path
run: |
echo /opt/riscv/bin >> $GITHUB_PATH
- name: Run Caliptra Verilator Smoke Test
run: |
CALIPTRA_ROOT=$(pwd)
ADAMSBRIDGE_ROOT=$CALIPTRA_ROOT/submodules/adams-bridge
cd tools/scripts
make verilator CALIPTRA_ROOT=$CALIPTRA_ROOT ADAMSBRIDGE_ROOT=$ADAMSBRIDGE_ROOT TESTNAME=${{ matrix.test_name }} | tee output.log
# Search the last 30 lines of the output for "TESTCASE PASSED"
tail -n 30 output.log | grep "TESTCASE PASSED"
# grep will return 0 if the search term is found, and 1 otherwise
# A non-zero value will cause the github action to fail.
exit $?
verify_test_results:
name: Verify Verilator Test Results
runs-on: ubuntu-22.04
needs: build_and_test
# Force to run even if the build_and_test job is skipped for some reason
if: ${{ !cancelled() }}
steps:
- name: Print Verilator Aggregated Result
run: |
echo "build_and_test has a result of [${{ needs.build_and_test.result }}]"
if [[ "${{ needs.build_and_test.result }}" != "success" ]]; then
exit 1
fi