-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (165 loc) · 6.31 KB
/
kernel-build.yml
File metadata and controls
177 lines (165 loc) · 6.31 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Reusable build workflow
on:
workflow_call:
inputs:
arch:
required: true
type: string
description: The architecture to build against, e.g x86_64, aarch64, s390x...
toolchain_full:
required: true
type: string
description: The toolchain and for llvm, its version, e.g gcc, llvm-15
toolchain:
required: true
type: string
description: The toolchain, e.g gcc, llvm
runs_on:
required: true
type: string
description: The runners to run the test on. This is a json string representing an array of labels.
llvm-version:
required: true
type: string
description: The version of LLVM used to build selftest.... for llvm toolchain, this should match the one from toolchain_full, for gcc it is an arbritrary version we decide to build selftests against.
kernel:
required: true
type: string
description: The kernel to run the test against. For KPD this is always LATEST, which runs against a newly built kernel.
download_sources:
required: true
type: boolean
description: Whether to download the linux sources into the working directory.
default: false
release:
required: false
type: boolean
description: Build selftest with -O2 optimization
default: false
jobs:
build:
name: build for ${{ inputs.arch }} with ${{ inputs.toolchain_full }}${{ inputs.release && '-O2' || '' }}
runs-on: ${{ fromJSON(inputs.runs_on) }}
timeout-minutes: 100
env:
ARTIFACTS_ARCHIVE: "vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}.tar.zst"
BUILD_BPF_GCC: ${{ inputs.arch == 'x86_64' && 'true' || '' }}
BPF_GCC_INSTALL_DIR: ${{ github.workspace }}/bpf-gcc
BPF_NEXT_BASE_BRANCH: 'master'
BPF_NEXT_FETCH_DEPTH: 64 # A bit of history is needed to facilitate incremental builds
BUILD_SCHED_EXT_SELFTESTS: ${{ inputs.arch == 'x86_64' || inputs.arch == 'aarch64' && 'true' || '' }}
KBUILD_OUTPUT: ${{ github.workspace }}/kbuild-output
KERNEL: ${{ inputs.kernel }}
KERNEL_ROOT: ${{ github.workspace }}
REPO_PATH: ""
REPO_ROOT: ${{ github.workspace }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ inputs.download_sources && 1 || env.BPF_NEXT_FETCH_DEPTH }}
- if: ${{ inputs.download_sources }}
name: Download bpf-next tree
env:
FETCH_DEPTH: ${{ env.BPF_NEXT_FETCH_DEPTH }}
uses: ./get-linux-source
with:
dest: '.kernel'
rev: ${{ env.BPF_NEXT_BASE_BRANCH }}
- uses: ./prepare-incremental-build
with:
repo-root: ${{ inputs.download_sources && '.kernel' || env.REPO_ROOT }}
base-branch: >-
${{ inputs.download_sources && env.BPF_NEXT_BASE_BRANCH
|| github.event_name == 'pull_request' && github.base_ref
|| github.ref_name
}}
arch: ${{ inputs.arch }}
toolchain_full: ${{ inputs.toolchain_full }}
kbuild-output: ${{ env.KBUILD_OUTPUT }}
- if: ${{ inputs.download_sources }}
name: Move linux source in place
shell: bash
run: |
cd .kernel
rm -rf .git
mv -t .. $(ls -A)
cd ..
rmdir .kernel
- uses: ./patch-kernel
with:
patches-root: '${{ github.workspace }}/ci/diffs'
repo-root: ${{ env.REPO_ROOT }}
- name: Setup build environment
uses: ./setup-build-env
with:
arch: ${{ inputs.arch }}
llvm-version: ${{ inputs.llvm-version }}
pahole: master
- name: Build kernel image
uses: ./build-linux
with:
arch: ${{ inputs.arch }}
toolchain: ${{ inputs.toolchain }}
kbuild-output: ${{ env.KBUILD_OUTPUT }}
max-make-jobs: 32
llvm-version: ${{ inputs.llvm-version }}
- if: ${{ env.BUILD_BPF_GCC }}
name: Build GCC for BPF selftests
uses: ./build-bpf-gcc
with:
install-dir: ${{ env.BPF_GCC_INSTALL_DIR }}
- name: Build selftests/bpf
uses: ./build-selftests
env:
MAX_MAKE_JOBS: 32
RELEASE: ${{ inputs.release && '1' || '' }}
BPF_GCC: ${{ env.BUILD_BPF_GCC && env.BPF_GCC_INSTALL_DIR || '' }}
with:
arch: ${{ inputs.arch }}
kernel-root: ${{ env.KERNEL_ROOT }}
llvm-version: ${{ inputs.llvm-version }}
toolchain: ${{ inputs.toolchain }}
- if: ${{ env.BUILD_SCHED_EXT_SELFTESTS }}
name: Build selftests/sched_ext
uses: ./build-scx-selftests
with:
kbuild-output: ${{ env.KBUILD_OUTPUT }}
repo-root: ${{ env.REPO_ROOT }}
arch: ${{ inputs.arch }}
toolchain: ${{ inputs.toolchain }}
llvm-version: ${{ inputs.llvm-version }}
max-make-jobs: 32
- if: ${{ github.event_name != 'push' }}
name: Build samples
uses: ./build-samples
with:
arch: ${{ inputs.arch }}
toolchain: ${{ inputs.toolchain }}
kbuild-output: ${{ env.KBUILD_OUTPUT }}
max-make-jobs: 32
llvm-version: ${{ inputs.llvm-version }}
- name: Tar artifacts
id: tar-artifacts
uses: ./tar-artifacts
env:
ARCHIVE_BPF_SELFTESTS: 'true'
ARCHIVE_MAKE_HELPERS: 'true'
ARCHIVE_SCHED_EXT_SELFTESTS: ${{ env.BUILD_SCHED_EXT_SELFTESTS }}
with:
arch: ${{ inputs.arch }}
archive: ${{ env.ARTIFACTS_ARCHIVE }}
kbuild-output: ${{ env.KBUILD_OUTPUT }}
repo-root: ${{ env.REPO_ROOT }}
- if: ${{ github.event_name != 'push' }}
name: Remove KBUILD_OUTPUT content
shell: bash
run: |
# Remove $KBUILD_OUTPUT to prevent cache creation for pull requests.
# Only on pushed changes are build artifacts actually cached, because
# of github.com/actions/cache's cache isolation logic.
rm -rf "${KBUILD_OUTPUT}"
- uses: actions/upload-artifact@v4
with:
name: vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}${{ inputs.release && '-release' || '' }}
if-no-files-found: error
path: ${{ env.ARTIFACTS_ARCHIVE }}