Skip to content

Commit b9605eb

Browse files
authored
Merge pull request #55 from ssalonen/ci-fix
CI fixes
2 parents 5318d5e + 0ce017c commit b9605eb

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

.github/workflows/pythonpackage.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Python package
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:
@@ -9,14 +9,15 @@ jobs:
99
strategy:
1010
max-parallel: 4
1111
matrix:
12-
python-version: [3.5, 3.6, 3.7]
12+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
1313

1414
steps:
1515
- uses: actions/checkout@v1
1616
- name: Set up Python ${{ matrix.python-version }}
1717
uses: actions/setup-python@v1
1818
with:
1919
python-version: ${{ matrix.python-version }}
20+
cache: 'pip' # caching pip dependencies
2021
- name: Install dependencies
2122
run: |
2223
sudo apt install gcc libasound-dev
@@ -29,7 +30,7 @@ jobs:
2930
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3031
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3132
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
32-
# - name: Test with pytest
33-
# run: |
34-
# pip install pytest
35-
# pytest
33+
- name: Test with pytest
34+
run: |
35+
pip install pytest
36+
pytest

hifiberrydsp/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
__version__ = "0.20"
2+
_called_from_test = False

hifiberrydsp/conftest.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
def pytest_configure(config):
3+
import hifiberrydsp
4+
hifiberrydsp._called_from_test = True

hifiberrydsp/hardware/spi.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,21 @@
2020
SOFTWARE.
2121
'''
2222
import logging
23-
24-
25-
def init_spi():
26-
import spidev
27-
spi = spidev.SpiDev()
28-
spi.open(0, 0)
29-
spi.bits_per_word = 8
30-
spi.max_speed_hz = 1000000
31-
spi.mode = 0
32-
logging.debug("spi initialized %s", spi)
23+
import hifiberrydsp
24+
25+
def init_spi():
26+
if not hifiberrydsp._called_from_test:
27+
# only open the device when not running tests
28+
import spidev
29+
spi = spidev.SpiDev()
30+
spi.open(0, 0)
31+
spi.bits_per_word = 8
32+
spi.max_speed_hz = 1000000
33+
spi.mode = 0
34+
logging.debug("spi initialized %s", spi)
35+
else:
36+
spi = None
37+
logging.debug("spi not initialized since running tests")
3338
return spi
3439

3540

0 commit comments

Comments
 (0)