Add convenience targets to `Makefile` which can run common sets of
tests. For now, add a target for pylint, module-unittests,
pipeline-runtime-tests, as well as all tests.
Currently, it is quite cumbersome to run a reasonable test-setup
locally. Pylint invokation is rather complex, the unittests and runtime
tests in ./test are mixed, and not all tests in ./test can necessarily
be run from a development system.
This commit prepares for a simpler setup:
* Add `make test-pylint` to run pylint as it is run by CI.
* Add `make test-module` to run all module-unittests. This is meant to
be fast (preferably close to instant) and easy to run during
development to do a short check whether there are obvious typos or
other errors in local changes.
If we can keep these tests to machine-local requirements, if we
avoid any sleeps or heavy computations, then this will remain a
convenient test-suite to run locally without having to wait for
30min. In other words: We should be able to keep this under 10s (and
for the long term under 1min) easily.
* Add `make test-runtime` to run all osbuild pipeline executions. This
is not meant to be fast, but thorough. This will require external
sources (preferably limited to a suitable container image with
everything embedded). This will very likely not be run during
development, but rather by the CI.
* Add `make test-all` to run all tests. Very handy for shy people when
the chance of embarrassing copy-paste mistakes is too high to push
publicly.
Additionally to these new targets, this PR introduces 2 new directories
in ./test: ./test/mod/ and ./test/run/
These are meant as equivalent to `test-module` and `test-runtime`. The
reason is that preferably we stick to the auto-discovery of `unittest`
to enumerate tests, rather than enrolling our own or having to enumerate
them explicitly somewhere.
However, we need some way to tell `unittest` which test belongs into
which group. The easiest setup is likely to just use sub-directories.
Note that `test-all` picks all tests independently of where they are
put, even if they are in further different sub-modules under ./test.
For now, no tests are moved into the new directories. I expect this to
take a bit, since there are several out-standing PRs that modify ./test.
I intend to do the final move once we agreed on this and we synchronized
our test-modifications.
132 lines
3.2 KiB
YAML
132 lines
3.2 KiB
YAML
name: Tests
|
|
|
|
on: [pull_request, push]
|
|
|
|
jobs:
|
|
pylint:
|
|
name: "pylint"
|
|
runs-on: ubuntu-latest
|
|
container: docker.io/library/python:3.7
|
|
steps:
|
|
- name: Install pylint
|
|
run: pip install pylint==2.4.1
|
|
- name: Clone repository
|
|
uses: actions/checkout@v2
|
|
- name: Run pylint
|
|
run: make test-pylint
|
|
|
|
module:
|
|
name: "Module Unittests"
|
|
runs-on: ubuntu-latest
|
|
container: docker.io/library/python:3.7
|
|
steps:
|
|
- name: Clone repository
|
|
uses: actions/checkout@v2
|
|
- name: Run Module Unittests
|
|
run: make test-module
|
|
|
|
documentation:
|
|
name: "📚 Documentation"
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: docker.io/library/python:3.7
|
|
steps:
|
|
- name: Install Dependencies
|
|
run: |
|
|
pip install docutils
|
|
|
|
- name: Clone repository
|
|
uses: actions/checkout@v2
|
|
with:
|
|
path: osbuild
|
|
|
|
- name: Generate Documentation
|
|
run: |
|
|
make \
|
|
-f osbuild/Makefile \
|
|
SRCDIR=osbuild \
|
|
BUILDDIR=build \
|
|
RST2MAN=rst2man.py \
|
|
man
|
|
|
|
- name: Verify Documentation
|
|
working-directory: build
|
|
run: |
|
|
test -d docs
|
|
test -f docs/osbuild.1
|
|
|
|
unit_tests:
|
|
name: "unit"
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: docker.io/library/python:3.7
|
|
options: --privileged # Needed for bind mounts in unit tests
|
|
steps:
|
|
- name: Clone repository
|
|
uses: actions/checkout@v2
|
|
with:
|
|
path: osbuild
|
|
|
|
- name: Run test_osbuild
|
|
run: |
|
|
cd osbuild
|
|
python3 -m unittest -v test.test_osbuild
|
|
|
|
- name: Run test_objectstore
|
|
run: |
|
|
cd osbuild
|
|
python3 -m unittest -v test.test_objectstore
|
|
|
|
- name: Run test_osrelease
|
|
run: |
|
|
cd osbuild
|
|
python3 -m unittest -v test.test_osrelease
|
|
|
|
- name: Run test_util_ostree
|
|
run: |
|
|
cd osbuild
|
|
python3 -m unittest -v test.test_util_ostree
|
|
|
|
- name: Run test_util_selinux
|
|
run: |
|
|
cd osbuild
|
|
python3 -m unittest -v test.test_util_selinux
|
|
|
|
rpm_build:
|
|
name: "📦 RPM"
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
fedora_release: ["31", "32", "33"]
|
|
container:
|
|
image: "quay.io/osbuild/osbuild-fedora${{ matrix.fedora_release }}:latest"
|
|
steps:
|
|
- name: "📥 Prepare container"
|
|
run: |
|
|
echo "fastestmirror=1" >> /etc/dnf/dnf.conf
|
|
echo "install_weak_deps=0" >> /etc/dnf/dnf.conf
|
|
rm -fv /etc/yum.repos.d/fedora*modular*
|
|
|
|
- name: "🗄️ Clone the repository"
|
|
uses: actions/checkout@v2
|
|
|
|
- name: "🛒 Install RPM build dependencies"
|
|
run: dnf -y builddep osbuild.spec
|
|
|
|
- name: "🛠️ Build RPMs"
|
|
run: |
|
|
mkdir rpms
|
|
make srpm
|
|
cp -av rpmbuild/SRPMS/*.rpm rpms/
|
|
make rpm
|
|
cp -av rpmbuild/RPMS/*/*.rpm rpms/
|
|
|
|
- name: "📤 Upload artifacts"
|
|
uses: actions/upload-artifact@v1
|
|
with:
|
|
name: rpms
|
|
path: rpms/
|
|
|
|
- name: "🔎 Test RPM installation"
|
|
run: dnf -y install $(ls rpms/*.noarch.rpm)
|