-
Notifications
You must be signed in to change notification settings - Fork 3
143 lines (120 loc) · 4.03 KB
/
build_and_test.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
# SPDX-FileCopyrightText: 2024 Rivos Inc.
#
# SPDX-License-Identifier: Apache-2.0
name: "Build & Test"
on:
# allow direct trigger
workflow_dispatch:
push:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
GCC_VERSION: "12"
LLVM_VERSION: "18"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
with:
persist-credentials: false
- name: Install dependencies
run: |
sudo apt-get update -y -qq
sudo apt-get install -y -qq build-essential curl ninja-build debootstrap
# Needed for some target toolchains like ld
- name: Install gcc
run: |
sudo apt-get install -y -qq gcc-${GCC_VERSION} gcc-${GCC_VERSION}-riscv64-linux-gnu g++-${GCC_VERSION} g++-${GCC_VERSION}-riscv64-linux-gnu
- name: Install llvm
run: |
curl -o llvm.sh https://apt.llvm.org/llvm.sh
chmod u+x llvm.sh
sudo ./llvm.sh ${LLVM_VERSION}
rm llvm.sh
- name: Setup QEMU
uses: docker/setup-qemu-action@v3.0.0
- name: Check sysroot cache
id: check-sysroot-cache
uses: actions/cache@v4
with:
path: sysroot
key: sysroot-${{ hashFiles('./.github/workflows/build_and_test.yml') }}
- name: Create sysroot
run: |
sudo debootstrap --arch=riscv64 --verbose --include=fakeroot,symlinks,googletest --resolve-deps --variant=minbase --components=main,universe jammy sysroot
# Remove unused files to minimize cache
sudo chroot sysroot symlinks -cr .
sudo chown ${USER} -R sysroot
rm -rf sysroot/{dev,proc,run,sys,var}
rm -rf sysroot/usr/{sbin,bin,share}
rm -rf sysroot/usr/lib/{apt,gcc,udev,systemd}
rm -rf sysroot/usr/libexec/gcc
if: steps.check-sysroot-cache.outputs.cache-hit != 'true'
- name: Build
shell: bash -ex -o pipefail {0}
run: |
export QEMU_LD_PREFIX=$(pwd)/sysroot
cmake -S . -B build -GNinja \
-DCMAKE_INSTALL_PREFIX="$(pwd)/install" \
-DCMAKE_TOOLCHAIN_FILE=$(pwd)/CMakeToolchain/riscv.clang.cross.cmake \
-DCMAKE_SYSROOT=$(pwd)/sysroot
cmake --build build
cmake --install build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build
path: |
build
install
if: always()
test:
runs-on: ubuntu-latest
needs: [build]
strategy:
fail-fast: false
matrix:
include:
- qemu_cpu: "rv64,zba=true,zbb=true,zbs=true,v=true,vlen=128,elen=64,vext_spec=v1.0"
- qemu_cpu: "rv64,zba=true,zbb=true,zbs=true,v=true,vlen=256,elen=64,vext_spec=v1.0"
- qemu_cpu: "rv64,zba=true,zbb=true,zbs=true,v=true,vlen=512,elen=64,vext_spec=v1.0"
name: "test (qemu_cpu: \"${{ matrix.qemu_cpu }}\")"
steps:
- uses: actions/checkout@v4.1.1
with:
persist-credentials: false
- name: Setup QEMU
uses: docker/setup-qemu-action@v3.0.0
- name: Check sysroot cache
id: check-sysroot-cache
uses: actions/cache@v4
with:
path: sysroot
key: sysroot-${{ hashFiles('./.github/workflows/build_and_test.yml') }}
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build
- name: Fix build permissions
run: |
chmod +x build/test/test_*
- name: Test
env:
CTEST_OUTPUT_ON_FAILURE: "TRUE"
run: |
export QEMU_CPU="${{ matrix.qemu_cpu }}"
export QEMU_LD_PREFIX=$(pwd)/sysroot
cd build
ctest -j$(nproc) --output-on-failure
- name: Upload test-${{ strategy.job-index }} artifacts
uses: actions/upload-artifact@v4
with:
name: test-${{ strategy.job-index }}
path: |
build/Testing
if: always()