From 1fff76f2f4c100d30d7b637f83663043f3aa5e91 Mon Sep 17 00:00:00 2001 From: Patrick Baus Date: Wed, 31 Jan 2024 03:42:56 +0100 Subject: [PATCH] Test git release version --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++++++ tests/__init__.py | 0 tests/test_version.py | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_version.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53ff693..132733f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,32 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: + tests: + name: Run Python tests + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [ "3.12", ] + + steps: + - name: Checkout source repository + uses: actions/checkout@v4 + - name: Set up python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + cache: 'pip' # caching pip dependencies + python-version: ${{ matrix.python-version }} + - name: Install dependencies for testing + run: | + python3 -m pip install --upgrade pip + python3 -m pip install .[test] + - name: Test with pytest + env: + GIT_TAG: ${{ github.ref_type == 'tag' && github.ref_name || '' }} + run: | + pytest --exitfirst --verbose --failed-first + prepare: runs-on: ubuntu-latest steps: @@ -45,6 +71,7 @@ jobs: build: needs: + - tests - prepare runs-on: ubuntu-latest permissions: diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..05ec720 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,14 @@ +"""Test to catch invalid versions when releasing a new git tag""" +import os + +from _version import __version__ + + +def test_version(): + """ + Test the Git tag when using CI against the package version + """ + if os.getenv("GIT_TAG"): + assert os.getenv("GIT_TAG") == __version__ + else: + assert True