Skip to content

Commit 06f27a8

Browse files
committed
ci: add cross/native build
Signed-off-by: Han Gao <rabenda.cn@gmail.com> Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
1 parent 36677db commit 06f27a8

File tree

2 files changed

+170
-0
lines changed

2 files changed

+170
-0
lines changed

.github/workflows/kernel-build.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: sophgo-kernel
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
schedule:
8+
- cron: "0 2 * * *"
9+
10+
jobs:
11+
build-kernel:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- name: gcc-13
17+
board: sg2044
18+
19+
runs-on: ubuntu-22.04
20+
env:
21+
xuantie_toolchain: https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1705395627867
22+
toolchain_file_name: Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.8.1-20240115.tar.gz
23+
mainline_toolchain: https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2024.03.01
24+
mainline_toolchain_file_name: riscv64-glibc-ubuntu-22.04-gcc-nightly-2024.03.01-nightly.tar.gz
25+
wget_alias: 'wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0'
26+
ARCH: riscv
27+
KBUILD_BUILD_USER: riscv
28+
KBUILD_BUILD_HOST: riscv-builder
29+
KDEB_COMPRESS: xz
30+
board: ${{ matrix.board }}
31+
CROSS_COMPILE: riscv64-unknown-linux-gnu-
32+
33+
steps:
34+
- name: Update Apt Cache
35+
run: sudo apt update
36+
37+
- name: Free Disk Space (Ubuntu)
38+
uses: jlumbroso/free-disk-space@main
39+
with:
40+
# this might remove tools that are actually needed,
41+
# if set to "true" but frees about 6 GB
42+
tool-cache: true
43+
# all of these default to true, but feel free to set to
44+
# "false" if necessary for your workflow
45+
android: true
46+
dotnet: true
47+
haskell: true
48+
large-packages: true
49+
docker-images: true
50+
swap-storage: true
51+
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
with:
55+
path: kernel
56+
57+
- name: Install software
58+
run: |
59+
sudo apt install -y gdisk dosfstools g++-12-riscv64-linux-gnu build-essential \
60+
libncurses-dev gawk flex bison openssl libssl-dev tree \
61+
dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf \
62+
device-tree-compiler xz-utils devscripts ccache debhelper bc gcc-riscv64-linux-gnu
63+
64+
- name: Compile Kernel && Install
65+
run: |
66+
mkdir -p artifact
67+
if [[ ${{ matrix.name }} = "thead-gcc" ]]; then
68+
${wget_alias} ${xuantie_toolchain}/${toolchain_file_name}
69+
tar -xvf ${toolchain_file_name} -C /opt
70+
export PATH="/opt/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.8.1/bin:$PATH"
71+
else
72+
${wget_alias} ${mainline_toolchain}/${mainline_toolchain_file_name}
73+
tar -xvf ${mainline_toolchain_file_name} -C /opt
74+
export PATH="/opt/riscv/bin:$PATH"
75+
fi
76+
${CROSS_COMPILE}gcc -v
77+
pushd kernel
78+
export KDEB_PKGVERSION="$(date "+%Y.%m.%d.%H.%M")+$(git rev-parse --short HEAD)"
79+
make revyos_defconfig
80+
81+
make -j$(nproc) dtbs
82+
make -j$(nproc) bindeb-pkg LOCALVERSION="-${board}"
83+
sudo cp -v arch/riscv/boot/dts/sophgo/*.dtb ../artifact
84+
sudo cp -v ../*.deb ../artifact
85+
popd
86+
87+
- name: compress
88+
run: tar -zcvf sophgo-kernel-${{ matrix.name }}-${{ matrix.board }}.tar.gz artifact
89+
90+
- name: 'Upload Artifact'
91+
uses: actions/upload-artifact@v3
92+
with:
93+
name: sophgo-kernel-${{ matrix.name }}-${{ matrix.board }}.tar.gz
94+
path: sophgo-kernel-${{ matrix.name }}-${{ matrix.board }}.tar.gz
95+
retention-days: 30

.github/workflows/native-build.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: sophgo-kernel-native
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
schedule:
8+
- cron: "0 2 * * *"
9+
10+
env:
11+
wget_alias: 'wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 0'
12+
ARCH: riscv
13+
KBUILD_BUILD_USER: builder
14+
KBUILD_BUILD_HOST: revyos-riscv-builder
15+
KDEB_COMPRESS: none
16+
KDEB_CHANGELOG_DIST: unstable
17+
18+
jobs:
19+
kernel:
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
include:
24+
- name: native
25+
cross: riscv64-linux-gnu-
26+
machine: [ self-hosted, Linux, riscv64 ]
27+
run_image: ghcr.io/revyos/revyos-kernel-builder:riscv64-2024.04.19
28+
board: sg2044
29+
compiler: riscv64-linux-gnu-gcc-13
30+
31+
runs-on: ${{ matrix.machine }}
32+
container:
33+
image: ${{ matrix.run_image }}
34+
env:
35+
CROSS_COMPILE: ${{ matrix.cross }}
36+
board: ${{ matrix.board }}
37+
compiler: ${{ matrix.compiler }}
38+
39+
steps:
40+
- name: Checkout kernel
41+
uses: actions/checkout@v4
42+
with:
43+
path: 'kernel'
44+
45+
- name: Compile Kernel && Install
46+
run: |
47+
mkdir -p output
48+
${CROSS_COMPILE}gcc -v
49+
50+
pushd kernel
51+
export KDEB_PKGVERSION="$(make kernelversion)-$(date "+%Y.%m.%d.%H.%M")+$(git rev-parse --short HEAD)"
52+
make CC="${compiler}" revyos_defconfig
53+
54+
# FIXME: force use 32 thread
55+
make CC="${compiler}" -j64 bindeb-pkg LOCALVERSION="-${board}"
56+
make CC="${compiler}" -j64 dtbs
57+
58+
sudo cp -v arch/riscv/boot/dts/sophgo/*.dtb ${GITHUB_WORKSPACE}/output
59+
# Copy deb
60+
sudo dcmd cp -v ../*.changes ${GITHUB_WORKSPACE}/output
61+
62+
# record commit-id
63+
git rev-parse HEAD > kernel-commitid
64+
sudo cp -v kernel-commitid ${GITHUB_WORKSPACE}/output
65+
popd
66+
67+
- name: compress
68+
run: tar -zcvf sophgo-kernel-${{ matrix.name }}-${{ matrix.board }}.tar.gz output
69+
70+
- name: 'Upload Artifact'
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: sophgo-kernel-${{ matrix.name }}-${{ matrix.board }}.tar.gz
74+
path: sophgo-kernel-${{ matrix.name }}-${{ matrix.board }}.tar.gz
75+
retention-days: 30

0 commit comments

Comments
 (0)