Skip to content

Commit 7757d17

Browse files
authored
CI: Add extra step building and uploading QEMU (#883)
Uses GHA caching to make it quick for future builds
1 parent 54c2c18 commit 7757d17

File tree

1 file changed

+71
-1
lines changed

1 file changed

+71
-1
lines changed

.github/workflows/build.yml

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ env:
1313
OLDSTABLE_VERSION: 1
1414
OLDOLDSTABLE_VERSION: 0.5
1515
OLDOLDOLDSTABLE_VERSION: 0.4
16+
QEMU_VERSION: 8.2.0
17+
QEMU_URL: https://download.qemu.org/qemu-8.2.0.tar.xz
1618

1719
jobs:
1820
# Run cargo xtask format-check
@@ -170,9 +172,64 @@ jobs:
170172
- name: Check the examples
171173
run: cargo xtask usage-example-build
172174

175+
buildqemu:
176+
name: Get modern QEMU, build and store
177+
runs-on: ubuntu-22.04
178+
steps:
179+
- name: Checkout
180+
uses: actions/checkout@v4
181+
182+
- name: Cache QEMU build
183+
id: cache-qemu
184+
uses: actions/cache@v4
185+
with:
186+
path: qemu-${{ env.QEMU_VERSION }}/build
187+
key: ${{ runner.OS }}-qemu-${{ env.QEMU_VERSION }}
188+
restore-keys: |
189+
${{ runner.OS }}-qemu-${{ env.QEMU_VERSION }}
190+
${{ runner.OS }}-qemu-
191+
192+
- name: Install QEMU to get dependencies
193+
run: |
194+
sudo apt update
195+
sudo apt install -y qemu-system-arm
196+
sudo apt-get install git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev ninja-build
197+
198+
- if: ${{ steps.cache-qemu.outputs.cache-hit != 'true' }}
199+
name: Download QEMU
200+
run: wget "${{ env.QEMU_URL }}"
201+
202+
- if: ${{ steps.cache-qemu.outputs.cache-hit != 'true' }}
203+
name: Extract QEMU
204+
run: tar xvJf qemu-${{ env.QEMU_VERSION }}.tar.xz
205+
206+
- if: ${{ steps.cache-qemu.outputs.cache-hit != 'true' }}
207+
name: Configure QEMU
208+
run: |
209+
cd qemu-${{ env.QEMU_VERSION }}
210+
./configure --target-list=arm-softmmu,riscv32-softmmu
211+
212+
- if: ${{ steps.cache-qemu.outputs.cache-hit != 'true' }}
213+
name: Build QEMU
214+
run: |
215+
cd qemu-${{ env.QEMU_VERSION }}
216+
make -j$(nproc)
217+
218+
- name: Archive QEMU build
219+
run: |
220+
cd qemu-${{ env.QEMU_VERSION }}/build
221+
tar -cf $GITHUB_WORKSPACE/qemu.tar *
222+
223+
- name: Store QEMU build
224+
uses: actions/upload-artifact@v4
225+
with:
226+
name: qemu
227+
path: qemu.tar
228+
173229
# Verify the example output with run-pass tests
174230
testexamples:
175231
name: QEMU run
232+
needs: buildqemu
176233
runs-on: ubuntu-22.04
177234
strategy:
178235
matrix:
@@ -207,11 +264,24 @@ jobs:
207264
- name: Cache Dependencies
208265
uses: Swatinem/rust-cache@v2
209266

210-
- name: Install QEMU
267+
- name: Install QEMU to get dependencies
211268
run: |
212269
sudo apt update
213270
sudo apt install -y qemu-system-arm
214271
272+
- name: Download built QEMU
273+
uses: actions/download-artifact@v4
274+
with:
275+
name: qemu
276+
277+
- name: Extract QEMU into local path
278+
run: tar -xf qemu.tar -C /usr/local/bin
279+
280+
- name: Check which QEMU is used
281+
run: |
282+
which qemu-system-arm
283+
which qemu-system-riscv32
284+
215285
- name: Run-pass tests
216286
run: cargo xtask --deny-warnings --backend ${{ matrix.backend }} qemu
217287

0 commit comments

Comments
 (0)