From 35898c22629b79dcd6edc40fc1afe63a2096a817 Mon Sep 17 00:00:00 2001 From: Sanchari Date: Thu, 20 Jul 2023 16:31:25 +0200 Subject: [PATCH] Add test for scripts/get_version_from_toml.py --- .github/workflows/nightly_release.yml | 16 +------------- scripts/get_version_from_toml.py | 5 +++-- tests/scripts/test.toml | 23 +++++++++++++++++++++ tests/scripts/test_get_version_from_toml.py | 9 ++++++++ 4 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 tests/scripts/test.toml create mode 100644 tests/scripts/test_get_version_from_toml.py diff --git a/.github/workflows/nightly_release.yml b/.github/workflows/nightly_release.yml index bd935fab5aa6..93c1008da5f3 100644 --- a/.github/workflows/nightly_release.yml +++ b/.github/workflows/nightly_release.yml @@ -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: | @@ -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 }}" diff --git a/scripts/get_version_from_toml.py b/scripts/get_version_from_toml.py index f19f15c2d608..500440d2fc4e 100644 --- a/scripts/get_version_from_toml.py +++ b/scripts/get_version_from_toml.py @@ -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) diff --git a/tests/scripts/test.toml b/tests/scripts/test.toml new file mode 100644 index 000000000000..dd57f96a4bcd --- /dev/null +++ b/tests/scripts/test.toml @@ -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 ",] +maintainers = [ "Tom Bocklisch ",] +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" \ No newline at end of file diff --git a/tests/scripts/test_get_version_from_toml.py b/tests/scripts/test_get_version_from_toml.py new file mode 100644 index 000000000000..b332e4cfc49e --- /dev/null +++ b/tests/scripts/test_get_version_from_toml.py @@ -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