Skip to content

Commit

Permalink
gh action
Browse files Browse the repository at this point in the history
Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
  • Loading branch information
thehajime committed Nov 12, 2024
1 parent a0bb30b commit e0d035e
Show file tree
Hide file tree
Showing 20 changed files with 1,177 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM alpine:3.20.3

ADD vmlinux /root/.
ADD inittab /etc/inittab
RUN mkdir /etc/init.d
ADD rcS /etc/init.d/.
RUN sh -c "echo "nameserver 8.8.8.8" > /etc/resolv.conf"

ADD bench.sh /
ADD do_getpid /root/.
ADD clone /root/.
ADD futex /root/.
ADD nullptr /root/.
ADD ctest /root/.
ADD stackp /root/.
ADD init_array /root/.
ADD entropy /root/.
ADD locale /root/.
ADD Makefile /root/.
ADD lmbench2/ /lmbench2
ADD lmbench_run.sh /lmbench2/bin/x86_64-linux-gnulibc1/


RUN apk update && apk add utmps-libs libtirpc curl make
RUN mkdir -p setup && cd setup && curl -L -o output.zip \
'https://gitlab.alpinelinux.org/thehajime/aports/-/jobs/1574074/artifacts/download?file_type=archive'
RUN cd setup && unzip output.zip && \
tar xfz packages/main/x86_64/musl-nommu-1.2.5-r0.apk
RUN cp setup/lib/ld-musl-x86_64.so.1 /lib/
RUN apk add --allow-untrusted setup/packages/main/x86_64/busybox-nommu-1.36.1-r29.apk
RUN cp /bin/busybox.nommu /bin/busybox
RUN rm -rf setup

ENTRYPOINT ["/root/vmlinux", "eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.1", "root=/dev/root", "rootflags=/", "rootfstype=hostfs", "rw", "mem=1024m", "loglevel=8", "init=/sbin/init"]
24 changes: 24 additions & 0 deletions .github/workflows/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SRCS := clone.c futex.c nullptr.c ctest.c stackp.c do_getpid.c init_array.c entropy.c locale.c
BKUP := exit.c noop.c
TARGETS := $(SRCS:.c=)

CFLAGS_exit = -nostdlib -pie -fPIE -fomit-frame-pointer
all: ${TARGETS}

tests: ${TARGETS}
set +x
./clone host
./futex
./nullptr 1 0 || RET=$$? ; echo "code="$$RET && if [ "$$RET" -ne "139" ] ; then false ; fi
./nullptr 1 1 || RET=$$? ; echo "code="$$RET && if [ "$$RET" -ne "11" ] ; then false ; fi
./nullptr 0 0 || RET=$$? ; echo "code="$$RET && if [ "$$RET" -ne "139" ] ; then false ; fi
./nullptr 0 1 || RET=$$? ; echo "code="$$RET && if [ "$$RET" -ne "11" ] ; then false ; fi
./nullptr
echo "test" | ./ctest
./stackp
./entropy 10000
./locale
set -x

clean:
rm -f ${TARGETS}
13 changes: 13 additions & 0 deletions .github/workflows/bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

mount proc /proc -t proc
export PATH=/home:/sbin:/usr/sbin:/bin:/usr/bin


cd /lmbench2/bin/x86_64-linux-gnulibc1
sh lmbench_run.sh

/root/do_getpid -c 10000

make -C /root tests
halt -f
287 changes: 287 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
on:
push:
branches:
- '**'
#pull_request:
# branches:
# - master

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
testname: um-mmu
- displayTargetName: ubuntu-22.04 (nommu)
os: unix
runs_on: ubuntu-22.04
shell: bash
defconfig: x86_64_nommu_defconfig
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: 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 sparse
- name: Setup latest Alpine Linux
uses: jirutka/setup-alpine@v1
with:
branch: v3.20
packages: >
alpine-sdk
doas
libtirpc-dev
linux-headers
- name: build bench tools
run: |
git clone https://github.com/ricarkol/lmbench2.git
cd lmbench2
touch src/Makefile
touch Makefile
make
cd ..
make -C .github/workflows/
shell: alpine.sh {0}
# --root {0}
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# detached: true
- name: Setup faketty
uses: Yuri6037/Action-FakeTTY@v1.1
- 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
- name: prep for docker build
run: |
cp build/vmlinux .github/workflows/
cp -rpf lmbench2 .github/workflows/
- name: Build and push Docker image (no push)
uses: docker/build-push-action@v6
with:
context: .github/workflows
push: false
tags: |
ghcr.io/thehajime/alpine:3.20.3-${{ matrix.testname }}
- name: image for test
run: |
container_id=$(docker create ghcr.io/thehajime/alpine:3.20.3-${{ matrix.testname }})
docker start $container_id
docker wait $container_id
docker logs $container_id
docker export $container_id > alpine.tar
docker rm $container_id
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
- name: test-0 (static)
run: |
sudo sh -c "echo 0 > /proc/sys/vm/mmap_min_addr"
sudo ip tuntap add dev tap100 mode tap user ${USER}
faketty ./build/vmlinux eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.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
- name: test-1
run: |
faketty ./vmlinux eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.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
run: |
mkdir -p output
faketty ./vmlinux eth0=tuntap,tap100,0e:fd:0:0:0:1,172.17.0.1 ubd0=./alpine.ext4 rw mem=1024m \
loglevel=0 console=tty init=/bench.sh | tee output/${{ matrix.testname }}.dat
- 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
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 }}.dat

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
- name: build (sparse)
run: |
make ARCH=um W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited -fmax-warnings=unlimited' defconfig O=build-sparse
make ARCH=um W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited -fmax-warnings=unlimited' O=build-sparse clean
make ARCH=um W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited -fmax-warnings=unlimited' O=build-sparse -j8 >& old-sparse.log
git checkout zpoline-nommu-v6.10
git checkout HEAD~1
make ARCH=um W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited -fmax-warnings=unlimited' O=build-sparse clean
make ARCH=um W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__ -fmax-errors=unlimited -fmax-warnings=unlimited' O=build-sparse -j8 >& new-sparse.log
./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
- 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
- name: bench data parse/out
run: |
export TMP_OUTPUT=$(bash .github/workflows/um-nommu-plot.sh output)
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/lmbench.*
- name: publish to imgur
uses: devicons/public-upload-to-imgur@v2.2.2
id: publish-to-imgur
with:
path: "output/out/*.png"
client_id: ${{secrets.IMGUR_CLIENT_ID}}
- name: bench data parse/out
run: |
export SCRIPT_OUTPUT="${{ join(fromJSON(steps.publish-to-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
})
Loading

0 comments on commit e0d035e

Please sign in to comment.