From 9ae7b78ee2c779750b6b4b2b82598a8c6a2b2685 Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Sun, 12 Feb 2023 16:47:15 +0200 Subject: [PATCH 1/6] add test verifying output of example --- tests/test_examples.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/test_examples.py diff --git a/tests/test_examples.py b/tests/test_examples.py new file mode 100644 index 0000000..1b07b4c --- /dev/null +++ b/tests/test_examples.py @@ -0,0 +1,18 @@ +import subprocess +import os + +def capture(command): + proc = subprocess.Popen(command, + stdout = subprocess.PIPE, + stderr = subprocess.PIPE, + ) + out, err = proc.communicate() + exit_code = proc.returncode + return exit_code, out.decode('utf-8'), err.decode('utf-8') + +def test_test(): + os.environ["PYTHONPATH"] = "." + exit_code, out, err = capture(["python", "examples/test.py"]) + assert exit_code == 0 + assert out == "test1\ntest2\n" + assert err == "" From 0fedff39dd368a17bc6551350100367ff9be38e7 Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Sun, 12 Feb 2023 16:56:34 +0200 Subject: [PATCH 2/6] add github action --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b959dce --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI + +on: + push: + pull_request: + workflow_dispatch: +# schedule: +# - cron: '42 5 * * *' + +jobs: + test: + strategy: + fail-fast: false + matrix: + runner: [ubuntu-latest] #, macos-latest, windows-latest] + python-version: ["3.9"] #, "3.10", "3.11"] + + runs-on: ${{matrix.runner}} + name: OS ${{matrix.runner}} Python ${{matrix.python-version}} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python setup.py + + - name: Check Python version + run: python -V + + - name: Test with pytest + run: pytest -vvs tests/ + From 6c87dfb7dfc96b47098a5c26d1af527b6d8296b5 Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Sun, 12 Feb 2023 17:03:34 +0200 Subject: [PATCH 3/6] always run the example with the current python --- tests/test_examples.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index 1b07b4c..1a63d40 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -1,5 +1,6 @@ import subprocess import os +import sys def capture(command): proc = subprocess.Popen(command, @@ -12,7 +13,7 @@ def capture(command): def test_test(): os.environ["PYTHONPATH"] = "." - exit_code, out, err = capture(["python", "examples/test.py"]) + exit_code, out, err = capture([sys.executable, "examples/test.py"]) assert exit_code == 0 assert out == "test1\ntest2\n" assert err == "" From 9a59853772c25e077d08baf3edc5cee89f42707a Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Sun, 12 Feb 2023 17:04:39 +0200 Subject: [PATCH 4/6] install dependencies --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b959dce..9b3052c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,8 @@ jobs: - name: Install dependencies run: | - python setup.py + python setup.py build + pip install pytest - name: Check Python version run: python -V From 77744183e33c0e46b06d5c7cf181066e100356a8 Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Sun, 12 Feb 2023 17:10:33 +0200 Subject: [PATCH 5/6] run ci on 9 variations --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b3052c..023f453 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,8 @@ jobs: strategy: fail-fast: false matrix: - runner: [ubuntu-latest] #, macos-latest, windows-latest] - python-version: ["3.9"] #, "3.10", "3.11"] + runner: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.9", "3.10", "3.11"] runs-on: ${{matrix.runner}} name: OS ${{matrix.runner}} Python ${{matrix.python-version}} From 175f7679181e735d476d054d403099ef0cfcc5fa Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Sun, 12 Feb 2023 17:13:26 +0200 Subject: [PATCH 6/6] disable windows testing as it fails due to the newlines --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 023f453..bc94580 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - runner: [ubuntu-latest, macos-latest, windows-latest] + runner: [ubuntu-latest, macos-latest] #, windows-latest] python-version: ["3.9", "3.10", "3.11"] runs-on: ${{matrix.runner}}