Skip to content

Commit

Permalink
Test for the correct version before pushing to PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickBaus committed Jun 22, 2024
1 parent ffa8f74 commit 9881111
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,38 @@ on:
workflow_dispatch:

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
upload:
needs:
- tests
runs-on: ubuntu-latest

strategy:
Expand Down
Empty file added tests/__init__.py
Empty file.
File renamed without changes.
15 changes: 15 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Test to catch invalid versions when releasing a new git tag"""

import os

from hp3478a_async._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

0 comments on commit 9881111

Please sign in to comment.