From d12de7cab55b9ddaedd4186bacbf87f46be768a7 Mon Sep 17 00:00:00 2001 From: Raffi Enficiaud Date: Fri, 3 May 2024 10:00:18 +0200 Subject: [PATCH] Adding CI and tox target --- .github/ci.yml | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 4 +++ pyproject.toml | 7 ++++- tox.ini | 17 +++++++++++ 4 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 .github/ci.yml create mode 100644 .gitignore create mode 100644 tox.ini diff --git a/.github/ci.yml b/.github/ci.yml new file mode 100644 index 0000000..7579b1f --- /dev/null +++ b/.github/ci.yml @@ -0,0 +1,79 @@ +name: Run tests + +on: [pull_request] + +jobs: + python-tox-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python_version: + - 3.8 + - 3.9 + - 3.10 + - 3.11 + - 3.12 + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Setup Python {{ matrix.python_version }} + uses: actions/setup-python@v2 + with: + python-version: "{{ matrix.python_version }}" + + - name: Install dependencies + run: | + sudo apt-get update && sudo apt-get install -y libarchive-dev + + - name: Install tox/wheel/setuptools + run: | + python -m pip install --upgrade pip + pip install wheel setuptools + pip install tox + + - name: List tox environments + run: | + # runs tox + tox -l + + - name: Install dependencies from tox + timeout-minutes: 15 + run: | + # runs tox with exhaustive package installation + tox -e ${{ matrix.python_version }} --notest -vv + + - name: Run tests from tox + timeout-minutes: 30 + run: | + # disables the GDrive tests + # runs tox + tox -l + tox -e ${{ matrix.python_version }} + + - name: Upload unit test results + if: always() + uses: actions/upload-artifact@v2 + with: + name: Tox test results (${{ matrix.python_version }}) + path: ${{ github.workspace }}/.tox/**/tmp/*.xml + + publish-test-results: + name: 'publish unit tests results' + needs: [python-tox-tests] + runs-on: ubuntu-latest + # previous jobs might be skipped, we don't need to run this job then + if: success() || failure() + + steps: + - name: Download Artifacts + uses: actions/download-artifact@v2 + with: + path: artifacts + + - name: Publish test results + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + files: artifacts/**/*.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea4bc22 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.tox +build +_version.py +pygsl_lite.egg-info diff --git a/pyproject.toml b/pyproject.toml index eedec2b..c08a012 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,11 @@ [project.urls] homepage = "https://github.com/AEI-ACR/pygsl_lite" - [tool.setuptools_scm] write_to = "pygsl_lite/_version.py" + +[tool.pytest.ini_options] + minversion = "6.0" + testpaths = [ + "test", + ] diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..fddfccd --- /dev/null +++ b/tox.ini @@ -0,0 +1,17 @@ +[tox] +requires = + tox>=4 +env_list = + py{39,310,311,312} +skip_missing_interpreters = true + +[default] + +[testenv] +description = run unit tests +package = wheel +deps = + pytest + +commands = + pytest --junitxml={env_tmp_dir}/junit-{env_name}.xml {posargs:test}