gh action #555
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- '**' | |
#pull_request: | |
# branches: | |
# - master | |
workflow_dispatch: | |
inputs: | |
debug_enabled: | |
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' | |
required: false | |
default: true | |
jobs: | |
tests: | |
runs-on: ${{ matrix.runs_on }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- displayTargetName: ubuntu-22.04 | |
os: unix | |
runs_on: ubuntu-22.04 | |
shell: bash | |
defconfig: defconfig | |
add_configs: CONFIG_UML_NET_VECTOR=y CFLAGS+="-DCONFIG_UML_NET_VECTOR" | |
testname: um-mmu | |
- displayTargetName: ubuntu-22.04 (nommu) | |
os: unix | |
runs_on: ubuntu-22.04 | |
shell: bash | |
defconfig: x86_64_nommu_defconfig | |
add_configs: CONFIG_UML_NET_VECTOR=y CFLAGS+="-DCONFIG_UML_NET_VECTOR" | |
kunit_opts: --kconfig_add CONFIG_MMU=n | |
testname: um-nommu | |
timeout-minutes: 100 | |
env: | |
CCACHE_DIR: ${{ github.workspace }}/.ccache | |
USE_CCACHE: 1 | |
defaults: | |
run: | |
shell: ${{ matrix.shell }} | |
steps: | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} | |
with: | |
detached: true | |
- name: Set env | |
shell: bash | |
run: | | |
echo "/usr/lib/ccache/bin:/usr/lib/ccache:${{ github.workspace }}/bin" >> $GITHUB_PATH | |
echo "export PATH=/usr/lib/ccache/bin:/usr/lib/ccache:${{ github.workspace }}/bin:$PATH" >> $HOME/.bashrc | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ env.CCACHE_DIR }} | |
key: ${{ runner.os }}-${{ matrix.defconfig }}-ccache-build-${{ github.sha }} | |
restore-keys: ${{ runner.os }}-${{ matrix.defconfig }}-ccache-build- | |
- name: Install packages | |
run: | | |
sudo apt update -y | |
sudo apt install -y ccache iperf3 netperf gdb | |
- name: Setup latest Alpine Linux | |
uses: jirutka/setup-alpine@v1 | |
with: | |
branch: v3.20 | |
packages: > | |
alpine-sdk | |
doas | |
libtirpc-dev | |
linux-headers | |
autoconf | |
automake | |
- name: build bench tools | |
run: | | |
git clone https://github.com/ricarkol/lmbench2.git | |
git clone https://github.com/HewlettPackard/netperf | |
cd lmbench2 | |
touch src/Makefile | |
touch Makefile | |
make | |
cd .. | |
cd netperf | |
sh autogen.sh | |
./configure; make CFLAGS="-fcommon" || true | |
cd .. | |
make -C .github/workflows/ | |
shell: alpine.sh {0} | |
# --root {0} | |
- name: Setup faketty | |
uses: Yuri6037/Action-FakeTTY@v1.1 | |
- name: setup tap interface | |
run: | | |
set -x | |
sudo ip tuntap add dev tap100 mode tap user ${USER} | |
sudo ip add add 192.168.122.1/24 dev tap100 | |
sudo ip link set up dev tap100 | |
cp .github/workflows/gdbinit ~/.gdbinit | |
iperf3 -s & | |
- name: build-0 (static) | |
run: | | |
make ARCH=um ${{ matrix.defconfig }} O=build | |
cat build/.config | sed "s/.*CONFIG_STATIC_LINK.*/CONFIG_STATIC_LINK=y/" > /tmp/a; mv /tmp/a build/.config | |
make -j8 ARCH=um O=build ${{ matrix.add_configs }} | |
- name: prep for docker build | |
run: | | |
cp build/vmlinux .github/workflows/ | |
cp -rpf lmbench2 .github/workflows/ | |
cp netperf/src/netperf .github/workflows/ | |
- name: Build and push Docker image (no push) | |
uses: docker/build-push-action@v6 | |
with: | |
context: .github/workflows | |
build-args: "MODE=${{ matrix.testname }}" | |
push: false | |
tags: | | |
ghcr.io/thehajime/alpine:3.20.3-${{ matrix.testname }} | |
- name: image for test | |
run: | | |
docker create --name alpine-nommu ghcr.io/thehajime/alpine:3.20.3-${{ matrix.testname }} | |
docker start alpine-nommu | |
docker wait alpine-nommu | |
docker logs alpine-nommu | |
docker export alpine-nommu > alpine.tar | |
docker rm alpine-nommu | |
mnt=$(mktemp -d) | |
dd if=/dev/zero of=alpine.ext4 bs=1 count=0 seek=1G | |
sudo chmod og+wr "alpine.ext4" | |
yes 2>/dev/null | mkfs.ext4 "alpine.ext4" || true | |
sudo mount "alpine.ext4" $mnt | |
sudo tar -xf alpine.tar -C $mnt | |
sudo umount $mnt | |
mkdir -p rootfs | |
sudo tar -xf alpine.tar -C rootfs | |
sudo chown -R ${USER} rootfs | |
- name: test-0 (static) | |
run: | | |
sudo sh -c "echo 0 > /proc/sys/vm/mmap_min_addr" | |
faketty ./build/vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 ubd0=./alpine.ext4 rw mem=1024m loglevel=8 console=tty init=/sbin/init 2>&1 | tee /tmp/log.txt & | |
sleep 10 && pkill vmlinux | |
echo "=========" | |
cat /tmp/log.txt | |
- name: kunit test | |
run: | | |
for config in `find ./ -name .kunitconfig | grep -v -E "kfence|sunrpc|handshake|kcsan|gpu|damon" `; do \ | |
echo "==" $config "==" ; \ | |
./tools/testing/kunit/kunit.py run --kunitconfig=$config ${{ matrix.kunit_opts }} | |
done | |
- name: build-1 | |
run: | | |
make ARCH=um ${{ matrix.defconfig }} | |
make -j8 ARCH=um ${{ matrix.add_configs }} | |
- name: test-1 | |
run: | | |
faketty ./vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 ubd0=./alpine.ext4 rw mem=1024m loglevel=8 init=/sbin/init 2>&1 | tee /tmp/log.txt & | |
sleep 10 && pkill vmlinux | |
echo "=========" | |
cat /tmp/log.txt | |
- name: benchmark-0 | |
if: matrix.testname == 'um-nommu' | |
run: | | |
mkdir -p output | |
## disable zpoline test for a while | |
faketty ./vmlinux ubd0=./alpine.ext4 rw mem=1024m loglevel=8 console=tty zpoline=1 init=/bench.sh \ | |
| tee output/${{ matrix.testname }}-zpoline.dat # XXX: until 6.12 pulled | |
faketty ./vmlinux ubd0=./alpine.ext4 rw mem=1024m loglevel=8 console=tty zpoline=0 init=/bench.sh \ | |
| tee output/${{ matrix.testname }}-seccomp.dat # XXX: until 6.12 pulled | |
- name: benchmark-1 | |
if: matrix.testname == 'um-mmu' | |
run: | | |
mkdir -p output | |
faketty ./vmlinux ubd0=./alpine.ext4 rw mem=1024m loglevel=0 console=tty init=/bench.sh \ | |
| tee output/${{ matrix.testname }}.dat | |
- name: benchmark-2-iperf3 | |
run: | | |
mkdir -p output | |
if [ "${{ matrix.testname }}" == "um-nommu" ] ; then | |
## dynamic build failed at iperf -R | |
echo "===========================non-static build may fail...===========================" | |
#faketty ./vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 mem=1024m \ | |
# root=/dev/root rootflags=`pwd`/rootfs rootfstype=hostfs rw \ | |
# loglevel=0 console=tty init=/root/iperf3.sh \ | |
# | tee output/${{ matrix.testname }}-seccomp-iperf3.dat | |
faketty ./vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 mem=1024m \ | |
root=/dev/root rootflags=`pwd`/rootfs rootfstype=hostfs rw \ | |
loglevel=0 console=tty zpoline=1 init=/root/iperf3.sh \ | |
| tee output/${{ matrix.testname }}-zpoline-iperf3.dat | |
faketty ./build/vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 mem=1024m \ | |
root=/dev/root rootflags=`pwd`/rootfs rootfstype=hostfs rw \ | |
loglevel=0 console=tty init=/root/iperf3.sh \ | |
| tee output/${{ matrix.testname }}-seccomp-iperf3.dat | |
faketty ./build/vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 mem=1024m \ | |
root=/dev/root rootflags=`pwd`/rootfs rootfstype=hostfs rw \ | |
loglevel=0 console=tty zpoline=1 init=/root/iperf3.sh \ | |
| tee output/${{ matrix.testname }}-zpoline-iperf3.dat | |
else | |
faketty ./vmlinux vec0:transport=tap,ifname=tap100,depth=128,gro=1 mem=1024m \ | |
root=/dev/root rootflags=`pwd`/rootfs rootfstype=hostfs rw \ | |
loglevel=0 console=tty init=/root/iperf3.sh \ | |
| tee output/${{ matrix.testname }}-iperf3.dat | |
fi | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver-opts: network=host | |
- name: Log in to the ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: .github/workflows | |
build-args: "MODE=${{ matrix.testname }}" | |
push: true | |
tags: | | |
ghcr.io/thehajime/alpine:3.20.3-${{ matrix.testname }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: bench-result-${{ matrix.testname }} | |
path: output/${{ matrix.testname }}* | |
checkpatch: | |
runs-on: ubuntu-22.04 | |
name: checkpatch and co | |
env: | |
CCACHE_DIR: ${{ github.workspace }}/.ccache | |
USE_CCACHE: 1 | |
steps: | |
- name: Set env | |
shell: bash | |
run: | | |
echo "/usr/lib/ccache/bin:/usr/lib/ccache:${{ github.workspace }}/bin" >> $GITHUB_PATH | |
echo "export PATH=/usr/lib/ccache/bin:/usr/lib/ccache:${{ github.workspace }}/bin:$PATH" >> $HOME/.bashrc | |
- name: Checkout | |
with: | |
fetch-depth: 0 | |
uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ env.CCACHE_DIR }} | |
key: ${{ runner.os }}-checkpatch-ccache-build-${{ github.sha }} | |
restore-keys: ${{ runner.os }}-checkpatch-ccache-build- | |
- name: Install packages | |
run: | | |
sudo pip install ply GitPython mypy | |
sudo apt update -y | |
sudo apt install -y aspell ccache sparse | |
git clone https://github.com/daxtens/smart-sparse-diff | |
#- name: Setup tmate session | |
# uses: mxschmitt/action-tmate@v3 | |
# with: | |
# detached: true | |
- name: checkout trees | |
run: | | |
#git remote add linus git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git | |
#git fetch linus | |
#git format-patch -o p1 linus/master..HEAD~1 | |
git remote add uml git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux.git | |
git fetch uml | |
git checkout uml/next | |
git checkout zpoline-nommu-v6.10 | |
#- name: build (sparse) | |
# run: | | |
# make ARCH=um W=1 C=2 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited -fmax-warnings=unlimited' defconfig O=build-sparse | |
# make ARCH=um W=1 C=2 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited -fmax-warnings=unlimited' O=build-sparse clean | |
# make ARCH=um W=1 C=2 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited -fmax-warnings=unlimited' O=build-sparse -j8 2> old-sparse.log 1> /dev/null | |
# git checkout zpoline-nommu-v6.10 | |
# git checkout HEAD~1 | |
# make ARCH=um W=1 C=2 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited -fmax-warnings=unlimited' O=build-sparse -j8 2> new-sparse.log 1> /dev/null | |
# ./smart-sparse-diff/smart-sparse-diff.py old-sparse.log new-sparse.log | |
- name: check coding style | |
run: | | |
git format-patch -o p1 uml/next..HEAD~1 | |
./scripts/checkpatch.pl --summary-file --ignore FILE_PATH_CHANGES \ | |
--ignore AVOID_EXTERNS p1/*.patch | |
- name: check spells on commit message | |
continue-on-error: true | |
run: | | |
git log uml/next..HEAD |grep -v -E "^commit" > /tmp/a | |
aspell list /tmp/a | |
exit 1 | |
bench-result: | |
runs-on: ubuntu-22.04 | |
name: bench-result | |
needs: tests | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
path: output | |
pattern: bench-result-* | |
merge-multiple: true | |
- name: Display structure of downloaded files | |
run: ls -R output | |
- name: Install packages | |
run: | | |
sudo apt update -y | |
sudo apt install -y gnuplot lmbench iperf3 netperf | |
- name: benchmark-host | |
run: | | |
mkdir -p output | |
sudo ln -s /usr/include/x86_64-linux-gnu/sys /usr/include/sys | |
sudo mkdir -p /var/tmp/lmbench/ | |
sudo chown ${USER} /var/tmp/lmbench/ | |
sh .github/workflows/lmbench_run.sh |& tee output/native.dat | |
gcc -o do_getpid .github/workflows/do_getpid.c | |
./do_getpid -c 100 | tee -a output/native.dat | |
iperf3 -s & | |
iperf3 -c localhost -fm | tee output/native-iperf3.dat | |
iperf3 -c localhost -fm -R | tee -a output/native-iperf3.dat | |
bash .github/workflows/netperf-bench.sh localhost netperf | tee -a output/native-iperf3.dat | |
- name: bench data parse/out | |
run: | | |
bash .github/workflows/um-nommu-plot.sh output |& tee um-nommu.log | |
bash .github/workflows/netperf-plot.sh output | |
export TMP_OUTPUT=$(cat um-nommu.log) | |
echo "TMP_OUTPUT<<EOF" >> $GITHUB_ENV | |
echo "$TMP_OUTPUT" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
echo ${{env.TMP_OUTPUT}} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: bench-result-all | |
path: output/out/* | |
- name: publish to imgur | |
uses: devicons/public-upload-to-imgur@v2.2.2 | |
id: lmbench-imgur | |
with: | |
path: "output/out/lmbench.png" | |
client_id: ${{secrets.IMGUR_CLIENT_ID}} | |
- name: publish to imgur-iperf | |
uses: devicons/public-upload-to-imgur@v2.2.2 | |
id: iperf3-imgur | |
with: | |
path: "output/out/iperf3.png" | |
client_id: ${{secrets.IMGUR_CLIENT_ID}} | |
- name: publish to imgur-netperf | |
uses: devicons/public-upload-to-imgur@v2.2.2 | |
id: netperf-imgur | |
with: | |
path: "output/out/tcp-stream.png" | |
client_id: ${{secrets.IMGUR_CLIENT_ID}} | |
- name: prepare action post | |
run: | | |
export SCRIPT_OUTPUT="${{ join(fromJSON(steps.lmbench-imgur.outputs.markdown_urls)) }} ${{ join(fromJSON(steps.iperf3-imgur.outputs.markdown_urls)) }} ${{ join(fromJSON(steps.netperf-imgur.outputs.markdown_urls)) }}" | |
echo "SCRIPT_OUTPUT<<EOF" >> $GITHUB_ENV | |
echo "$TMP_OUTPUT" >> $GITHUB_ENV | |
echo "" >> $GITHUB_ENV | |
echo "$SCRIPT_OUTPUT" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
echo ${{env.SCRIPT_OUTPUT}} | |
- uses: actions/github-script@v7 | |
env: | |
COMMENT_BODY: ${{env.SCRIPT_OUTPUT}} | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: 1, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: process.env.COMMENT_BODY | |
}) |