From f03b2d14a301f527f419ea726cc20b11da65caac Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Fri, 7 Jun 2024 13:50:44 +0200 Subject: [PATCH 1/3] Add python validation action Check tests and linting on pull requests and pushes --- .github/workflows/validate.yml | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/validate.yml diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..d473d7a --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python application validation + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v3 + with: + python-version: "3.12" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest From 65cb8debcc83dabb8d3f083e625b8e2f94956cc6 Mon Sep 17 00:00:00 2001 From: jbouwh Date: Fri, 7 Jun 2024 11:56:01 +0000 Subject: [PATCH 2/3] Add isort and black --- .github/workflows/validate.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index d473d7a..32320b6 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -35,6 +35,14 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: "Check formatting 1: black" + run: | + black --diff --check *client.py + black --diff --check incomfort* + - name: "Check formatting 2: isort" + run: | + isort --check --diff *client.py + isort --check --diff incomfort* - name: Test with pytest run: | pytest From 50238a4656bfefc81236afbc82051b8c80a91b5e Mon Sep 17 00:00:00 2001 From: jbouwh Date: Fri, 7 Jun 2024 12:00:51 +0000 Subject: [PATCH 3/3] Update flake to be in sync with pre commit --- .flake8 | 2 +- .github/workflows/validate.yml | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.flake8 b/.flake8 index e68c9db..c56ef71 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ -# .flake8 file for https://github.com/zxdavb +# .flake8 file for https://github.com/jbouwh/incomfort-client [flake8] # max-line-length as used by black diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 32320b6..5593cfa 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -32,9 +32,8 @@ jobs: - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --count --select=C,E,F,W,B,B950 --ignore=E203,E501,W503 --show-source --statistics + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics - name: "Check formatting 1: black" run: | black --diff --check *client.py