Skip to content

Commit e432aff

Browse files
mbolivar-amperemarc-hb
authored andcommitted
Add docker compose based testing
Our release process documentation recommends getting passing tox results on as many popular linux distributions as time allows. Doing this by hand is cumbersome, redundant, and error prone. Add a directory with a helper script that automates the entire process using docker compose and document its use in MAINTAINERS.rst. Signed-off-by: Martí Bolívar <[email protected]> Signed-off-by: Pieter De Gendt <[email protected]>
1 parent 113ff95 commit e432aff

File tree

9 files changed

+192
-7
lines changed

9 files changed

+192
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ shippable/
1212
htmlcov/
1313
.dir-locals.el
1414
.venv/
15+
docker-testing/outdir

MAINTAINERS.rst

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,35 @@ Pre-release test plan
1111

1212
git checkout vX.Y-branch
1313

14-
1. Make tox happy on the following first-party platforms:
14+
1. Make tox happy on the following first-party non-Linux platforms:
1515

1616
- Windows 10
1717
- the latest macOS
18-
- the latest Ubuntu LTS
1918

20-
2. Make tox happy on other popular Linux distributions as resources allow.
21-
Doing this in a container is fine.
19+
Do this by hand and check for any anomalous warnings in the output.
20+
Do not just trust CI.
21+
22+
2. Make tox happy on other popular Linux distributions:
2223

2324
- Arch
24-
- the latest Ubuntu release (if different than the latest LTS)
25-
- Debian stable (if its Python 3 is still supported)
25+
- the latest Ubuntu LTS release
26+
- the latest Ubuntu development release
27+
- Debian stable
2628
- Debian testing
27-
- Fedora
29+
- the latest Fedora release
30+
- the latest Fedora rawhide release
31+
32+
Automated infrastructure for doing this in docker is in the docker-testing
33+
directory. Start by updating the Dockerfiles and compose.yaml in that
34+
directory if any newer distribution versions should be tested.
35+
36+
Then, install docker compose in your host Linux environment and run::
37+
38+
cd docker-testing
39+
./run-tests.sh
40+
41+
Make sure to check the tox.log files mentioned in the output for any
42+
anomalous warnings.
2843

2944
3. Build alpha N (N=1 to start, then N=2 if you need more commits, etc.) and
3045
upload to pypi. See "Building and uploading the release wheels" below for

docker-testing/README.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Docker based testing
2+
--------------------
3+
4+
This directory contains helper files used for running west's tests in Docker on
5+
various Linux runtimes. It was originally developed for release testing.
6+
7+
Run "./run-tests.sh" in this directory to run the tests.

docker-testing/arch/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ARG TARGET
2+
3+
FROM ${TARGET}
4+
5+
ARG TARGET
6+
ENV WEST_TARGET=${TARGET}
7+
8+
RUN pacman -Syu --noconfirm \
9+
git \
10+
python-pip \
11+
&& pacman -Scc --noconfirm
12+
13+
RUN pip3 install --break-system-packages tox

docker-testing/compose.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
x-common: &common
4+
user: ${MY_UID}:${MY_GID}
5+
volumes:
6+
- /etc/passwd:/etc/passwd:ro
7+
- /etc/group:/etc/group:ro
8+
- ..:/west
9+
command: /west/docker-testing/in-container-test.sh
10+
environment:
11+
WEST_TOX_OUT: /west/docker-testing/outdir
12+
WEST_TOX_OUT_IN_HOST: ${WEST_IN_HOST}/docker-testing/outdir
13+
14+
services:
15+
west-archlinux-latest:
16+
<<: *common
17+
build:
18+
args:
19+
TARGET: archlinux:latest
20+
dockerfile: arch/Dockerfile
21+
22+
west-debian-stable:
23+
<<: *common
24+
build:
25+
args:
26+
TARGET: debian:stable
27+
dockerfile: debian/Dockerfile
28+
29+
west-debian-testing:
30+
<<: *common
31+
build:
32+
args:
33+
TARGET: debian:testing
34+
dockerfile: debian/Dockerfile
35+
36+
west-fedora-latest:
37+
<<: *common
38+
build:
39+
args:
40+
TARGET: fedora:latest
41+
dockerfile: fedora/Dockerfile
42+
43+
west-fedora-rawhide:
44+
<<: *common
45+
build:
46+
args:
47+
TARGET: fedora:rawhide
48+
dockerfile: fedora/Dockerfile
49+
50+
west-ubuntu-latest:
51+
<<: *common
52+
build:
53+
args:
54+
TARGET: ubuntu:latest
55+
dockerfile: debian/Dockerfile
56+
57+
west-ubuntu-devel:
58+
<<: *common
59+
build:
60+
args:
61+
TARGET: ubuntu:devel
62+
dockerfile: debian/Dockerfile

docker-testing/debian/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ARG TARGET
2+
3+
FROM ${TARGET}
4+
5+
ARG TARGET
6+
ENV WEST_TARGET=${TARGET}
7+
8+
RUN apt-get update \
9+
&& apt-get install -y \
10+
git \
11+
python3-pip \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
RUN pip3 install --break-system-packages tox

docker-testing/fedora/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ARG TARGET
2+
3+
FROM ${TARGET}
4+
5+
ARG TARGET
6+
ENV WEST_TARGET=${TARGET}
7+
8+
RUN dnf install -y \
9+
git \
10+
python3-pip \
11+
&& dnf clean dbcache
12+
13+
RUN pip3 install tox

docker-testing/in-container-test.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# This is the test script that runs in the containers themselves.
5+
6+
WEST=/west
7+
# Replace semicolon with dash
8+
WEST_TARGET=${WEST_TARGET//:/-}
9+
10+
WEST_TOX_OUT=$WEST_TOX_OUT/$WEST_TARGET
11+
WEST_TOX_OUT_IN_HOST=$WEST_TOX_OUT_IN_HOST/$WEST_TARGET
12+
13+
die() {
14+
if [ $# -eq 0 ]; then
15+
echo "error: $*" >&2
16+
else
17+
echo "error: unknown error in $0" >&2
18+
fi
19+
exit 1
20+
}
21+
22+
main()
23+
{
24+
# Verify the container environment set up meets this script's requirements.
25+
[ -n "$WEST_TOX_OUT" ] || die "missing $WEST_TOX_OUT"
26+
[ -n "$WEST_TOX_OUT_IN_HOST" ] || die "missing $WEST_TOX_OUT_IN_HOST"
27+
[ -d "$WEST" ] || die "missing $WEST in the container"
28+
29+
TOX_LOG="$WEST_TOX_OUT/tox.log"
30+
TOX_LOG_IN_HOST="$WEST_TOX_OUT_IN_HOST/tox.log"
31+
WEST_TESTDIR="/tmp/west"
32+
33+
mkdir "$WEST_TOX_OUT"
34+
35+
git clone -q "$WEST" "$WEST_TESTDIR" || die "failed to clone west to $WEST_TESTDIR in container"
36+
cd "$WEST_TESTDIR"
37+
38+
echo "running tox, output in $TOX_LOG_IN_HOST in host"
39+
tox run >"$TOX_LOG" 2>&1 || die "tox failed, see $TOX_LOG"
40+
41+
cp -R htmlcov "$WEST_TOX_OUT" || die "failed to copy coverage to $WEST_TOX_OUT_IN_HOST/htmlcov in host"
42+
}
43+
44+
main "$@"

docker-testing/run-tests.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# This is the top-level test script that runs in the host.
4+
5+
HERE=$(dirname "$0")
6+
7+
[ -d "$HERE/outdir" ] && rm -r "$HERE/outdir"
8+
9+
set -e
10+
mkdir "$HERE/outdir"
11+
export MY_UID=$(id -u)
12+
export MY_GID=$(id -g)
13+
export WEST_IN_HOST=$(realpath "$HERE/..")
14+
# Store the final config as reference
15+
docker-compose config > $HERE/outdir/config.yml
16+
docker-compose up --force-recreate --build

0 commit comments

Comments
 (0)