From 607571e44e9430c070afd7dfe77e749c8cbc2288 Mon Sep 17 00:00:00 2001 From: s-martin Date: Sun, 10 Dec 2023 15:35:53 +0100 Subject: [PATCH 1/8] Add running pytest --- .github/workflows/pythonpackage_future3.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pythonpackage_future3.yml b/.github/workflows/pythonpackage_future3.yml index 48e27b15d..7fef16671 100644 --- a/.github/workflows/pythonpackage_future3.yml +++ b/.github/workflows/pythonpackage_future3.yml @@ -41,6 +41,9 @@ jobs: pip3 install -r src/jukebox/components/rfid/hardware/pn532_i2c_py532/requirements.txt pip3 install -r src/jukebox/components/rfid/hardware/rdm6300_serial/requirements.txt pip3 install -r src/jukebox/components/rfid/hardware/rc522_spi/requirements.txt + - name: Run pytest + run: | + ./run_pytest.sh - name: Lint with flake8 run: | pip3 install flake8 From a809c8c05403654cb2bfff95e3075370678982c7 Mon Sep 17 00:00:00 2001 From: s-martin Date: Sun, 10 Dec 2023 15:38:20 +0100 Subject: [PATCH 2/8] Trigger running the action --- src/jukebox/misc/loggingext.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jukebox/misc/loggingext.py b/src/jukebox/misc/loggingext.py index 9328cfea8..771248d8f 100644 --- a/src/jukebox/misc/loggingext.py +++ b/src/jukebox/misc/loggingext.py @@ -1,6 +1,7 @@ """ ############## Logger + ############## We use a hierarchical Logger structure based on pythons logging module. It can be finely configured with a yaml file. From 0ccc269ce22cc50840592a3b9f41f955f81f2961 Mon Sep 17 00:00:00 2001 From: s-martin Date: Sun, 10 Dec 2023 15:41:49 +0100 Subject: [PATCH 3/8] Remove Python 3.7 to check --- .github/workflows/pythonpackage_future3.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage_future3.yml b/.github/workflows/pythonpackage_future3.yml index 7fef16671..db83b523f 100644 --- a/.github/workflows/pythonpackage_future3.yml +++ b/.github/workflows/pythonpackage_future3.yml @@ -21,7 +21,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v3 From b32abd3b3e3603cfafad02c7f9a9a8366ad18800 Mon Sep 17 00:00:00 2001 From: s-martin Date: Sun, 10 Dec 2023 17:49:01 +0100 Subject: [PATCH 4/8] support only bullseye and bookworm python versions --- .github/workflows/pythonpackage_future3.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pythonpackage_future3.yml b/.github/workflows/pythonpackage_future3.yml index db83b523f..d5f5c1bc7 100644 --- a/.github/workflows/pythonpackage_future3.yml +++ b/.github/workflows/pythonpackage_future3.yml @@ -6,13 +6,11 @@ on: - 'future3/**' paths: - '**.py' - - '**.py.*' pull_request: branches: - 'future3/**' paths: - '**.py' - - '**.py.*' jobs: build: @@ -21,7 +19,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v3 From 21966fa2a94293a8bd1a2e69d9555eaab823c5a0 Mon Sep 17 00:00:00 2001 From: s-martin Date: Sun, 10 Dec 2023 18:10:34 +0100 Subject: [PATCH 5/8] Add coverage check with coveralls --- .github/workflows/pythonpackage_future3.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/pythonpackage_future3.yml b/.github/workflows/pythonpackage_future3.yml index d5f5c1bc7..c6a1009af 100644 --- a/.github/workflows/pythonpackage_future3.yml +++ b/.github/workflows/pythonpackage_future3.yml @@ -42,8 +42,24 @@ jobs: - name: Run pytest run: | ./run_pytest.sh + - name: Report to Coveralls (parallel) + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + file: coverage.xml + format: cobertura + parallel: true - name: Lint with flake8 run: | pip3 install flake8 # Stop the build if linting fails ./run_flake8.sh + + finish: + needs: build + runs-on: ubuntu-latest + steps: + - name: Close parallel build + uses: coverallsapp/github-action@v2 + with: + parallel-finished: true From e8ed7aaf2c62cdc0dc0b1d8e3a184013b831cc5d Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 10 Dec 2023 21:22:39 +0100 Subject: [PATCH 6/8] use coverage for ci --- .github/workflows/pythonpackage_future3.yml | 2 +- run_pytest.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonpackage_future3.yml b/.github/workflows/pythonpackage_future3.yml index c6a1009af..3834d83db 100644 --- a/.github/workflows/pythonpackage_future3.yml +++ b/.github/workflows/pythonpackage_future3.yml @@ -41,7 +41,7 @@ jobs: pip3 install -r src/jukebox/components/rfid/hardware/rc522_spi/requirements.txt - name: Run pytest run: | - ./run_pytest.sh + ./run_pytest.sh --cov --cov-report xml - name: Report to Coveralls (parallel) uses: coverallsapp/github-action@v2 with: diff --git a/run_pytest.sh b/run_pytest.sh index a3cbd8df6..57ad4bfab 100755 --- a/run_pytest.sh +++ b/run_pytest.sh @@ -10,4 +10,4 @@ SCRIPT_DIR="$(dirname "$SOURCE")" cd "$SCRIPT_DIR" || (echo "Could not change to top-level project directory" && exit 1) # Run pytest -pytest -c pytest.ini +pytest -c pytest.ini $1 $2 $3 From 9a57a6db1ac238b05f6b5961b0d2a35d5d41387c Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 10 Dec 2023 21:28:48 +0100 Subject: [PATCH 7/8] add coverage package --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 0f8c8c86d..bd2ea6651 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,4 +31,5 @@ gpiozero # Code quality flake8>=4.0.0 pytest +pytest-cov mock From 19e556cff8efda2bbf41c849b7d049249f5db4e2 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 10 Dec 2023 23:30:16 +0100 Subject: [PATCH 8/8] consider review comments --- .flake8 | 2 +- run_pytest.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index d11edbe8a..0c2cd276e 100644 --- a/.flake8 +++ b/.flake8 @@ -15,7 +15,7 @@ per-file-ignores = count = True max-complexity = 12 statistics = True -filename = *.py,*.py.* +filename = *.py extend-exclude = # Ignore all scratch development directories scratch*, diff --git a/run_pytest.sh b/run_pytest.sh index 57ad4bfab..766f05182 100755 --- a/run_pytest.sh +++ b/run_pytest.sh @@ -10,4 +10,4 @@ SCRIPT_DIR="$(dirname "$SOURCE")" cd "$SCRIPT_DIR" || (echo "Could not change to top-level project directory" && exit 1) # Run pytest -pytest -c pytest.ini $1 $2 $3 +pytest -c pytest.ini $@