Skip to content

Commit fc3d25f

Browse files
committed
ci: run unit & integration tests in GH Actions
The original CentOS CI infra no longer supports CentOS/RHEL 7, so let's run the upstream tests in GH Actions in a CentOS 7 container. There are several workarounds to make this work and some tests can't run there at all, but it's better than nothing (and we still run the internal test suite on RHEL 7 builds anyway). rhel-only Related: RHEL-61958
1 parent cd52946 commit fc3d25f

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

.github/workflows/ci.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
# vi: ts=2 sw=2 et:
3+
4+
name: Build & test
5+
on:
6+
pull_request:
7+
branches:
8+
- rhel-7.9
9+
10+
permissions:
11+
contents: read
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
jobs:
18+
centos7:
19+
runs-on: ubuntu-latest
20+
container:
21+
image: quay.io/centos/centos:7
22+
options: "--privileged -v /dev:/dev"
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: true
26+
strategy:
27+
fail-fast: false
28+
steps:
29+
- name: Configure repositories
30+
run: |
31+
# CentOS 7 is EOL, so we need to grab the repos from the CentOS Vault
32+
sed -i 's/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
33+
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=https://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
34+
yum clean all
35+
yum makecache
36+
37+
- name: Install build & test dependencies
38+
run: |
39+
yum-builddep -y systemd
40+
yum install -y dhclient e2fsprogs file git kernel kbd net-tools qemu-kvm strace systemd-journal-gateway systemd-resolved xfsprogs
41+
42+
# We can't use the actions/checkout action, since it's no longer compatible with some _very_ old images,
43+
# like CentOS 7. To circumvent this, let's make a poor man's version of the checkout action for our needs.
44+
- name: Checkout the repository
45+
run: |
46+
set -ux
47+
48+
git clone "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_WORKSPACE"
49+
cd "$GITHUB_WORKSPACE"
50+
git fetch -fu origin "refs/pull/$GITHUB_REF_NAME:pr"
51+
git checkout pr
52+
git log -2
53+
54+
- name: Build
55+
run: |
56+
set -x
57+
58+
./autogen.sh
59+
./configure --with-sysvinit-path=/etc/rc.d/init.d \
60+
--with-rc-local-script-path-start=/etc/rc.d/rc.local \
61+
--disable-timesyncd \
62+
--disable-kdbus \
63+
--disable-terminal \
64+
--enable-gtk-doc \
65+
--enable-compat-libs \
66+
--disable-sysusers \
67+
--disable-ldconfig \
68+
--enable-lz4
69+
make -j $(nproc)
70+
71+
- name: Run unit tests
72+
run: |
73+
set -ux
74+
75+
if ! make check; then
76+
cat ./test-suite.log
77+
exit 1
78+
fi
79+
80+
- name: Run integration tests
81+
run: |
82+
set -ux
83+
84+
export QEMU_BIN=/usr/libexec/qemu-kvm
85+
export QEMU_TIMEOUT=600
86+
export TEST_NO_NSPAWN=1
87+
export KERNEL_VER="$(rpm -q --qf '%{VERSION}-%{RELEASE}.%{ARCH}' kernel | head -n1)"
88+
export KERNEL_BIN="/boot/vmlinuz-$KERNEL_VER"
89+
export KERNEL_APPEND="systemd.default_standard_output=journal+console"
90+
export INITRD="$PWD/test.initrd"
91+
92+
# Note: skip TEST-02-CRYPTSETUP here, since dealing with udev in containers is pain
93+
readarray -t TESTS < <(find test/ -maxdepth 1 -name "TEST-*" ! -name "TEST-02-CRYPTSETUP" -type d | sort)
94+
[[ "${#TESTS[@]}" -gt 0 ]]
95+
96+
dracut -v --force --kver "$KERNEL_VER" --no-hostonly "$INITRD"
97+
98+
for test in "${TESTS[@]}"; do
99+
echo "::group::$test"
100+
make -C "$test" clean setup run clean
101+
echo "::endgroup::"
102+
done

0 commit comments

Comments
 (0)