Skip to content

Commit

Permalink
Merge pull request #379 from k4cg/tox_version
Browse files Browse the repository at this point in the history
tox test - version
  • Loading branch information
jkowalleck committed Sep 5, 2020
2 parents 2230eea + a7ea435 commit 619529e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .github/codeql/python-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ queries:
- uses: security-and-quality

paths:
- python-package/bin
- python-package/src
paths-ignore:
# web-ui is generated
- python-package/src/nichtparasoup/_web-ui
46 changes: 2 additions & 44 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,6 @@ env:
latest-python-version: '3.8'

jobs:
test-version:
name: Assert version
# assure that the correct version is marked where needed
runs-on: ubuntu-latest
steps:
- name: Fetch Code
# see https://github.com/actions/checkout
uses: actions/checkout@v2
- name: Setup Python
# see https://github.com/actions/setup-python
uses: actions/setup-python@v2
with:
python-version: ${{ env.latest-python-version }}
- name: get package version
id: package
run: echo "::set-output name=version::$(python setup.py --version)"
- name: get nichtparasoup version
id: nichtparasoup
run: |
from nichtparasoup import __version__
print(f'::set-output name=version::{__version__}', sep='', flush=True)
shell: python
env:
PYTHONPATH: src
- name: Assert package_version
if: ${{ steps.package.outputs.version != github.event.release.tag_name }}
run: |
echo ERROR: assertion mismatch
echo package.version : ${{ steps.package.outputs.version }}
echo release.tag_name: ${{ github.event.release.tag_name }}
exit 1
- name: Assert nichtparasoup_version
if: ${{ steps.nichtparasoup.outputs.version != github.event.release.tag_name }}
run: |
echo ERROR: assertion mismatch
echo nichtparasoup.version: ${{ steps.nichtparasoup.outputs.version }}
echo release.tag_name : ${{ github.event.release.tag_name }}
exit 2
test:
name: Tests
# these tests are just to ensure that a minimal quality is given. full tests are done in `tests` action
Expand All @@ -77,12 +38,11 @@ jobs:
- name: Test nichtparasoup
run: python -m tox -r -s false
env:
TOXENV: style, tests_start, py38
NP_VERSION_EXPECTED: ${{ github.event.release.tag_name }}
TOXENV: version, style, tests_start, py38
TOX_PARALLEL_NO_SPINNER: 1

build:
name: Build
needs: ['test-version']
# build in an isolated env
runs-on: ubuntu-latest
steps:
Expand All @@ -109,7 +69,6 @@ jobs:
name: build-results
path: ${{ env.project-directory }}/${{ env.dist-dir }}/
if-no-files-found: error

publish-asset-wheel:
name: Publish to assets
needs: ['test', 'build']
Expand Down Expand Up @@ -147,7 +106,6 @@ jobs:
asset_path: ${{ env.dist-dir }}/${{ steps.files.outputs.source }}
asset_name: ${{ steps.files.outputs.source }}
asset_content_type: application/tar+gzip

publish-pypi:
name: Publish to PyPI
needs: ['test', 'build']
Expand Down
40 changes: 40 additions & 0 deletions python-package/bin/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
import os
import sys
from subprocess import check_output

# region config

PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
SOURCES_DIR = os.path.join(PROJECT_ROOT, 'src')
SETUP_FILE = os.path.join(PROJECT_ROOT, 'setup.py')

# region config

VERSION_EXPECTED = sys.argv[1] if len(sys.argv) > 1 else os.getenv('NP_VERSION_EXPECTED')
if not VERSION_EXPECTED:
print(f'VERSION_EXPECTED empty: {VERSION_EXPECTED!r}')
sys.exit(1)
print(f'expected version {VERSION_EXPECTED!r}')

# region version_src

sys.path.insert(0, SOURCES_DIR)
from nichtparasoup import __version__ as version_src # noqa isort:skip

if version_src != VERSION_EXPECTED:
print(f'ERROR version_src: expected {VERSION_EXPECTED!r}, got {version_src!r}', file=sys.stderr)
sys.exit(2)

# endregion version_src

# region version_setup

version_setup = check_output([sys.executable, SETUP_FILE, '--version'], shell=False, universal_newlines=True).strip()
if version_setup != VERSION_EXPECTED:
print(f'ERROR version_setup: expected {VERSION_EXPECTED!r}, got {version_setup!r}', file=sys.stderr)
sys.exit(3)

# endregion version_setup

sys.exit(0)
7 changes: 7 additions & 0 deletions python-package/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,10 @@ deps = -r requirements/style.txt
commands =
{envpython} -m flake8
{envpython} -m mypy

[testenv:version]
depends =
skip_install = True
deps =
commands =
{envpython} bin/test_version.py {env:NP_VERSION_EXPECTED}

0 comments on commit 619529e

Please sign in to comment.