Skip to content

Merge pull request #738 from projecthamster/improved-versioning #223

Merge pull request #738 from projecthamster/improved-versioning

Merge pull request #738 from projecthamster/improved-versioning #223

Workflow file for this run

name: Testing
on: [push, pull_request]
jobs:
test:
# This runs the test suite. Since we need some system dependencies
# (e.g. pygobject) that cannot easily be installed inside a
# virtualenv using pip (that requires installing a dozen -dev
# packages and building parts of pygobject from source, which makes
# things way too complicated), this just runs with the Ubuntu system
# python (e.g. not using the standard setup-python action, which
# sets up a virtualenv).
name: Run test suite
strategy:
# Complete all combinations, even if one fails
fail-fast: false
matrix:
include:
# This tests uses the oldest Ubuntu and its oldest Python
# version, to get as close to our minimum required version as
# possible. This does mean that we will not catch changes to
# the code that unintentionally reaise the required python
# version, but there's no easy way to run an older python
# version (without having to install all or dependencies from
# source) it seems.
- os: ubuntu-20.04
python-version: 3.8
# On the latest ubuntu, just test the default 3.x version.
- os: ubuntu-latest
python-version: 3
runs-on: ${{matrix.os}}
steps:
- name: Prepare repo
uses: actions/checkout@v2
- name: Install system packages
run: |
PACKAGES=""
# Install a specific python version as configured
PACKAGES="$PACKAGES python${{matrix.python-version}}"
# Normal dependencies
PACKAGES="$PACKAGES gettext intltool python3-gi python3-cairo python3-gi-cairo python3-distutils python3-dbus python3-xdg libglib2.0-dev libglib2.0-bin gir1.2-gtk-3.0 gtk-update-icon-cache"
# For dbus-launch
PACKAGES="$PACKAGES dbus-x11"
sudo apt-get update
sudo apt-get install ${PACKAGES}
- name: Install hamster
# This serves two purposes:
# 1) Verify build and install still works and
# 2) install the needed stuff (e.g. gsettings schemas) to allow
# running the tests
run: |
./waf configure build
sudo ./waf install
- name: Run tests
run: |
dbus-launch python${{ matrix.python-version }} -m unittest
flake8:
name: Run code linting and checks
runs-on: ubuntu-20.04
steps:
- name: Prepare repo
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.7'
- name: Install flake8
run: |
pip install flake8
- name: Run flake8
run: |
flake8 --count --show-source --statistics
flatpak:
# This job builds Hamster for flatpak, and runs its tests
# inside the sandbox.
name: Test the flatpak build
runs-on: ubuntu-20.04
steps:
- name: Prepare repo
uses: actions/checkout@v2
# Fetch history, so we also fetch the previous tag for deriving
# the version number
with:
fetch-depth: 0
- name: Install system packages
# It would be good to cache the GNOME Sdk, as it
# is rather big to download each time.
env:
DEBIAN_FRONTEND: noninteractive
run: |
PACKAGES="flatpak flatpak-builder dbus-x11"
sudo apt-get update
sudo apt-get install -yq ${PACKAGES}
- name: Install GNOME SDK for flatpak
run: |
flatpak remote-add --user --if-not-exists --from flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install --user -y flathub org.gnome.Platform//45 org.gnome.Sdk//45
- name: Build application
run: |
flatpak-builder --repo=build/flatpak/repo build/flatpak/tmp org.gnome.Hamster.yml
- name: Run tests inside sandbox
run: |
dbus-launch flatpak-builder --run build/flatpak/tmp org.gnome.Hamster.yml python3 -m unittest
- name: Export bundle and try to install it
run: |
mkdir -p dist
# Note: For pull requests, this version includes the git hash
# of the autogenerated *merge* commit, not the original
# to-be-merged commit (because that's also what is tested).
VERSION=$(python src/hamster/version.py)
flatpak build-bundle --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo build/flatpak/repo "dist/Hamster-$VERSION.flatpak" org.gnome.Hamster
flatpak --user -y install "dist/Hamster-$VERSION.flatpak"
- name: Upload built artifact
uses: actions/upload-artifact@v2
with:
name: Flatpak application
path: dist/*.flatpak