Skip to content

Commit

Permalink
dist: extend makefile and tests
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MattHag authored Feb 18, 2024
1 parent 20a76fb commit 9617cb8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: tests
on: [push, pull_request]

jobs:
build:
ubuntu-tests:
runs-on: ubuntu-latest

strategy:
Expand All @@ -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:
Expand All @@ -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
38 changes: 35 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/

0 comments on commit 9617cb8

Please sign in to comment.