Commit 23864917 authored by Emeric Verschuur's avatar Emeric Verschuur

[CI] Add testsuites for RPM and DEB packages

parent f48a6b8b
Pipeline #23400695 passed with stages
in 8 minutes and 49 seconds
......@@ -117,3 +117,46 @@ build-package-dev-deb: *build-package-dev
build-package-dev-rpm: *build-package-dev
build-package-rel-deb: *build-package-rel
build-package-rel-rpm: *build-package-rel
##################################################
# ### PACKAGE TESTSUITES ### #
##################################################
.test-package-template: &test-package-template
stage: test
variables:
CITBX_JOB_RUN_FILE_NAME: test-package.sh
tags: ["docker"]
script: ["ci-scripts/run-job-script.sh"]
test-package-deb-dev-ubuntu-18.04:
image: ubuntu:16.04
dependencies: ["build-package-dev-deb"]
<<: *test-package-template
<<: *package-channel-dev
test-package-deb-dev-ubuntu-16.04:
image: ubuntu:16.04
dependencies: ["build-package-dev-deb"]
<<: *test-package-template
<<: *package-channel-dev
test-package-rpm-dev-fedora-27:
image: fedora:27
dependencies: ["build-package-dev-rpm"]
<<: *test-package-template
<<: *package-channel-dev
test-package-deb-rel-ubuntu-18.04:
image: ubuntu:16.04
dependencies: ["build-package-rel-deb"]
<<: *test-package-template
<<: *package-channel-rel
test-package-deb-rel-ubuntu-14.04:
image: ubuntu:16.04
dependencies: ["build-package-rel-deb"]
<<: *test-package-template
<<: *package-channel-rel
test-package-rpm-rel-fedora-27:
image: fedora:27
dependencies: ["build-package-rel-rpm"]
<<: *test-package-template
<<: *package-channel-rel
......@@ -12,6 +12,7 @@
* [modules/runshell] Add runshell module to run a shell on a specific build step, useful for debugging
* [ci-toolbox] Add options to manage Docker configuration propagation
* [packaging] Add build-package job for Debian-like and RedHat-like operating systems
* [CI] Add testsuites for RPM and DEB packages
## 4.1.0
* [env-setup/common] update install_tools function
......
citbx_use runshell
CITBX_PACKAGE_NAME="ci-toolbox"
job_define() {
CITBX_UID=0
}
job_setup() {
CI_COMMIT_REF_NAME=$(git rev-parse --abbrev-ref HEAD)
TEST_USER_UID=$(id -u)
TEST_USER_HOME=$HOME
citbx_export CI_COMMIT_REF_NAME TEST_USER_UID TEST_USER_HOME
citbx_docker_run_add_args --privileged
}
job_main() {
case "$CI_JOB_NAME" in
test-package-rpm-*)
dnf install -y sudo psmisc
dnf install -y ./artifacts/ci-toolbox.rpm
;;
test-package-deb-*)
apt update
apt -y install sudo psmisc
apt -y install ./artifacts/ci-toolbox.deb
;;
esac
case "$CI_JOB_NAME" in
*-rel-*)
export CITBX_PACKAGE_CHANNEL=rel
;;
*-dev-*)
export CITBX_PACKAGE_CHANNEL=dev
;;
esac
if [ -z "$TEST_USER_UID" ]; then
TEST_USER_UID=1000
fi
if [ -z "$TEST_USER_HOME" ]; then
TEST_USER_HOME=/home/testuser
fi
print_info "### STEP1 ### Environment setup"
useradd -o -u $TEST_USER_UID -s /bin/sh -d $TEST_USER_HOME -M test-user
echo "test-user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
if [ ! -d "$TEST_USER_HOME" ]; then
mkdir -p "$TEST_USER_HOME"
chown test-user:test-user "$TEST_USER_HOME"
fi
print_info "### STEP2 ### ci-toolbox setup"
sudo -u test-user env HOME="$TEST_USER_HOME" \
ci-toolbox setup "$CI_COMMIT_REF_NAME" \
--docker-storage-driver overlay2 \
--docker-bip "172.30.0.1/24" \
--docker-cdir "172.30.0.0/24" \
--docker-dns 9.9.9.9 \
--component base-pkgs \
--component docker-cfg \
--component git-lfs \
--component ca-certs
print_info "### STEP3 ### Docker daemon start"
dockerd --data-root "$CI_PROJECT_DIR/testdir/docker/data"&
echo -n "Waiting for docker daemon"
until [ -e /var/run/docker.sock ]; do sleep 1; echo -n "."; done
print_info "### STEP3 ### job-* exec"
for j in $(ci-toolbox | grep '^ job-'); do
print_info "### JOB ### Running job $j..."
sudo -u test-user env HOME="$TEST_USER_HOME" ci-toolbox $j
done
}
job_after() {
if [ -f /var/run/docker.pid ]; then
# Kill the docker daemon
local pid=$(cat /var/run/docker.pid)
kill $pid || true
wait $pid || true
fi
# Remove testdir and ignore errors
rm -rf testdir || true
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment