name: 'unit tests' on: push: branches: ['master'] paths: - '.github/**' - '**.py' - 'tests/**' pull_request: branches: ['master'] paths: - '.github/**' - '**.py' - 'tests/**' jobs: test: name: 'unit tests' runs-on: 'ubuntu-latest' strategy: fail-fast: false matrix: # Testing per python-version using actions/setup-python is not possible, # because rpm doesn't exist on pypi and cannot be installed via pip on ubuntu. # That's why we're going to test on the target distros directly. container: # Fedora - 'fedora:36' - 'fedora:rawhide' # openSUSE # leap < 15.2 doesn't contain git-lfs which causes actions/checkout to fail - 'opensuse/leap:15.3' - 'opensuse/leap:15.4' - 'opensuse/tumbleweed' # CentOS Stream - 'quay.io/centos/centos:stream9' # Debian - 'debian:stable' - 'debian:unstable' # Ubuntu - 'ubuntu:latest' container: image: ${{ matrix.container }} steps: - name: 'Install packages (openSUSE)' if: ${{ startsWith(matrix.container, 'opensuse/') }} run: | zypper -n --gpg-auto-import-keys refresh zypper -n lr --details grep -qi tumbleweed /etc/os-release && zypper -n dist-upgrade || zypper -n patch || zypper -n patch zypper -n install git-lfs zypper -n install diffstat diffutils python3 python3-cryptography python3-pip python3-rpm python3-setuptools python3-urllib3 - name: 'Install packages (Fedora/CentOS)' if: ${{ startsWith(matrix.container, 'fedora:') || contains(matrix.container, 'centos:') }} run: | dnf -y makecache dnf -y distro-sync dnf -y install git-lfs dnf -y install diffstat diffutils python3 python3-cryptography python3-pip python3-rpm python3-setuptools python3-urllib3 - name: 'Install packages (Debian/Ubuntu)' if: ${{ startsWith(matrix.container, 'debian:') || startsWith(matrix.container, 'ubuntu:') }} run: | apt-get -y update apt-get -y upgrade apt-get -y --no-install-recommends install git-lfs apt-get -y --no-install-recommends install diffstat diffutils python3 python3-cryptography python3-pip python3-rpm python3-setuptools python3-urllib3 - uses: actions/checkout@v3 - name: 'Run unit tests' run: | pip3 install -e . python3 setup.py test - name: 'Generate coverage reports (openSUSE Tumbleweed)' if: ${{ matrix.container == 'opensuse/tumbleweed' }} run: | zypper -n install python3-pytest python3-pytest-cov pytest --cov=osc - name: 'Upload coverage reports to Codecov (openSUSE Tumbleweed)' if: ${{ matrix.container == 'opensuse/tumbleweed' }} uses: codecov/codecov-action@v3