dist: extend makefile and tests

* Show pytest coverage in GitHub CI tests

Related #1097

* Extend Makefile with installation and test targets

Refactor setup steps to unify commands between Linux and macOS.
Move bash commands into Makefile for consistency and enable local
execution of GitHub CI commands corresponding Makefile targets.

Install on Ubuntu:
make install_ubuntu

Install on Ubuntu for development:
make install_ubuntu PIP_ARGS=."[test]"

Fixes #2303

* Improve name of GitHub test actions

Related #2303
This commit is contained in:
MattHag 2024-02-18 14:29:29 +01:00 committed by GitHub
parent 20a76fb4d3
commit 9617cb88df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 14 deletions

View File

@ -3,7 +3,7 @@ name: tests
on: [push, pull_request]
jobs:
build:
ubuntu-tests:
runs-on: ubuntu-latest
strategy:
@ -20,19 +20,17 @@ jobs:
- name: Install Ubuntu dependencies
run: |
sudo apt update
sudo apt install libdbus-1-dev libglib2.0-dev
make install_apt
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e ."[test]"
make install_pip PIP_ARGS='.["test"]'
- name: Run tests on Ubuntu
run: |
pytest --cov=lib/ tests/
make test
macos-build:
macos-tests:
runs-on: macos-latest
strategy:
@ -50,13 +48,12 @@ jobs:
- name: Set up macOS dependencies
run: |
brew install hidapi gtk+3 pygobject3
make install_brew
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install ."[test]"
make install_pip PIP_ARGS='.["test"]'
- name: Run tests on macOS
run: |
pytest --cov=lib/ tests/
make test

View File

@ -3,19 +3,51 @@ UDEV_RULES_SOURCE := rules.d/$(UDEV_RULE_FILE)
UDEV_RULES_SOURCE_UINPUT := rules.d-uinput/$(UDEV_RULE_FILE)
UDEV_RULES_DEST := /etc/udev/rules.d/
.PHONY: install_udev install_udev_uinput uninstall_udev
PIP_ARGS ?= .
.PHONY: install_ubuntu install_macos
.PHONY: install_apt install_brew install_pip
.PHONY: install_udev install_udev_uinput reload_udev uninstall_udev
.PHONY: test
install_ubuntu: install_apt install_udev_uinput install_pip
install_macos: install_brew install_pip
install_apt:
@echo "Installing Solaar dependencies via apt"
sudo apt update
sudo apt install libdbus-1-dev libglib2.0-dev
install_brew:
@echo "Installing Solaar dependencies via brew"
brew update
brew install hidapi gtk+3 pygobject3
install_pip:
@echo "Installing Solaar dependencies via pip"
python -m pip install --upgrade pip
pip install $(PIP_ARGS)
install_udev:
@echo "Copying Solaar udev rule to $(UDEV_RULES_DEST)"
sudo cp $(UDEV_RULES_SOURCE) $(UDEV_RULES_DEST)
sudo udevadm control --reload-rules
make reload_udev
install_udev_uinput:
@echo "Copying Solaar udev rule (uinput) to $(UDEV_RULES_DEST)"
sudo cp $(UDEV_RULES_SOURCE_UINPUT) $(UDEV_RULES_DEST)
make reload_udev
reload_udev:
@echo "Reloading udev rules"
sudo udevadm control --reload-rules
uninstall_udev:
@echo "Removing Solaar udev rules from $(UDEV_RULES_DEST)"
sudo rm -f $(UDEV_RULES_DEST)/$(UDEV_RULE_FILE)
sudo udevadm control --reload-rules
make reload_udev
test:
@echo "Running Solaar tests"
pytest --cov=lib/ tests/