-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workflows): add build and publish jobs (#2)
- Loading branch information
1 parent
6ac3610
commit cf7f766
Showing
9 changed files
with
366 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
name: Run unit tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
poetry install | ||
- name: Run unittest | ||
run: poetry run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish: | ||
name: Publish to PyPI | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
poetry install | ||
- name: Publish to PyPI | ||
env: | ||
POETRY_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | ||
run: | | ||
poetry config pypi-token.pypi $POETRY_PYPI_TOKEN | ||
poetry publish --build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
[tool.poetry] | ||
name = "doc-comments-ai" | ||
version = "0.1.0" | ||
version = "0.1.2" | ||
description = "" | ||
authors = ["fynnfluegge <[email protected]>"] | ||
readme = "README.md" | ||
packages = [{ include = "doc_comments_ai" }] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.11" | ||
python = "^3.9" | ||
tree-sitter-languages = "^1.7.0" | ||
tree-sitter = "^0.20.1" | ||
python-dotenv = "^1.0.0" | ||
|
@@ -18,7 +18,7 @@ yaspin = "^3.0.0" | |
pytest = "^7.4.0" | ||
|
||
[tool.poetry.scripts] | ||
dccai = "doc_comments_ai.__main__:main" | ||
aicomment = "doc_comments_ai.__main__:main" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def response_fixture(): | ||
return """ | ||
``` | ||
def get_bold_text(text): | ||
\"\"\" | ||
Returns the provided text formatted in bold. | ||
Args: | ||
text (str): The text to be formatted. | ||
Returns: | ||
str: The text formatted in bold. | ||
\"\"\" | ||
return f"\033[01m{text}\033[0m" | ||
``` | ||
""" | ||
|
||
|
||
@pytest.fixture | ||
def response_fixture_language_enclosed(): | ||
return """ | ||
```python | ||
def get_bold_text(text): | ||
\"\"\" | ||
Returns the provided text formatted in bold. | ||
Args: | ||
text (str): The text to be formatted. | ||
Returns: | ||
str: The text formatted in bold. | ||
\"\"\" | ||
return f"\033[01m{text}\033[0m" | ||
``` | ||
""" | ||
|
||
|
||
@pytest.fixture | ||
def response_fixture_with_text(): | ||
return """ | ||
``` | ||
def get_bold_text(text): | ||
\"\"\" | ||
Returns the provided text formatted in bold. | ||
Args: | ||
text (str): The text to be formatted. | ||
Returns: | ||
str: The text formatted in bold. | ||
\"\"\" | ||
return f"\033[01m{text}\033[0m" | ||
``` | ||
This a text | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import pytest | ||
from doc_comments_ai import utils | ||
|
||
|
||
@pytest.mark.usefixtures("response_fixture") | ||
def test_response_parser(response_fixture): | ||
markdown_code_block = utils.extract_content_from_markdown_code_block( | ||
response_fixture, "python" | ||
) | ||
assert ( | ||
markdown_code_block | ||
== """def get_bold_text(text): | ||
\"\"\" | ||
Returns the provided text formatted in bold. | ||
Args: | ||
text (str): The text to be formatted. | ||
Returns: | ||
str: The text formatted in bold. | ||
\"\"\" | ||
return f"\033[01m{text}\033[0m\"""" | ||
) | ||
|
||
|
||
@pytest.mark.usefixtures("response_fixture_language_enclosed") | ||
def test_response_parser_language_enclosed(response_fixture_language_enclosed): | ||
markdown_code_block = utils.extract_content_from_markdown_code_block( | ||
response_fixture_language_enclosed, "python" | ||
) | ||
assert ( | ||
markdown_code_block | ||
== """def get_bold_text(text): | ||
\"\"\" | ||
Returns the provided text formatted in bold. | ||
Args: | ||
text (str): The text to be formatted. | ||
Returns: | ||
str: The text formatted in bold. | ||
\"\"\" | ||
return f"\033[01m{text}\033[0m\"""" | ||
) | ||
|
||
|
||
@pytest.mark.usefixtures("response_fixture_with_text") | ||
def test_response_parser_with_text(response_fixture_with_text): | ||
markdown_code_block = utils.extract_content_from_markdown_code_block( | ||
response_fixture_with_text, "python" | ||
) | ||
assert ( | ||
markdown_code_block | ||
== """def get_bold_text(text): | ||
\"\"\" | ||
Returns the provided text formatted in bold. | ||
Args: | ||
text (str): The text to be formatted. | ||
Returns: | ||
str: The text formatted in bold. | ||
\"\"\" | ||
return f"\033[01m{text}\033[0m\"""" | ||
) |