From 5c2371c8da2d15aa46c7600e14918935e4efa51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Pl=C3=A1tek?= Date: Tue, 5 Nov 2024 17:21:25 +0100 Subject: [PATCH] Minimal GitHub CI: demo unittest and black check (#142) * setup minimal Gitlab CI: unittest, black only for the main branch and PRs to the main pytest are only demo tests * apply the same behavior for CI for the release-1.0.0 branch as for the main --- .github/workflows/black_check.yml | 26 ++++++++++++++++++++++++++ .github/workflows/py311_tests.yml | 26 ++++++++++++++++++++++++++ factgenie/bin/run.py | 2 +- setup.py | 5 ++++- tests/test_demo.py | 11 +++++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/black_check.yml create mode 100644 .github/workflows/py311_tests.yml create mode 100644 tests/test_demo.py diff --git a/.github/workflows/black_check.yml b/.github/workflows/black_check.yml new file mode 100644 index 00000000..d7ba4f7b --- /dev/null +++ b/.github/workflows/black_check.yml @@ -0,0 +1,26 @@ +name: Black Check + +on: + push: + branches: [ main, release-1.0.0] + pull_request: + branches: [ main, release-1.0.0] + +jobs: + + check-black: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.11 + - name: Install Black 24.10.0 - check setup.py if version matches + run: | + python -m pip install --upgrade pip + pip install black==24.10.0 + - name: Run Black + run: | + black --check . --line-length 120 \ No newline at end of file diff --git a/.github/workflows/py311_tests.yml b/.github/workflows/py311_tests.yml new file mode 100644 index 00000000..35871146 --- /dev/null +++ b/.github/workflows/py311_tests.yml @@ -0,0 +1,26 @@ +name: Pytest + +on: + push: + branches: [ main, release-1.0.0] + pull_request: + branches: [ main, release-1.0.0] + +jobs: + + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.11 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install .[test] + - name: Run tests + run: | + pytest diff --git a/factgenie/bin/run.py b/factgenie/bin/run.py index cea928e3..edd9c010 100644 --- a/factgenie/bin/run.py +++ b/factgenie/bin/run.py @@ -314,4 +314,4 @@ def run(): if __name__ == "__main__": app = create_app() - app.run(debug=False) \ No newline at end of file + app.run(debug=False) diff --git a/setup.py b/setup.py index 6d3d3979..58e8220b 100644 --- a/setup.py +++ b/setup.py @@ -77,8 +77,11 @@ def run(self): "wheel>=0.44.0", # Set exact version of black formatter to avoid merge conflicts due to different setup. # See also pyproject.toml and setup of line length (to 120 characters) - "black==24.10.0", "ipdb", + "black==24.10.0", + ], + "test": [ + "pytest>=8.3.3", ], "deploy": [ "gunicorn>=23.0.0", diff --git a/tests/test_demo.py b/tests/test_demo.py new file mode 100644 index 00000000..e2f42aef --- /dev/null +++ b/tests/test_demo.py @@ -0,0 +1,11 @@ +def test_demo_ok(): + assert 1 + 1 == 2 + + +# # Uncomment to fail the tests +# def test_demo_ko(): +# assert 1 + 1 == 3 +# +# +# def test_demo_exception(): +# return 1 / 0