debian-forge/.github/workflows/tests.yml
Christian Kellner a2cbed0ceb tests: copy on write checks for objectstore.Object
Verify the copy on write semantics of `objectstore.Object`, i.e.
content will only be copied at the moment a client wants to write
to `Object`. This also checks that `Object.base` works.

Modify the CI to execute the unit tests in a privileged container
because `Object.read()` works internally by bind mounting a path.
The mount operation needs at least CAP_SYS_ADMIN and overwriting
the file permissions CAP_DAC_OVERRIDE.
2020-02-28 16:11:49 +01:00

126 lines
3.3 KiB
YAML

name: Tests
# NOTE(mhayden): Restricting branches prevents jobs from being doubled since
# a push to a pull request triggers two events.
on:
pull_request:
branches:
- "*"
push:
branches:
- master
jobs:
pylint:
name: "pylint"
runs-on: ubuntu-latest
container:
image: docker.io/library/python:3.7
steps:
- name: Install pylint
run: pip install pylint==2.4.1
- name: Clone repository
uses: actions/checkout@v2
with:
path: osbuild
- name: Run pylint
run: |
cd osbuild
pylint osbuild runners/* assemblers/* stages/* sources/*
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
rpm_build:
name: "RPM build"
needs:
- pylint
- unit_tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
fedora_release: ["31", "32", "rawhide"]
container:
image: "docker.io/library/fedora:${{ matrix.fedora_release }}"
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*
dnf -y upgrade
dnf -y install dnf-plugins-core rpm-build rpmdevtools
- name: Fetch .spec file
run: |
mkdir spec
# Fetch the spec file at the given commit, and prepend the commit sha to it
curl "https://raw.githubusercontent.com/osbuild/osbuild/${GITHUB_SHA}/osbuild.spec" -o osbuild.spec
echo "%global commit ${GITHUB_SHA}" | cat - osbuild.spec > spec/osbuild.spec
- name: Install RPM build dependencies
run: dnf -y builddep spec/osbuild.spec
- name: Fetch sources
run: |
mkdir sources
spectool -g spec/osbuild.spec -C sources/
- name: Build SRPM
run: |
mkdir srpms
rpmbuild -bs \
--define "_sourcedir sources" \
--define "_srcrpmdir srpms" \
spec/osbuild.spec
- name: Build RPMs
run: |
mkdir rpmbuild rpms build
rpmbuild -bb \
--define "_sourcedir `pwd`/sources" \
--define "_specdir `pwd`/spec" \
--define "_builddir `pwd`/rpmbuild" \
--define "_srcrpmdir `pwd`/srpms" \
--define "_rpmdir `pwd`/rpms" \
--define "_buildrootdir `pwd`/build" \
spec/osbuild.spec
- name: "Upload artifacts"
uses: actions/upload-artifact@v1
with:
name: rpms
path: rpms/
- name: Test RPM installation
run: |
pushd rpms/noarch
dnf -y install $(ls *.rpm)
popd