Skip to content

Commit c0abf79

Browse files
author
Kernel Patches Daemon
committed
adding ci files
1 parent 8589e92 commit c0abf79

18 files changed

+1228
-18
lines changed

.github/workflows/lint.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "lint"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
shellcheck:
11+
# This workflow gets injected into other Linux repositories, but we don't
12+
# want it to run there.
13+
if: ${{ github.repository == 'kernel-patches/vmtest' }}
14+
name: ShellCheck
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
- name: Run ShellCheck
20+
uses: ludeeus/action-shellcheck@master
21+
env:
22+
SHELLCHECK_OPTS: --severity=warning --exclude=SC1091

.github/workflows/test.yml

Lines changed: 326 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,326 @@
1+
name: bpf-ci
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- bpf_base
8+
- bpf-next_base
9+
10+
concurrency:
11+
group: ci-test-${{ github.ref_name }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
llvm-toolchain:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
llvm: ${{ steps.llvm-toolchain-impl.outputs.version }}
19+
steps:
20+
- id: llvm-version
21+
uses: libbpf/ci/get-llvm-version@master
22+
- id: llvm-toolchain-impl
23+
shell: bash
24+
run: echo "version=llvm-${{ steps.llvm-version.outputs.version }}" >> $GITHUB_OUTPUT
25+
set-matrix:
26+
needs: llvm-toolchain
27+
runs-on: ubuntu-latest
28+
outputs:
29+
build-matrix: ${{ steps.set-matrix-impl.outputs.build_matrix }}
30+
test-matrix: ${{ steps.set-matrix-impl.outputs.test_matrix }}
31+
steps:
32+
- id: set-matrix-impl
33+
shell: python3 -I {0}
34+
run: |
35+
from json import dumps
36+
from enum import Enum
37+
import os
38+
39+
class Arch(Enum):
40+
"""
41+
CPU architecture supported by CI.
42+
"""
43+
aarch64 = "aarch64"
44+
s390x = "s390x"
45+
x86_64 = "x86_64"
46+
47+
def set_output(name, value):
48+
"""Write an output variable to the GitHub output file."""
49+
with open(os.getenv("GITHUB_OUTPUT"), "a") as f:
50+
f.write(f"{name}={value}\n")
51+
52+
def generate_test_config(test):
53+
"""Create the configuration for the provided test."""
54+
experimental = test.endswith("_parallel")
55+
config = {
56+
"test": test,
57+
"continue_on_error": experimental,
58+
# While in experimental mode, parallel jobs may get stuck
59+
# anywhere, including in user space where the kernel won't detect
60+
# a problem and panic. We add a second layer of (smaller) timeouts
61+
# here such that if we get stuck in a parallel run, we hit this
62+
# timeout and fail without affecting the overall job success (as
63+
# would be the case if we hit the job-wide timeout). For
64+
# non-experimental jobs, 360 is the default which will be
65+
# superseded by the overall workflow timeout (but we need to
66+
# specify something).
67+
"timeout_minutes": 30 if experimental else 360,
68+
}
69+
return config
70+
71+
matrix = [
72+
{"kernel": "LATEST", "runs_on": [], "arch": Arch.x86_64.value, "toolchain": "gcc"},
73+
{"kernel": "LATEST", "runs_on": [], "arch": Arch.x86_64.value, "toolchain": "${{ needs.llvm-toolchain.outputs.llvm }}"},
74+
{"kernel": "LATEST", "runs_on": [], "arch": Arch.aarch64.value, "toolchain": "gcc"},
75+
{"kernel": "LATEST", "runs_on": [], "arch": Arch.aarch64.value, "toolchain": "${{ needs.llvm-toolchain.outputs.llvm }}"},
76+
{"kernel": "LATEST", "runs_on": [], "arch": Arch.s390x.value, "toolchain": "gcc"},
77+
]
78+
self_hosted_repos = [
79+
"kernel-patches/bpf",
80+
"kernel-patches/vmtest",
81+
]
82+
83+
# Only a few repository within "kernel-patches" use self-hosted runners.
84+
if "${{ github.repository_owner }}" != "kernel-patches" or "${{ github.repository }}" not in self_hosted_repos:
85+
# Outside of those repositories, we only run on x86_64 GH hosted runners (ubuntu-latest)
86+
for idx in range(len(matrix) - 1, -1, -1):
87+
if matrix[idx]["arch"] != Arch.x86_64.value:
88+
del matrix[idx]
89+
else:
90+
matrix[idx]["runs_on"] = ["ubuntu-latest"]
91+
else:
92+
# Otherwise, run on (self-hosted, arch) runners
93+
for idx in range(len(matrix) - 1, -1, -1):
94+
matrix[idx]["runs_on"].extend(["self-hosted", matrix[idx]["arch"]])
95+
96+
build_matrix = {"include": matrix}
97+
set_output("build_matrix", dumps(build_matrix))
98+
99+
tests = [
100+
"test_progs",
101+
"test_progs_parallel",
102+
"test_progs_no_alu32",
103+
"test_progs_no_alu32_parallel",
104+
"test_maps",
105+
"test_verifier",
106+
]
107+
test_matrix = {"include": [{**config, **generate_test_config(test)}
108+
for config in matrix
109+
for test in tests]}
110+
set_output("test_matrix", dumps(test_matrix))
111+
build:
112+
name: build for ${{ matrix.arch }} with ${{ matrix.toolchain }}
113+
needs: set-matrix
114+
runs-on: ${{ matrix.runs_on }}
115+
timeout-minutes: 100
116+
strategy:
117+
fail-fast: false
118+
matrix: ${{ fromJSON(needs.set-matrix.outputs.build-matrix) }}
119+
env:
120+
KERNEL: ${{ matrix.kernel }}
121+
REPO_ROOT: ${{ github.workspace }}
122+
REPO_PATH: ""
123+
KBUILD_OUTPUT: kbuild-output/
124+
steps:
125+
- uses: actions/checkout@v3
126+
# We fetch an actual bit of history here to facilitate incremental
127+
# builds (which may check out some earlier upstream change).
128+
with:
129+
fetch-depth: 50
130+
- if: ${{ github.repository == 'kernel-patches/vmtest' }}
131+
name: Download bpf-next tree
132+
uses: libbpf/ci/get-linux-source@master
133+
with:
134+
dest: '.kernel'
135+
- if: ${{ github.repository == 'kernel-patches/vmtest' }}
136+
name: Move linux source in place
137+
shell: bash
138+
run: |
139+
rm -rf .kernel/.git
140+
cp -rf .kernel/. .
141+
rm -rf .kernel
142+
- name: Get commit meta-data
143+
id: get-commit-metadata
144+
shell: bash
145+
run: |
146+
if [ ${{ github.event_name }} = 'push' ]; then
147+
echo "branch=${{ github.ref_name }}" >> "${GITHUB_OUTPUT}"
148+
# Ignore top most commit which just adds CI files.
149+
commit="$(git rev-parse HEAD^)"
150+
else
151+
echo "branch=${{ github.base_ref }}" >> "${GITHUB_OUTPUT}"
152+
# For pull requests we just use the current HEAD.
153+
commit="$(git rev-parse ${{ github.sha }})"
154+
fi
155+
echo "timestamp=$(TZ=utc git show --format='%cd' --no-patch --date=iso-strict-local ${commit})" >> "${GITHUB_OUTPUT}"
156+
echo "commit=${commit}" >> "${GITHUB_OUTPUT}"
157+
- name: Pull recent KBUILD_OUTPUT contents
158+
uses: actions/cache@v3
159+
with:
160+
path: ${{ env.KBUILD_OUTPUT }}
161+
key: kbuild-output-${{ matrix.arch }}-${{ matrix.toolchain }}-${{ steps.get-commit-metadata.outputs.branch }}-${{ steps.get-commit-metadata.outputs.timestamp }}-${{ steps.get-commit-metadata.outputs.commit }}
162+
restore-keys: |
163+
kbuild-output-${{ matrix.arch }}-${{ matrix.toolchain }}-${{ steps.get-commit-metadata.outputs.branch }}-${{ steps.get-commit-metadata.outputs.timestamp }}-
164+
kbuild-output-${{ matrix.arch }}-${{ matrix.toolchain }}-${{ steps.get-commit-metadata.outputs.branch }}-
165+
kbuild-output-${{ matrix.arch }}-${{ matrix.toolchain }}-
166+
- name: Prepare incremental build
167+
shell: bash
168+
run: |
169+
set -e -u
170+
171+
# $1 - the SHA-1 to fetch and check out
172+
fetch_and_checkout() {
173+
local build_base_sha="${1}"
174+
175+
# If cached artifacts became stale for one reason or another, we
176+
# may not have the build base SHA available. Fetch it and retry.
177+
git fetch origin "${build_base_sha}" && git checkout --quiet "${build_base_sha}"
178+
}
179+
180+
# $1 - value of KBUILD_OUTPUT
181+
clear_cache_artifacts() {
182+
local kbuild_output="${1}"
183+
echo "Unable to find earlier upstream ref. Discarding KBUILD_OUTPUT contents..."
184+
rm --recursive --force "${kbuild_output}"
185+
mkdir "${kbuild_output}"
186+
false
187+
}
188+
189+
# $1 - value of KBUILD_OUTPUT
190+
# $2 - current time in ISO 8601 format
191+
restore_source_code_times() {
192+
local kbuild_output="${1}"
193+
local current_time="${2}"
194+
local src_time="$(date --iso-8601=ns --date="${current_time} - 2 minutes")"
195+
local obj_time="$(date --iso-8601=ns --date="${current_time} - 1 minute")"
196+
197+
git ls-files | xargs --max-args=10000 touch -m --no-create --date="${src_time}"
198+
find "${kbuild_output}" -type f | xargs --max-args=10000 touch -m --no-create --date="${obj_time}"
199+
git checkout --quiet -
200+
echo "Adjusted src and obj time stamps relative to system time"
201+
}
202+
203+
mkdir --parents "${KBUILD_OUTPUT}"
204+
current_time="$(date --iso-8601=ns)"
205+
206+
if [ -f "${KBUILD_OUTPUT}/.build-base-sha" ]; then
207+
build_base_sha="$(cat "${KBUILD_OUTPUT}/.build-base-sha")"
208+
echo "Setting up base build state for ${build_base_sha}"
209+
210+
(
211+
git checkout --quiet "${build_base_sha}" \
212+
|| fetch_and_checkout "${build_base_sha}" \
213+
|| clear_cache_artifacts "${KBUILD_OUTPUT}"
214+
) && restore_source_code_times "${KBUILD_OUTPUT}" "${current_time}"
215+
else
216+
echo "No previous build data found"
217+
fi
218+
219+
echo -n "${{ steps.get-commit-metadata.outputs.commit }}" > "${KBUILD_OUTPUT}/.build-base-sha"
220+
- uses: libbpf/ci/patch-kernel@master
221+
with:
222+
patches-root: '${{ github.workspace }}/ci/diffs'
223+
repo-root: '${{ github.workspace }}'
224+
- name: Setup build environment
225+
uses: libbpf/ci/setup-build-env@master
226+
- name: Build kernel image
227+
uses: libbpf/ci/build-linux@master
228+
with:
229+
arch: ${{ matrix.arch }}
230+
toolchain: ${{ matrix.toolchain }}
231+
kbuild-output: ${{ env.KBUILD_OUTPUT }}
232+
max-make-jobs: 32
233+
- if: ${{ github.event_name != 'push' }}
234+
name: Build selftests
235+
uses: libbpf/ci/build-selftests@master
236+
with:
237+
toolchain: ${{ matrix.toolchain }}
238+
kbuild-output: ${{ env.KBUILD_OUTPUT }}
239+
max-make-jobs: 32
240+
- if: ${{ github.event_name != 'push' }}
241+
name: Build samples
242+
uses: libbpf/ci/build-samples@master
243+
with:
244+
toolchain: ${{ matrix.toolchain }}
245+
kbuild-output: ${{ env.KBUILD_OUTPUT }}
246+
max-make-jobs: 32
247+
- if: ${{ github.event_name != 'push' }}
248+
name: Tar artifacts
249+
run: |
250+
file_list=""
251+
if [ "${{ github.repository }}" == "kernel-patches/vmtest" ]; then
252+
# Package up a bunch of additional infrastructure to support running
253+
# 'make kernelrelease' and bpf tool checks later on.
254+
file_list="$(find . -iname Makefile | xargs) \
255+
scripts/ \
256+
tools/testing/selftests/bpf/ \
257+
tools/include/ \
258+
tools/bpf/bpftool/";
259+
fi
260+
# zstd is installed by default in the runner images.
261+
tar -cf - \
262+
"${KBUILD_OUTPUT}"/.config \
263+
"${KBUILD_OUTPUT}"/$(KBUILD_OUTPUT="${KBUILD_OUTPUT}" make -s image_name) \
264+
"${KBUILD_OUTPUT}"/include/config/auto.conf \
265+
"${KBUILD_OUTPUT}"/include/generated/autoconf.h \
266+
"${KBUILD_OUTPUT}"/vmlinux \
267+
${file_list} \
268+
--exclude '*.h' \
269+
selftests/bpf/ | zstd -T0 -19 -o vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.zst
270+
- if: ${{ github.event_name != 'push' }}
271+
name: Remove KBUILD_OUTPUT contents
272+
shell: bash
273+
run: |
274+
# Remove $KBUILD_OUTPUT to prevent cache creation for pull requests.
275+
# Only on pushed changes are build artifacts actually cached, because
276+
# of github.com/actions/cache's cache isolation logic.
277+
rm -rf "${KBUILD_OUTPUT}"
278+
- if: ${{ github.event_name != 'push' }}
279+
uses: actions/upload-artifact@v3
280+
with:
281+
name: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}
282+
if-no-files-found: error
283+
path: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.zst
284+
test:
285+
if: ${{ github.event_name != 'push' }}
286+
name: ${{ matrix.test }} on ${{ matrix.arch }} with ${{ matrix.toolchain }}
287+
needs: [set-matrix, build]
288+
strategy:
289+
fail-fast: false
290+
matrix: ${{ fromJSON(needs.set-matrix.outputs.test-matrix) }}
291+
runs-on: ${{ matrix.runs_on }}
292+
timeout-minutes: 100
293+
env:
294+
KERNEL: ${{ matrix.kernel }}
295+
REPO_ROOT: ${{ github.workspace }}
296+
REPO_PATH: ""
297+
KBUILD_OUTPUT: kbuild-output/
298+
steps:
299+
- uses: actions/checkout@v3
300+
- uses: actions/download-artifact@v3
301+
with:
302+
name: vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}
303+
path: .
304+
- name: Untar artifacts
305+
# zstd is installed by default in the runner images.
306+
run: zstd -d -T0 vmlinux-${{ matrix.arch }}-${{ matrix.toolchain }}.tar.zst --stdout | tar -xf -
307+
- name: Prepare rootfs
308+
uses: libbpf/ci/prepare-rootfs@master
309+
with:
310+
project-name: 'libbpf'
311+
arch: ${{ matrix.arch }}
312+
kernel: ${{ matrix.kernel }}
313+
kernel-root: '.'
314+
kbuild-output: ${{ env.KBUILD_OUTPUT }}
315+
image-output: '/tmp/root.img'
316+
test: ${{ matrix.test }}
317+
- name: Run selftests
318+
uses: libbpf/ci/run-qemu@master
319+
continue-on-error: ${{ matrix.continue_on_error }}
320+
timeout-minutes: ${{ matrix.timeout_minutes }}
321+
with:
322+
arch: ${{ matrix.arch}}
323+
img: '/tmp/root.img'
324+
vmlinuz: '${{ github.workspace }}/vmlinuz'
325+
kernel-root: '.'
326+
max-cpu: 8

README

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +0,0 @@
1-
Linux kernel
2-
============
3-
4-
There are several guides for kernel developers and users. These guides can
5-
be rendered in a number of formats, like HTML and PDF. Please read
6-
Documentation/admin-guide/README.rst first.
7-
8-
In order to build the documentation, use ``make htmldocs`` or
9-
``make pdfdocs``. The formatted documentation can also be read online at:
10-
11-
https://www.kernel.org/doc/html/latest/
12-
13-
There are various text files in the Documentation/ subdirectory,
14-
several of them using the Restructured Text markup notation.
15-
16-
Please read the Documentation/process/changes.rst file, as it contains the
17-
requirements for building and running the kernel, and information about
18-
the problems which may result by upgrading your kernel.

ci/diffs/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)