From bed45992b54c38d9e5e6978d28d682cb46d0c445 Mon Sep 17 00:00:00 2001 From: Omar Jarjur Date: Tue, 9 Jul 2024 18:23:50 -0700 Subject: [PATCH 1/4] Add a GitHub action to test the python package --- .github/workflows/python-package.yml | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/python-package.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 00000000..e56abb63 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.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 efba371c88f89398a94ca72a0d5fe4635be06710 Mon Sep 17 00:00:00 2001 From: Omar Jarjur Date: Wed, 10 Jul 2024 01:26:24 +0000 Subject: [PATCH 2/4] Remove the flake8 check since it has unresolvable false alerts --- .github/workflows/python-package.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index e56abb63..065e5ea1 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -27,14 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest if [ -f requirements.txt ]; then pip install -r requirements.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 4b6cf63be75b696c7f49228f921ab1426914f040 Mon Sep 17 00:00:00 2001 From: Omar Jarjur Date: Wed, 10 Jul 2024 01:30:33 +0000 Subject: [PATCH 3/4] Fix bug in previous commit where the `pytest` install was accidentally removed. --- .github/workflows/python-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 065e5ea1..524b4078 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -27,6 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + python -m pip install pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Test with pytest run: | From c39fea3e9a94c7580292c6d21fafef9c0587d4a3 Mon Sep 17 00:00:00 2001 From: Omar Jarjur Date: Wed, 10 Jul 2024 01:33:08 +0000 Subject: [PATCH 4/4] Install the local package before trying to test it. --- .github/workflows/python-package.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 524b4078..98300a62 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -29,6 +29,9 @@ jobs: python -m pip install --upgrade pip python -m pip install pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Install package + run: | + python -m pip install -e ".[test]" - name: Test with pytest run: | pytest