Skip to content

Commit

Permalink
Merge pull request #174 from airtai/173-create-a-new-ci-job-to-test-t…
Browse files Browse the repository at this point in the history
…he-examples

Add GitHub action file to test the examples in CI
  • Loading branch information
harishmohanraj authored Oct 11, 2023
2 parents 1572bf0 + b3ad6d9 commit b9d690c
Show file tree
Hide file tree
Showing 26 changed files with 141 additions and 8 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/test-faststream-examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test faststream gen examples
on: [workflow_dispatch, pull_request, push]


jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install Dependencies and library
shell: bash
run: |
set -ux
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run pytest
shell: bash
run: |
scripts/test.sh
scripts/test.sh docs_src/tutorial/calculate-mean-app/tests/test_application.py
scripts/test.sh docs_src/tutorial/retrieve-publish-crypto/tests/test_application.py
scripts/test.sh docs_src/app_index_example/test.py
2 changes: 1 addition & 1 deletion faststream_gen/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.7rc0"
__version__ = "0.1.7rc1"
12 changes: 6 additions & 6 deletions nbs/Helper.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"/tmp/tmp4492dn2w/grand-parent/parent/child/application.py\n",
"/tmp/tmp3i7gtvzn/grand-parent/parent/child/application.py\n",
"\n",
"\n",
"print(\"Hello World\")\n",
Expand Down Expand Up @@ -995,7 +995,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"/tmp/tmpv8rje5w0/grand-parent/parent/child/application.py\n",
"/tmp/tmpa4z2fli7/grand-parent/parent/child/application.py\n",
"\n",
"\n",
"print(\"Hello World\")\n",
Expand Down Expand Up @@ -1031,7 +1031,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"<ExceptionInfo FileNotFoundError(\"Error: The file '/tmp/tmpp4oex7rw/grand-parent/parent/child/application.py' does not exist. Please ensure that the specified 'output_path' is valid and that you have the necessary permissions to access it.\") tblen=2>\n"
"<ExceptionInfo FileNotFoundError(\"Error: The file '/tmp/tmp2zdz501b/grand-parent/parent/child/application.py' does not exist. Please ensure that the specified 'output_path' is valid and that you have the necessary permissions to access it.\") tblen=2>\n"
]
}
],
Expand Down Expand Up @@ -1205,15 +1205,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"['api', 'kafka', 'getting-started', 'index', 'release', 'nats', 'rabbit']\n"
"['README', 'faststream', '.pre-commit-config', 'CONTRIBUTING', '.github', 'CODE_OF_CONDUCT', 'pyproject', 'docs', 'scripts', 'SECURITY', 'examples', 'LICENSE', 'tests', '.gitignore', '.secrets']\n"
]
}
],
"source": [
"with download_and_extract_github_repo(FASTSTREAM_REPO_ZIP_URL) as extracted_path:\n",
" files = [p.stem for p in list(Path(extracted_path/FASTSTREAM_ROOT_DIR_NAME/FASTSTREAM_DOCS_DIR_SUFFIX).glob(\"*\"))]\n",
" files = [p.stem for p in list(Path(extracted_path/FASTSTREAM_ROOT_DIR_NAME).glob(\"*\"))]\n",
" print(files)\n",
" assert \"index\" in files"
" assert \"pyproject\" in files"
]
},
{
Expand Down
5 changes: 5 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pytest]
minversion = 7.0
addopts = -ra -q
testpaths =
search/tests
5 changes: 5 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

coverage run -m pytest -x --ff "$@" || \
coverage run -m pytest -x --ff "$@" || \
coverage run -m pytest -x --ff "$@"
File renamed without changes.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from search.examples.example_consume_publish_with_key.test_app import (
test_point_was_incremented,
)

__all__ = ("test_point_was_incremented",)
6 changes: 6 additions & 0 deletions search/tests/examples/test_example_course_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from search.examples.example_course_updates.test_app import (
test_app_with_new_content,
test_app_without_new_content,
)

__all__ = ("test_app_with_new_content", "test_app_without_new_content")
6 changes: 6 additions & 0 deletions search/tests/examples/test_example_execute_trade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from search.examples.example_execute_trade.test_app import (
test_app_with_sell_action,
test_app_without_sell_action,
)

__all__ = ("test_app_without_sell_action", "test_app_with_sell_action")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from search.examples.example_forward_to_another_topic.test_app import test_app

__all__ = ("test_app",)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from search.examples.example_forward_to_multiple_topics.test_app import test_app

__all__ = ("test_app",)
7 changes: 7 additions & 0 deletions search/tests/examples/test_example_infinity_publishing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# import pytest

from search.examples.example_infinity_publishing.test_app import (
test_message_was_published,
)
__all__ = ("test_message_was_published",)
# pytest.mark.slow(test_message_was_published)
9 changes: 9 additions & 0 deletions search/tests/examples/test_example_investment_updates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from search.examples.example_investment_updates.test_app import (
test_invest_grater_amount_than_threshold,
test_invest_smaller_amount_than_threshold,
)

__all__ = (
"test_invest_smaller_amount_than_threshold",
"test_invest_grater_amount_than_threshold",
)
3 changes: 3 additions & 0 deletions search/tests/examples/test_example_new_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from search.examples.example_new_employee.test_app import test_new_employee

__all__ = ("test_new_employee",)
3 changes: 3 additions & 0 deletions search/tests/examples/test_example_pets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from search.examples.example_pets.test_app import test_app

__all__ = ("test_app",)
6 changes: 6 additions & 0 deletions search/tests/examples/test_example_plants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from search.examples.example_plants.test_app import (
test_sell_plant_is_called,
test_still_growing_is_calles,
)

__all__ = ("test_sell_plant_is_called", "test_still_growing_is_calles")
9 changes: 9 additions & 0 deletions search/tests/examples/test_example_product_reviews.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from search.examples.example_product_reviews.test_app import (
test_app_where_review_grade_is_grater_then_5,
test_app_where_review_grade_is_less_then_5,
)

__all__ = (
"test_app_where_review_grade_is_grater_then_5",
"test_app_where_review_grade_is_less_then_5",
)
5 changes: 5 additions & 0 deletions search/tests/examples/test_example_publish_with_key.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from search.examples.example_publish_with_key.test_app import (
test_point_was_incremented,
)

__all__ = ("test_point_was_incremented",)
3 changes: 3 additions & 0 deletions search/tests/examples/test_example_scram256_security.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from search.examples.example_scram256_security.test_app import test_app

__all__ = ("test_app",)
3 changes: 3 additions & 0 deletions search/tests/examples/test_example_scram512_security.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from search.examples.example_scram512_security.test_app import test_app

__all__ = ("test_app",)
9 changes: 9 additions & 0 deletions search/tests/examples/test_example_scrape_weather.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# import pytest

from search.examples.example_scrape_weather.test_app import (
test_message_was_published,
)

__all__ = ("test_message_was_published",)

# pytest.mark.slow(test_message_was_published)
6 changes: 6 additions & 0 deletions search/tests/examples/test_example_social_media_post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from search.examples.example_social_media_post.test_app import (
test_post_with_just_two_likes,
test_post_with_many_likes,
)

__all__ = ("test_post_with_just_two_likes", "test_post_with_many_likes")
5 changes: 5 additions & 0 deletions search/tests/examples/test_example_student_query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from search.examples.example_student_query.test_app import (
test_message_published_to_correct_topic,
)

__all__ = ("test_message_published_to_correct_topic",)
6 changes: 6 additions & 0 deletions search/tests/examples/test_example_weather_updates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from search.examples.example_weather_updates.test_app import (
test_not_published_to_weather_alerts,
test_published_to_weather_alerts,
)

__all__ = ("test_not_published_to_weather_alerts", "test_published_to_weather_alerts")
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### Python library ###
repo = faststream-gen
lib_name = %(repo)s
version = 0.1.7rc0
version = 0.1.7rc1
min_python = 3.8
license = apache2
black_formatting = False
Expand Down

0 comments on commit b9d690c

Please sign in to comment.