-
Notifications
You must be signed in to change notification settings - Fork 749
151 lines (139 loc) · 4.93 KB
/
github-ci.yml
File metadata and controls
151 lines (139 loc) · 4.93 KB
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
name: LK CI (gcc)
# Brute force build a bunch of variants of LK in parallel jobs.
on:
pull_request:
push:
branches-ignore:
- 'wip/**'
- 'docs/**' # Skip builds for documentation branches
paths-ignore:
- '**.md' # Skip builds when only markdown files change
- 'docs/**' # Skip builds for docs directory changes
jobs:
build:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
toolchain-ver: [15.2.0, 11.3.0]
debug: [2, 0]
ubsan: [1, 0]
arch:
- arm
- arm64
- m68k
- mips
- or1k
- riscv32
- riscv64
- x86
exclude:
# do not build ubsan for older 32bit arches where it is not well supported
- ubsan: 1
arch: m68k
- ubsan: 1
arch: mips
- ubsan: 1
arch: or1k
env:
ARCH: ${{ matrix.arch }}
TOOLCHAIN_VER: ${{ matrix.toolchain-ver }}
# ${{ matrix.toolchain-arch }}-${{ matrix.toolchain-ver }}-Linux-x86_64
DEBUG: ${{ matrix.debug }}
UBSAN: ${{ matrix.ubsan }}
TOOLCHAIN: # compute below
TOOLCHAIN_ALT: # compute below
steps:
- name: banner
shell: bash
run: |
printf "Building with %d processors\n" "$(nproc)"
grep -oP '(?<=model name\t: ).*' /proc/cpuinfo|head -n1
echo ARCH = $ARCH
echo TOOLCHAIN_VER = $TOOLCHAIN_VER
echo DEBUG = $DEBUG
echo UBSAN = $UBSAN
# check out the source
- name: checkout
uses: actions/checkout@v6
# compute the toolchain prefix this project will need
- name: compute toolchain
shell: bash
run: |
case "${{ matrix.arch }}" in
arm) TOOLCHAIN_PREFIX="arm-eabi-" ;;
arm64) TOOLCHAIN_PREFIX="aarch64-elf-" ;;
m68k) TOOLCHAIN_PREFIX="m68k-elf-" ;;
mips) TOOLCHAIN_PREFIX="mips-elf-" ;;
or1k) TOOLCHAIN_PREFIX="or1k-elf-" ;;
riscv32) TOOLCHAIN_PREFIX="riscv32-elf-" ;;
riscv64) TOOLCHAIN_PREFIX="riscv64-elf-" ;;
x86) TOOLCHAIN_PREFIX="x86_64-elf-" ;;
*) echo "Unknown architecture: ${{ matrix.arch }}" && exit 1 ;;
esac
echo "TOOLCHAIN_PREFIX=${TOOLCHAIN_PREFIX}" >> $GITHUB_ENV
echo "TOOLCHAIN=${TOOLCHAIN_PREFIX}${{ matrix.toolchain-ver }}-$(uname)-$(uname -m)" >> $GITHUB_ENV
if [ "$TOOLCHAIN_PREFIX" = "x86_64-elf-" ]; then
# for some x86_64-elf projects, we need i386-elf as well
echo "TOOLCHAIN_ALT=i386-elf-${{ matrix.toolchain-ver }}-$(uname)-$(uname -m)" >> $GITHUB_ENV
fi
# maintain a directory archives/ in the repo
# it will contain tarballs of various toolchains
- name: cache
uses: actions/cache@v5
id: cache
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: archives
# An explicit key for restoring and saving the cache
key: archives-${{ env.TOOLCHAIN }}-${{ env.TOOLCHAIN_ALT }}
# download a toolchain from https://newos.org/toolchains
# if not already cached
- name: fetch/extract toolchain
shell: bash
run: |
TOOLCHAIN_BASE_URL="https://newos.org/toolchains"
TOOLCHAIN_SUFFIX="tar.xz"
TOOLCHAIN_ADDRESS="$TOOLCHAIN_BASE_URL/$TOOLCHAIN.$TOOLCHAIN_SUFFIX"
mkdir -p archives
cd archives
echo "Downloading toolchain $TOOLCHAIN from $TOOLCHAIN_ADDRESS"
wget -v -N $TOOLCHAIN_ADDRESS || exit 1
cd ..
echo "Unpacking $TOOLCHAIN"
tar xf archives/$TOOLCHAIN.$TOOLCHAIN_SUFFIX || exit 1
echo "$GITHUB_WORKSPACE/$TOOLCHAIN/bin" >> $GITHUB_PATH
# if we have an alternate toolchain, download it too
- name: fetch/extract alternate toolchain
if: env.TOOLCHAIN_ALT != ''
shell: bash
run: |
TOOLCHAIN_BASE_URL="https://newos.org/toolchains"
TOOLCHAIN_SUFFIX="tar.xz"
TOOLCHAIN_ALT_ADDRESS="$TOOLCHAIN_BASE_URL/$TOOLCHAIN_ALT.$TOOLCHAIN_SUFFIX"
echo "Downloading alternate toolchain $TOOLCHAIN_ALT from $TOOLCHAIN_ALT_ADDRESS"
mkdir -p archives
cd archives
wget -v -N $TOOLCHAIN_ALT_ADDRESS || exit 1
cd ..
echo "Unpacking $TOOLCHAIN_ALT"
tar xf archives/$TOOLCHAIN_ALT.$TOOLCHAIN_SUFFIX || exit 1
echo "$GITHUB_WORKSPACE/$TOOLCHAIN_ALT/bin" >> $GITHUB_PATH
# build it
- name: build
shell: bash
run: |
export -n TOOLCHAIN_PREFIX
export -n TOOLCHAIN
export -n TOOLCHAIN_ALT
export -n TOOLCHAIN_VER
export -n ARCH
# DEBUG is passed through to the build script
# UBSAN is passed through to the build script
./scripts/buildall -e -a "${{ matrix.arch }}"
# upload artifacts
#- uses: actions/upload-artifact@v2
# with:
# name: build-dir
# path: build-${{ matrix.project }}/lk.*
# vim: ts=2 sw=2 expandtab