forked from kernel-patches/bpf
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (138 loc) · 5.6 KB
/
kernel-build.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
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 && ' and -O2 optimization' || '' }}
runs-on: ${{ fromJSON(inputs.runs_on) }}
timeout-minutes: 100
env:
KERNEL: ${{ inputs.kernel }}
REPO_ROOT: ${{ github.workspace }}
REPO_PATH: ""
KBUILD_OUTPUT: kbuild-output/
steps:
- uses: actions/checkout@v4
# We fetch an actual bit of history here to facilitate incremental
# builds (which may check out some earlier upstream change).
with:
fetch-depth: 50
- if: ${{ inputs.download_sources }}
name: Download bpf-next tree
uses: libbpf/ci/get-linux-source@main
with:
dest: '.kernel'
- if: ${{ inputs.download_sources }}
name: Move linux source in place
shell: bash
run: |
rm -rf .kernel/.git
cp -rf .kernel/. .
rm -rf .kernel
- name: Get commit meta-data
id: get-commit-metadata
run: |
bash .github/scripts/get-commit-metadata.sh
- name: Pull recent KBUILD_OUTPUT contents
uses: actions/cache@v4
with:
path: ${{ env.KBUILD_OUTPUT }}
key: kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-${{ steps.get-commit-metadata.outputs.branch }}-${{ steps.get-commit-metadata.outputs.timestamp }}-${{ steps.get-commit-metadata.outputs.commit }}
restore-keys: |
kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-${{ steps.get-commit-metadata.outputs.branch }}-${{ steps.get-commit-metadata.outputs.timestamp }}-
kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-${{ steps.get-commit-metadata.outputs.branch }}-
kbuild-output-${{ inputs.arch }}-${{ inputs.toolchain_full }}-
- name: Prepare incremental build
shell: bash
run: |
bash .github/scripts/prepare-incremental-builds.sh ${{ steps.get-commit-metadata.outputs.commit }}
- uses: libbpf/ci/patch-kernel@main
with:
patches-root: '${{ github.workspace }}/ci/diffs'
repo-root: '${{ github.workspace }}'
- name: Setup build environment
uses: libbpf/ci/setup-build-env@main
with:
arch: ${{ inputs.arch }}
llvm-version: ${{ inputs.llvm-version }}
- name: Build kernel image
uses: libbpf/ci/build-linux@main
with:
arch: ${{ inputs.arch }}
toolchain: ${{ inputs.toolchain }}
kbuild-output: ${{ env.KBUILD_OUTPUT }}
max-make-jobs: 32
llvm-version: ${{ inputs.llvm-version }}
- name: Build selftests
uses: libbpf/ci/build-selftests@main
with:
arch: ${{ inputs.arch }}
toolchain: ${{ inputs.toolchain }}
kbuild-output: ${{ env.KBUILD_OUTPUT }}
max-make-jobs: 32
llvm-version: ${{ inputs.llvm-version }}
env:
# RELEASE= disables all optimizaions
# RELEASE=0 adds -O0 make flag
# RELEASE=1 adds -O2 make flag
RELEASE: ${{ inputs.release && '1' || '' }}
- if: ${{ github.event_name != 'push' }}
name: Build samples
uses: libbpf/ci/build-samples@main
with:
arch: ${{ inputs.arch }}
toolchain: ${{ inputs.toolchain }}
kbuild-output: ${{ env.KBUILD_OUTPUT }}
max-make-jobs: 32
llvm-version: ${{ inputs.llvm-version }}
- name: Tar artifacts
run: |
bash .github/scripts/tar-artifact.sh ${{ inputs.arch }} ${{ inputs.toolchain_full }}
- 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: vmlinux-${{ inputs.arch }}-${{ inputs.toolchain_full }}.tar.zst