Skip to content

Commit

Permalink
Add test for scripts/get_version_from_toml.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchariGr committed Jul 20, 2023
1 parent 153df5d commit 35898c2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/nightly_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,6 @@ jobs:
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}

- name: Read Poetry Version 🔢
run: |
echo "POETRY_VERSION=$(scripts/poetry-version.sh)" >> $GITHUB_ENV
shell: bash

- name: Install poetry 🦄
uses: Gr1N/setup-poetry@15821dc8a61bc630db542ae4baf6a7c19a994844 # v8
with:
poetry-version: ${{ env.POETRY_VERSION }}

- name: Install Dependencies 📦
run: |
make install
- name: Compose tag name
id: set_tagname
run: |
Expand Down Expand Up @@ -205,7 +191,7 @@ jobs:
# send notification if 'deploy' or 'docker' is skipped (previous needed job failed) or failed
if: needs.docker.result != 'success' || needs.deploy.result != 'success'
env:
SLACK_WEBHOOK: ${{ secrets.TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASE_ASSISTANT_ATOM_ALERTS_WEBHOOK }}
uses: Ilshidur/action-slack@689ad44a9c9092315abd286d0e3a9a74d31ab78a
with:
args: "⛔️ *Rasa nightly release* failed 😱! Please check out GitHub Actions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
Expand Down
5 changes: 3 additions & 2 deletions scripts/get_version_from_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ def pyproject_file_path() -> Path:
return project_root() / PYPROJECT_FILE_PATH


def get_rasa_version_from_pyproject() -> str:
def get_rasa_version_from_pyproject(pyproject_file=None) -> str:
"""Fetch rasa version from pyproject."""
pyproject_file = pyproject_file_path()
if pyproject_file is None:
pyproject_file = pyproject_file_path()

try:
data = toml.load(pyproject_file)
Expand Down
23 changes: 23 additions & 0 deletions tests/scripts/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[build-system]
requires = [ "poetry-core>=1.0.4",]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 88
target-version = [ "py37", "py38", "py39", "py310",]
exclude = "((.eggs | .git | .pytest_cache | build | dist))"

[tool.poetry]
name = "rasa"
version = "3.7.1rc1"
description = "Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants"
authors = [ "Rasa Technologies GmbH <[email protected]>",]
maintainers = [ "Tom Bocklisch <[email protected]>",]
homepage = "https://rasa.com"
repository = "https://github.com/rasahq/rasa"
documentation = "https://rasa.com/docs"
classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Topic :: Software Development :: Libraries",]
keywords = [ "nlp", "machine-learning", "machine-learning-library", "bot", "bots", "botkit", "rasa conversational-agents", "conversational-ai", "chatbot", "chatbot-framework", "bot-framework",]
include = [ "LICENSE.txt", "README.md", "rasa/shared/core/training_data/visualization.html", "rasa/cli/default_config.yml", "rasa/shared/importers/*", "rasa/utils/schemas/*", "rasa/keys",]
readme = "README.md"
license = "Apache-2.0"
9 changes: 9 additions & 0 deletions tests/scripts/test_get_version_from_toml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from scripts.get_version_from_toml import get_rasa_version_from_pyproject
import os


def test_version_from_toml():
pyproject_file_path = os.path.dirname(__file__) + '/test.toml'
expected = "3.7.1rc1"
version = get_rasa_version_from_pyproject(pyproject_file=pyproject_file_path)
assert version == expected

0 comments on commit 35898c2

Please sign in to comment.