Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/actions/build-kernel/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2024 ByteDance.

name: "Build Kernel"
description: build kernel from source code
inputs:
arch:
description: "architecture for Docker image"
required: true
distro-code:
description: "distro code for the Docker image"
required: true
runs:
using: "composite"
steps:
- name: BuildOSImageWithKernel
run: |
set -e

# configurations
code_path=${{ github.workspace }}/tmp/.github/code
docker_image=kernel_builder:${{ inputs.arch }}-${{ inputs.distro-code }}
artifacts_root=$(jq .artifacts < /etc/kci.conf | tr -d \")
artifacts_relpath=${{ inputs.arch }}/${{ inputs.distro-code }}/${{ github.event.pull_request.head.sha }}
os_image_root=$(jq .images < /etc/kci.conf | tr -d \")
os_image=${{ inputs.arch }}-${{ inputs.distro-code }}.qcow2
os_image_size=100G

# build Docker image
dockerfile="${{ inputs.arch }}-${{ inputs.distro-code }}.dockerfile"
docker build --network=host -t $docker_image -f $code_path/dockerfiles/$dockerfile .

# build kernel
artifacts_dir=$artifacts_root/$artifacts_relpath
mkdir -p $artifacts_dir
docker run --network=host --rm \
-v ${{ github.workspace }}:/linux/src \
-v $artifacts_dir:/linux/output \
-v $code_path/scripts/build.sh:/bin/build.sh \
$docker_image \
build.sh -j32

# create OS image
source_image_path=$os_image_root/$os_image
target_image_path=$artifacts_root/$artifacts_relpath/$os_image
cp $source_image_path $target_image_path
qemu-img resize $target_image_path $os_image_size
virt-customize \
-a $target_image_path \
--root-password password:kernelci \
--ssh-inject root \
--copy-in $code_path/configs/ltp-whitelist:/opt
shell: bash
15 changes: 15 additions & 0 deletions .github/actions/fetch-refs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2024 ByteDance.

name: "Fetch Code"
description: "fetch code from GitHub"
inputs:
depth:
description: depth for git fetch command
default: "2000"
runs:
using: "composite"
steps:
- name: FetchRefs
run: git fetch --no-tags --prune --depth=${{ inputs.depth }} origin +refs/heads/*:refs/remotes/origin/*
shell: bash
17 changes: 17 additions & 0 deletions .github/actions/prepare-ci-code/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2024 ByteDance.

name: "Prepare CI Code"
description: download ci code from 5.4.143-velinux branch
runs:
using: "composite"
steps:
- name: PrepareCICode
run: |
set -e

target=tmp
branch=5.4.143-velinux

git clone -b $branch ${{ github.server_url }}/${{ github.repository }}.git $target
shell: bash
55 changes: 55 additions & 0 deletions .github/actions/test-kernel/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2024 ByteDance.

name: "Test Kernel"
description: test the Kernel
inputs:
arch:
description: "Architecture for the Docker image"
required: true
distro-code:
description: "Distro code for the Docker image"
required: true
runs:
using: "composite"
steps:
- name: PrepareTestEnvironment
run: |
set -e

artifacts_root=$(jq .artifacts < /etc/kci.conf | tr -d \")
artifacts_dir=$artifacts_root/${{ inputs.arch }}/${{ inputs.distro-code }}/${{ github.event.pull_request.head.sha }}
code_path=${{ github.workspace }}/tmp/.github/code

python3 -m pip install virtualenv
python3 -m virtualenv $artifacts_dir/venv
source $artifacts_dir/venv/bin/activate

pip3 install -r $code_path/configs/ktest-requirements.txt
mkdir -p $artifacts_dir/log
shell: bash
- name: RunKernelTest
run: |
set -e

code_path=${{ github.workspace }}/tmp/.github/code
artifacts_root=$(jq .artifacts < /etc/kci.conf | tr -d \")
artifacts_relpath=${{ inputs.arch }}/${{ inputs.distro-code }}/${{ github.event.pull_request.head.sha }}
artifacts_dir=$artifacts_root/$artifacts_relpath
image=$artifacts_dir/${{ inputs.arch }}-${{ inputs.distro-code }}.qcow2
domain_name=${{ inputs.arch }}-${{ inputs.distro-code }}-${{ github.event.pull_request.head.sha }}
test_file=$code_path/tests/ltp.yml

cp -r $code_path/ktest ktest
cd ktest
source $artifacts_dir/venv/bin/activate

./kernel_test.py kvm \
--image $image \
--test-kvm $domain_name \
--ssh-auth-method sshkey \
--ssh-pubkey-file ~/.ssh/id_rsa.pub \
--kernel-package-dir $artifacts_dir \
--log-dir $artifacts_dir/log \
--tests-yml $test_file
shell: bash
12 changes: 12 additions & 0 deletions .github/code/configs/ktest-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
bcrypt==4.1.3
certifi==2024.7.4
cffi==1.15.1
charset-normalizer==3.3.2
cryptography==42.0.8
idna==3.7
paramiko==3.4.0
pycparser==2.21
PyNaCl==1.5.0
PyYAML==6.0.1
requests==2.31.0
schema==0.7.7
5 changes: 5 additions & 0 deletions .github/code/configs/ltp-whitelist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ioctl03
fanotify22
ioprio_set03
setsockopt08
statx04
47 changes: 47 additions & 0 deletions .github/code/dockerfiles/x86_64-buster.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2024 ByteDance.

FROM --platform=linux/amd64 debian:10

RUN mkdir /linux
RUN mkdir /linux/src
RUN mkdir /linux/output

RUN apt update
RUN apt install -y bc
RUN apt install -y bison
RUN apt install -y ccache
RUN apt install -y cpio
RUN apt install -y dpkg-dev
RUN apt install -y flex
RUN apt install -y gcc
RUN apt install -y git
RUN apt install -y kmod
RUN apt install -y libaudit-dev
RUN apt install -y libbfd-dev
RUN apt install -y libdw-dev
RUN apt install -y libelf-dev
RUN apt install -y libiberty-dev
RUN apt install -y liblzma-dev
RUN apt install -y libnuma-dev
RUN apt install -y libperl-dev
RUN apt install -y libslang2-dev
RUN apt install -y libssl-dev
RUN apt install -y libunwind-dev
RUN apt install -y libunwind8-dev
RUN apt install -y make
RUN apt install -y pkg-config
RUN apt install -y python
RUN apt install -y python3
RUN apt install -y python3-pip
RUN apt install -y python3-requests
RUN apt install -y rsync
RUN apt install -y lsb-release
RUN apt install -y python-dev
RUN apt install -y python3-dev
RUN apt install -y sshpass
RUN apt install -y debhelper

# WA for install pahole>=1.13
RUN echo "deb http://deb.debian.org/debian bullseye main" >> /etc/apt/sources.list
RUN apt update && apt install -y dwarves
82 changes: 82 additions & 0 deletions .github/code/ktest/basic_func.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/python3
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2024 ByteDance.

import os
import sys
import json
try:
# requests module doesn't come with the default Python3 package
import requests
except ImportError:
print("ERROR: Please install 'requests' module for python3:")
print(" sudo apt-get install python3-pip")
print(" sudo pip3 install requests")
raise
import time


def http_get(url, token):
headers = {
'Accept': 'application/json',
'Authorization': token,
}
response = requests.get(url=url, headers=headers)

if response.status_code != requests.codes.ok:
raise RuntimeError("Failed request external API, GET request URL: {url}, error: {response}, "
"status code: {status_code}".
format(url=url, response=response.json(), status_code=response.status_code))

response_data = response.json()
return response_data


def http_post(url, post_data_dict, token):

post_data = json.dumps(post_data_dict)
# content_length = str(len(post_data))
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': token,
}
response = requests.post(url=url, headers=headers, data=post_data)

if response.status_code != requests.codes.ok:
raise RuntimeError("Failed request external API, POST request URL: {url} with data: {data}, error: "
"{response}, status code: {status_code}".
format(url=url, data=post_data, response=response.json(), status_code=response.status_code))
response_data = response.json()
return response_data


def http_put(url, post_data_dict, token):

headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': token,
}
response = requests.put(url=url, headers=headers, json=post_data_dict)

if response.status_code != requests.codes.ok:
raise RuntimeError("Failed request external API, PUT request URL: {url} with data: {data}, error: "
"{response}, status code: {status_code}".
format(url=url, data=post_data_dict, response=response.json(),
status_code=response.status_code))
response_data = response.json()
return response_data


def local_print(message, begin_newline=False):
if begin_newline:
print()
timestamp = time.asctime(time.localtime(time.time()))
print("{timestamp} {msg}".format(timestamp=timestamp, msg=message))
sys.stdout.flush()


# for local debug
if __name__ == "__main__":
print(http_put("http://localhost:8080/api/jobs/cancel", {"job_ids": []}, ""))
Loading