Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .github/workflows/CI_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
push:
pull_request:
types: [opened, reopened]
workflow_dispatch:
inputs:
tag:
description: Tag for manually running CI Build workflow
required: False
default: ''

jobs:

Expand Down Expand Up @@ -38,12 +44,12 @@ jobs:
- name: Check whether import statements are used consistently
shell: bash -l {0}
run: poetry run isort --check-only --diff --conda-env spec2vec-dev .
- name: SonarQube Scan
if: github.repository == 'iomega/spec2vec'
uses: SonarSource/sonarqube-scan-action@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# - name: SonarQube Scan
# if: github.repository == 'iomega/spec2vec'
# uses: SonarSource/sonarqube-scan-action@v6
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build_pypi:
name: Pypi and documentation build / python-${{ matrix.python-version }} / ${{ matrix.os }}
Expand Down
4 changes: 3 additions & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% set name = "spec2vec" %}
{% set version = "0.9.1" %}

{% set pyproject = load_file_data('../pyproject.toml', from_recipe_dir=True) %}
{% set version = pyproject.get('tool', {}).get('poetry', {}).get('version', '0+unknown') %}

package:
name: {{ name|lower }}
Expand Down
8 changes: 7 additions & 1 deletion spec2vec/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
__version__ = '0.9.1'
from importlib.metadata import PackageNotFoundError, version


try:
__version__ = version("spec2vec")
except PackageNotFoundError:
__version__ = "0+unknown"
21 changes: 12 additions & 9 deletions tests/test_version_string_consistency.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import importlib
import os
import re
from spec2vec import __version__ as expected_version
import pytest
import tomli


@pytest.mark.skipif(not os.getenv("CI"),reason="Skipping version consistency test outside CI environment")
def test_version_string_consistency():
"""Check whether version in conda/meta.yaml is consistent with that in spec2vec.__version__"""

repository_root = os.path.join(os.path.dirname(__file__), "..")
fixture = os.path.join(repository_root, "conda", "meta.yaml")
pyproject_file = os.path.join(repository_root, "pyproject.toml")

with open(fixture, "r", encoding="utf-8") as f:
metayaml_contents = f.read()
with open(pyproject_file, "rb") as f:
pyproject = tomli.load(f)
expected_version = pyproject["tool"]["poetry"]["version"]

match = re.search(r"^{% set version = \"(?P<semver>.*)\" %}$", metayaml_contents, re.MULTILINE)
actual_version = match["semver"]
spec2vec = importlib.import_module("spec2vec")
actual_version = spec2vec.__version__

assert expected_version == actual_version, "Expected version string used in conda/meta.yaml to be consistent with" \
" that in spec2vec.__version__"
assert expected_version == actual_version, f"Expected version {expected_version!r} in pyproject.toml to match" \
f" spec2vec.__version__ ({actual_version!r})"
Loading