Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 98a3362

Browse files
William Douglasbryteise
authored andcommitted
Rework clear linux docker container for test runs
Also skips a few tests that do not run well with docker (changing date and disk filling have a hard time). Adding comment for how to run docker (needs the --cap-add LINUX_IMMUTABLE option passed). Signed-off-by: William Douglas <[email protected]>
1 parent a960885 commit 98a3362

11 files changed

+63
-23
lines changed

docker/Dockerfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@
99
#
1010
#
1111

12+
# Build with the following:
13+
# docker build -t swupd-ci -f docker/Dockerfile .
14+
1215
FROM clearlinux:latest
13-
ADD dockerrun.sh /dockerrun.sh
14-
ADD https://download.clearlinux.org/releases/13010/clear/Swupd_Root.pem /usr/share/clear/update-ca/Swupd_Root.pem
15-
RUN swupd update && swupd bundle-add os-core-update-dev sysadmin-basic os-testsuite c-basic
16+
RUN swupd bundle-add os-core-update-dev sysadmin-basic os-testsuite c-basic haskell-basic
17+
RUN pip install coverxygen && stack install ShellCheck && mv /root/.local/bin/shellcheck /usr/bin/
18+
RUN useradd tester && usermod -aG wheelnopw tester
19+
COPY . /build
20+
RUN chown -R tester /build
21+
USER tester
22+
WORKDIR /build
1623

17-
CMD ["/dockerrun.sh"]
24+
# Requires docker run with: --cap-add LINUX_IMMUTABLE
25+
CMD ["/build/docker/dockerrun.sh"]

docker/dockerrun.sh

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212
# Enforce correct umask
1313
umask 0022
1414

15-
mkdir -p /build
16-
cd /build
17-
18-
if [[ ! -d /source ]]; then
19-
echo "Missing source tree!" >&2
20-
exit 1
21-
fi
22-
23-
# Copy all the files across to prevent contaminating the bind mount
24-
cp -Ra /source/. /build
25-
2615
die_fatal()
2716
{
2817
echo "$*"
@@ -38,18 +27,27 @@ die_log_fatal()
3827
fi
3928
exit 1
4029
}
41-
42-
jobCount="-j$(($(getconf _NPROCESSORS_ONLN)+1))"
30+
sudo chown -R tester .
4331

4432
# Fix file permissions in the event of dodgy umask
4533
find test/functional -exec chmod g-w {} \;
4634

4735
# Configure the build
4836
autoreconf --verbose --warnings=none --install --force || die_fatal "Configure failure"
49-
./configure || die_fatal "Configure failure"
50-
51-
# Build error
52-
make $jobCount || die_fatal "Build failure"
5337

54-
# Test suite failure, print the log
55-
make $jobCount check || die_log_fatal
38+
./configure CFLAGS="$CFLAGS -fsanitize=address -Werror" --prefix=/usr --with-fallback-capaths="$PWD"/swupd_test_certificates --with-systemdsystemunitdir=/usr/lib/systemd/system --with-config-file-path=./testconfig --enable-debug || die_fatal "Configure failure"
39+
40+
make -j$(nproc) || die_fatal "Build Failure"
41+
make compliant || die_fatal "make compliant failure"
42+
make shellcheck-all || die_fatal "make shellcheck-all failure"
43+
make docs-coverage || die_fatal "make docs-coverage failure"
44+
sudo make install || die_fatal "make install failure"
45+
make install-check || die_fatal "make install-check failure"
46+
make check -j$(nproc) || die_fatal "unit test failure"
47+
make distcheck -j$(nproc) || die_fatal "make distcheck failure"
48+
./test/code_analysis/check_api_changes.bats || die_fatal "api change check failure"
49+
./scripts/github_actions/run_check.bash 1 1 || die_log_fatal
50+
FILES="$(find test/functional/only_in_ci_slow/ -name "*.bats")"
51+
env RUNNING_IN_CI=true TESTS="$(echo $FILES)" make -e check || die_log_fatal
52+
FILES="$(find test/functional/only_in_ci_system/ -name "*.bats")"
53+
env SKIP_DATE_CHECK=true SKIP_DISK_SPACE=true RUNNING_IN_CI=true TESTS="$(echo $FILES)" make -e check || die_log_fatal

test/functional/only_in_ci_system/add-no-disk-space.bats

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ load "../testlib"
77

88
test_setup() {
99

10+
if [ -n "${SKIP_DISK_SPACE}" ]; then
11+
skip "Skipping disk space test"
12+
fi
13+
1014
# create a test environment with 10 MB of space
1115
create_test_environment -s 10 "$TEST_NAME"
1216

test/functional/only_in_ci_system/expired-certificate-latest.bats

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ test_setup() {
1515
if [ -z "${RUNNING_IN_CI}" ]; then
1616
skip "Skipping slow test for local development, test only runs in CI"
1717
fi
18+
if [ -n "${SKIP_DATE_CHECK}" ]; then
19+
skip "Skipping date test"
20+
fi
1821

1922
create_test_environment "$TEST_NAME"
2023
create_bundle -L -n test-bundle1 -f /file_1 "$TEST_NAME"

test/functional/only_in_ci_system/expired-certificate-mom.bats

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ test_setup() {
1515
if [ -z "${RUNNING_IN_CI}" ]; then
1616
skip "Skipping slow test for local development, test only runs in CI"
1717
fi
18+
if [ -n "${SKIP_DATE_CHECK}" ]; then
19+
skip "Skipping date test"
20+
fi
1821

1922
create_test_environment "$TEST_NAME"
2023
create_bundle -L -n test-bundle1 -f /file_1 "$TEST_NAME"

test/functional/only_in_ci_system/expired-certificate.bats

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ test_setup() {
1515
if [ -z "${RUNNING_IN_CI}" ]; then
1616
skip "Skipping slow test for local development, test only runs in CI"
1717
fi
18+
if [ -n "${SKIP_DATE_CHECK}" ]; then
19+
skip "Skipping date test"
20+
fi
21+
1822
create_test_environment "$TEST_NAME"
1923
create_bundle -n test-bundle -f /test-file "$TEST_NAME"
2024

test/functional/only_in_ci_system/list-no-disk-space.bats

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ load "../testlib"
77

88
test_setup() {
99

10+
if [ -n "${SKIP_DISK_SPACE}" ]; then
11+
skip "Skipping disk space test"
12+
fi
13+
1014
# create a test environment with 10 MB of space
1115
create_test_environment -s 10 "$TEST_NAME"
1216

test/functional/only_in_ci_system/remove-no-disk-space.bats

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ load "../testlib"
77

88
test_setup() {
99

10+
if [ -n "${SKIP_DISK_SPACE}" ]; then
11+
skip "Skipping disk space test"
12+
fi
13+
1014
# create a test environment with 10 MB of space
1115
create_test_environment -s 10 "$TEST_NAME"
1216

test/functional/only_in_ci_system/repair-no-disk-space.bats

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ load "../testlib"
77

88
test_setup() {
99

10+
if [ -n "${SKIP_DISK_SPACE}" ]; then
11+
skip "Skipping disk space test"
12+
fi
13+
1014
# create a test environment with 10 MB of space
1115
create_test_environment -s 10 "$TEST_NAME"
1216

test/functional/only_in_ci_system/search-no-disk-space.bats

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ load "../testlib"
77

88
test_setup() {
99

10+
if [ -n "${SKIP_DISK_SPACE}" ]; then
11+
skip "Skipping disk space test"
12+
fi
13+
1014
# create a test environment with 10 MB of space
1115
create_test_environment -s 3 "$TEST_NAME"
1216

0 commit comments

Comments
 (0)