From 9617cb88dfe1f609a2bf1e7950d7c73a1ffe6aee Mon Sep 17 00:00:00 2001 From: MattHag <16444067+MattHag@users.noreply.github.com> Date: Sun, 18 Feb 2024 14:29:29 +0100 Subject: [PATCH] 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 --- .github/workflows/tests.yml | 19 ++++++++----------- Makefile | 38 ++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8967a3dde6..de4afb730b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/Makefile b/Makefile index a255b53b71..6688877ebf 100644 --- a/Makefile +++ b/Makefile @@ -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/