|
| 1 | +--- |
| 2 | +#------------------------------------------------------------------------------ |
| 3 | +# QEMU OpenTitan CI |
| 4 | +# |
| 5 | +# Copyright (c) 2023-2025 Rivos, Inc. |
| 6 | +# SPDX-License-Identifier: Apache License 2.0 |
| 7 | +#------------------------------------------------------------------------------ |
| 8 | + |
| 9 | +name: Build & Test QEMU OT |
| 10 | +on: [pull_request] |
| 11 | +jobs: |
| 12 | + build-clang: |
| 13 | + runs-on: ubuntu-24.04 |
| 14 | + steps: |
| 15 | + - name: Install deps |
| 16 | + run: | |
| 17 | + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | |
| 18 | + sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && |
| 19 | + sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main" && |
| 20 | + sudo apt-get update && |
| 21 | + sudo apt-get install -y git make pkg-config clang-18 cmake ninja-build python3 rust-all \ |
| 22 | + libpixman-1-dev libglib2.0-dev |
| 23 | + - name: Check out QEMU |
| 24 | + uses: actions/checkout@v4 |
| 25 | + - name: Configure |
| 26 | + run: | |
| 27 | + rm -rf build-clang |
| 28 | + git clean -dffx subprojects |
| 29 | + mkdir build-clang |
| 30 | + (cd build-clang && |
| 31 | + ../configure --cc=clang-18 --disable-werror --disable-install-blobs \ |
| 32 | + --target-list=riscv32-softmmu,riscv64-softmmu) |
| 33 | + - name: Build |
| 34 | + run: | |
| 35 | + ninja -C build-clang && |
| 36 | + ninja -C build-clang qemu-img && |
| 37 | + strip build-clang/qemu-system-riscv32 |
| 38 | + - name: Create minimal test binaries |
| 39 | + run: | |
| 40 | + scripts/opentitan/swexit.py -t ibexdemo -b 0x0 -o build-clang/exit_id.bin |
| 41 | + scripts/opentitan/swexit.py -t earlgrey -b 0x80 -o build-clang/exit_eg.bin |
| 42 | + scripts/opentitan/swexit.py -t darjeeling -b 0x80 -o build-clang/exit_dj.bin |
| 43 | + - name: Upload QEMU binary artifacts |
| 44 | + uses: actions/upload-artifact@v4 |
| 45 | + with: |
| 46 | + name: qemu-bin |
| 47 | + path: | |
| 48 | + build-clang/qemu-system-riscv32 |
| 49 | + build-clang/exit_*.bin |
| 50 | + retention-days: 1 |
| 51 | + - name: Pack source artifacts |
| 52 | + # GitHub takes ages to retrieve each source file, so pack them |
| 53 | + run: | |
| 54 | + tar czf qemu-src-artifact.tar.gz \ |
| 55 | + subprojects/libtomcrypt/src/headers/*.h \ |
| 56 | + build-clang/*.h \ |
| 57 | + build-clang/qapi/*.h \ |
| 58 | + build-clang/trace/*.h \ |
| 59 | + build-clang/compile_commands.json |
| 60 | + - name: Upload QEMU source artifacts |
| 61 | + uses: actions/upload-artifact@v4 |
| 62 | + with: |
| 63 | + name: qemu-src |
| 64 | + path: qemu-src-artifact.tar.gz |
| 65 | + retention-days: 1 |
| 66 | + |
| 67 | + format: |
| 68 | + runs-on: ubuntu-24.04 |
| 69 | + steps: |
| 70 | + - name: Install tools |
| 71 | + run: | |
| 72 | + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | |
| 73 | + sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && |
| 74 | + sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main" && |
| 75 | + sudo apt-get update && |
| 76 | + sudo apt-get install -y clang-format-18 |
| 77 | + - name: Check out QEMU |
| 78 | + uses: actions/checkout@v4 |
| 79 | + - name: Check C code format |
| 80 | + run: | |
| 81 | + scripts/opentitan/ot-format.sh --ci -i |
| 82 | +
|
| 83 | + lint-python: |
| 84 | + runs-on: ubuntu-latest |
| 85 | + steps: |
| 86 | + - name: Install tools |
| 87 | + run: | |
| 88 | + sudo apt-get update && |
| 89 | + sudo apt-get install -y python3-pip |
| 90 | + # ubuntu "latest" is too old to require --break-system-packages ... |
| 91 | + pip3 install pylint==3.3.3 |
| 92 | + - name: Check out QEMU |
| 93 | + uses: actions/checkout@v4 |
| 94 | + - name: Lint Python code |
| 95 | + run: | |
| 96 | + pylint --rcfile scripts/opentitan/.pylintrc -d 'duplicate-code' -d 'fixme' \ |
| 97 | + scripts/opentitan/*.py python/qemu/jtagtools python/qemu/ot |
| 98 | +
|
| 99 | + lint-clang: |
| 100 | + runs-on: ubuntu-24.04 |
| 101 | + needs: build-clang |
| 102 | + steps: |
| 103 | + - name: Install tools |
| 104 | + run: | |
| 105 | + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | |
| 106 | + sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && |
| 107 | + sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main" && |
| 108 | + sudo apt-get update && |
| 109 | + sudo apt-get install -y clang-tidy-18 libglib2.0-dev |
| 110 | + - name: Check out QEMU |
| 111 | + uses: actions/checkout@v4 |
| 112 | + - name: Download QEMU source artifacts |
| 113 | + uses: actions/download-artifact@v4 |
| 114 | + with: |
| 115 | + name: qemu-src |
| 116 | + - name: Unpack source artifacts |
| 117 | + run: | |
| 118 | + tar xzf qemu-src-artifact.tar.gz |
| 119 | + - name: Clang tidy |
| 120 | + # Expect many warnings/errors (accounted but not reported) from included QEMU files |
| 121 | + run: | |
| 122 | + scripts/opentitan/ot-tidy.sh --ci -p build-clang |
| 123 | +
|
| 124 | + lint-commits: |
| 125 | + runs-on: ubuntu-latest |
| 126 | + steps: |
| 127 | + - uses: actions/checkout@v4 |
| 128 | + with: |
| 129 | + fetch-depth: 0 # Don't shallow clone, we need to see all commits. |
| 130 | + - name: Lint commits |
| 131 | + run: ./scripts/opentitan/lint-commits.sh "origin/${{ github.base_ref }}" |
| 132 | + |
| 133 | + test-clang: |
| 134 | + runs-on: ubuntu-24.04 |
| 135 | + needs: build-clang |
| 136 | + steps: |
| 137 | + - name: Install tools |
| 138 | + run: | |
| 139 | + sudo apt-get update && |
| 140 | + sudo apt-get install -y libpixman-1-0 libglib2.0-dev |
| 141 | + - name: Download QEMU binary artifacts |
| 142 | + uses: actions/download-artifact@v4 |
| 143 | + with: |
| 144 | + name: qemu-bin |
| 145 | + - name: Check machine availability |
| 146 | + run: | |
| 147 | + chmod +x ./qemu-system-riscv32 && |
| 148 | + ./qemu-system-riscv32 -M help | grep ibexdemo && |
| 149 | + ./qemu-system-riscv32 -M help | grep ot-earlgrey && |
| 150 | + ./qemu-system-riscv32 -M help | grep ot-darjeeling |
| 151 | + - name: Check IbexDemo VM execution |
| 152 | + run: | |
| 153 | + timeout -s KILL 4 ./qemu-system-riscv32 -M ibexdemo -nographic \ |
| 154 | + -device loader,addr=0x100080,file=exit_id.bin -d in_asm,int |
| 155 | + - name: Check EarlGrey VM execution |
| 156 | + run: | |
| 157 | + timeout -s KILL 4 ./qemu-system-riscv32 -M ot-earlgrey,no_epmp_cfg=true -nographic \ |
| 158 | + -object ot-rom_img,id=rom,file=exit_eg.bin -d in_asm,int |
| 159 | +
|
| 160 | + build-gcc: |
| 161 | + runs-on: ubuntu-24.04 |
| 162 | + steps: |
| 163 | + - name: Install tools |
| 164 | + run: | |
| 165 | + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | |
| 166 | + sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && |
| 167 | + sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main" && |
| 168 | + sudo apt-get update && |
| 169 | + sudo apt-get install -y git make pkg-config gcc cmake ninja-build python3 rust-all \ |
| 170 | + libpixman-1-dev libglib2.0-dev |
| 171 | + - name: Check out QEMU |
| 172 | + uses: actions/checkout@v4 |
| 173 | + - name: Configure |
| 174 | + run: | |
| 175 | + rm -rf build-gcc |
| 176 | + git clean -dffx subprojects |
| 177 | + mkdir build-gcc |
| 178 | + (cd build-gcc && |
| 179 | + ../configure --cc=gcc --enable-werror --disable-install-blobs \ |
| 180 | + --target-list=riscv32-softmmu,riscv64-softmmu) |
| 181 | + - name: Build |
| 182 | + run: | |
| 183 | + ninja -C build-gcc |
0 commit comments