From f7cf31486f2f10db7a1b7f39baf078a545cb6375 Mon Sep 17 00:00:00 2001 From: Ondrej Platek Date: Tue, 5 Nov 2024 17:10:29 +0100 Subject: [PATCH 1/5] setup minimal Gitlab CI: unittest, black only for main branch and PRs to main pytest are only demo tests --- .github/workflows/black_check.yml | 26 ++++++++++++++++++++++++++ .github/workflows/py311_tests.yml | 26 ++++++++++++++++++++++++++ setup.py | 5 ++++- tests/test_demo.py | 9 +++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) 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..aabbcc23 --- /dev/null +++ b/.github/workflows/black_check.yml @@ -0,0 +1,26 @@ +name: Black Code Style Check + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +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 diff --git a/.github/workflows/py311_tests.yml b/.github/workflows/py311_tests.yml new file mode 100644 index 00000000..a5e84d57 --- /dev/null +++ b/.github/workflows/py311_tests.yml @@ -0,0 +1,26 @@ +name: Python CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +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/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..39bdff18 --- /dev/null +++ b/tests/test_demo.py @@ -0,0 +1,9 @@ +def test_demo_ok(): + assert 1 + 1 == 2 + + +def test_demo_ko(): + assert 1 + 1 == 3 + +def test_demo_exception(): + return 1 / 0 From 438b118df4abf9925edd47958a93b58ddb129f11 Mon Sep 17 00:00:00 2001 From: Ondrej Platek Date: Tue, 5 Nov 2024 17:12:30 +0100 Subject: [PATCH 2/5] apply the same behaviour for CI for the release-1.0.0 branch as for main --- .github/workflows/black_check.yml | 4 ++-- .github/workflows/py311_tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/black_check.yml b/.github/workflows/black_check.yml index aabbcc23..38bad9f3 100644 --- a/.github/workflows/black_check.yml +++ b/.github/workflows/black_check.yml @@ -2,9 +2,9 @@ name: Black Code Style Check on: push: - branches: [ main ] + branches: [ main, release-1.0.0] pull_request: - branches: [ main ] + branches: [ main, release-1.0.0] jobs: diff --git a/.github/workflows/py311_tests.yml b/.github/workflows/py311_tests.yml index a5e84d57..81e203ce 100644 --- a/.github/workflows/py311_tests.yml +++ b/.github/workflows/py311_tests.yml @@ -2,9 +2,9 @@ name: Python CI on: push: - branches: [ main ] + branches: [ main, release-1.0.0] pull_request: - branches: [ main ] + branches: [ main, release-1.0.0] jobs: From aee4855508b97805f305474f706736e811e6ae8d Mon Sep 17 00:00:00 2001 From: Ondrej Platek Date: Tue, 5 Nov 2024 17:13:59 +0100 Subject: [PATCH 3/5] fix black --- factgenie/bin/run.py | 2 +- tests/test_demo.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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/tests/test_demo.py b/tests/test_demo.py index 39bdff18..867f2fd8 100644 --- a/tests/test_demo.py +++ b/tests/test_demo.py @@ -5,5 +5,6 @@ def test_demo_ok(): def test_demo_ko(): assert 1 + 1 == 3 + def test_demo_exception(): return 1 / 0 From c52e0aa35f17efe6b79bdffc5328928ffe41dae4 Mon Sep 17 00:00:00 2001 From: Ondrej Platek Date: Tue, 5 Nov 2024 17:15:39 +0100 Subject: [PATCH 4/5] simplify names for CI setups --- .github/workflows/black_check.yml | 4 ++-- .github/workflows/py311_tests.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/black_check.yml b/.github/workflows/black_check.yml index 38bad9f3..d7ba4f7b 100644 --- a/.github/workflows/black_check.yml +++ b/.github/workflows/black_check.yml @@ -1,4 +1,4 @@ -name: Black Code Style Check +name: Black Check on: push: @@ -23,4 +23,4 @@ jobs: pip install black==24.10.0 - name: Run Black run: | - black --check . --line-length 120 + 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 index 81e203ce..35871146 100644 --- a/.github/workflows/py311_tests.yml +++ b/.github/workflows/py311_tests.yml @@ -1,4 +1,4 @@ -name: Python CI +name: Pytest on: push: From 1cb649b3049bd688a05abeba77fddfa448eddc67 Mon Sep 17 00:00:00 2001 From: Ondrej Platek Date: Tue, 5 Nov 2024 17:19:26 +0100 Subject: [PATCH 5/5] make test to pass --- tests/test_demo.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/test_demo.py b/tests/test_demo.py index 867f2fd8..e2f42aef 100644 --- a/tests/test_demo.py +++ b/tests/test_demo.py @@ -2,9 +2,10 @@ def test_demo_ok(): assert 1 + 1 == 2 -def test_demo_ko(): - assert 1 + 1 == 3 - - -def test_demo_exception(): - return 1 / 0 +# # Uncomment to fail the tests +# def test_demo_ko(): +# assert 1 + 1 == 3 +# +# +# def test_demo_exception(): +# return 1 / 0