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
36 changes: 17 additions & 19 deletions .github/workflows/cli_test.yaml
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
name: CLI Test

on: [ push, workflow_call, pull_request ]
on: [push, workflow_call, pull_request]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
app_type: [ "Blank", "SyncORM", "AsyncORM", "MongoDB", "PostgresSync", "PostgresAsync", "MySQLSync", "MySQLAsync" ]
app_type: ["Blank", "SyncORM", "AsyncORM", "MongoDB", "PostgresSync", "PostgresAsync", "MySQLSync", "MySQLAsync"]

steps:
- name: Check out repository code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install poetry
poetry install

- name: Test CLI Commands
run: |
app_name="${{ matrix.app_type }}App"
case "${{ matrix.app_type }}" in
"Blank")
pynest generate application -n "$app_name"
poetry run pynest generate application -n "$app_name"
;;
"SyncORM")
pynest generate application -n "$app_name" -db sqlite
poetry run pynest generate application -n "$app_name" -db sqlite
;;
"AsyncORM")
pynest generate application -n "$app_name" -db sqlite --is-async
poetry run pynest generate application -n "$app_name" -db sqlite --is-async
;;
"MongoDB")
pynest generate application -n "$app_name" -db mongodb
poetry run pynest generate application -n "$app_name" -db mongodb
;;
"PostgresSync")
pynest generate application -n "$app_name" -db postgresql
poetry run pynest generate application -n "$app_name" -db postgresql
;;
"PostgresAsync")
pynest generate application -n "$app_name" -db postgresql --is-async
poetry run pynest generate application -n "$app_name" -db postgresql --is-async
;;
"MySQLSync")
pynest generate application -n "$app_name" -db mysql
poetry run pynest generate application -n "$app_name" -db mysql
;;
"MySQLAsync")
pynest generate application -n "$app_name" -db mysql --is-async
poetry run pynest generate application -n "$app_name" -db mysql --is-async
;;
esac

cd "$app_name"
pynest generate resource -n user
poetry run pynest generate resource -n user

- name: Verify Boilerplate
run: |
Expand All @@ -74,7 +74,6 @@ jobs:
exit 1
fi


# List of expected files
declare -a files=("main.py" "requirements.txt" "README.md")
declare -a src_level_files=("app_module.py" "app_service.py" "app_controller.py")
Expand All @@ -100,7 +99,6 @@ jobs:
fi
done


# Check each file in the list of module_files
for file in "${module_files[@]}"; do
if [ -f "$app_name/src/user/$file" ]; then
Expand All @@ -111,4 +109,4 @@ jobs:
fi
done

echo "Boilerplate for ${{ matrix.app_type }} generated successfully."
echo "Boilerplate for ${{ matrix.app_type }} generated successfully."
12 changes: 5 additions & 7 deletions .github/workflows/deploy_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ name: Deploy Docs

on: [workflow_call, workflow_dispatch]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
Expand All @@ -27,15 +25,15 @@ jobs:
- name: Copy License File
run: cp LICENSE docs/license.md

- name: Set up Python 3.10
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.9"

- name: Install MKDocs
- name: Install dependencies
run: |
pip install --upgrade pip
pip install mkdocs-material mkdocstrings-python
pip install poetry
poetry install --with docs

- name: Build docs
run: mkdocs build --clean
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ jobs:

steps:
- name: Check out repository code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install poetry
poetry install

- name: Start Application
run: |
Expand All @@ -38,15 +38,15 @@ jobs:
fi

if [ "${{ matrix.app_type }}" == "Blank" ]; then
pynest generate application -n "$app_name"
poetry run pynest generate application -n "$app_name"
else
pynest generate application -n "$app_name" -db sqlite $is_async
pip install aiosqlite
poetry run pynest generate application -n "$app_name" -db sqlite $is_async
poetry add aiosqlite
fi

cd "$app_name"
pynest generate resource -n user
uvicorn "src.app_module:http_server" --host "0.0.0.0" --port 8000 --reload &
poetry run pynest generate resource -n user
poetry run uvicorn "src.app_module:http_server" --host "0.0.0.0" --port 8000 --reload &

- name: Wait for the server to start
run: sleep 10
Expand All @@ -62,4 +62,4 @@ jobs:
curl -f http://localhost:8000/user/

- name: Kill the server
run: kill $(jobs -p) || true
run: kill $(jobs -p) || true
67 changes: 31 additions & 36 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- patch

env:
VERSION_FILE_PATH: nest/__init__.py
VERSION_FILE_PATH: pyproject.toml
CHANGELOG_FILE_PATH: CHANGELOG.md

jobs:
Expand All @@ -36,65 +36,60 @@ jobs:
with:
token: ${{ secrets.RELEASE_GIT_TOKEN }}

- name: Set version
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install Poetry
run: |
VERSION_REGEX='^(__version__ = \")(([[:digit:]]+\.)*[[:digit:]]+)((a|b|rc)[[:digit:]]+)?(\.post[[:digit:]]+)?(.dev[[:digit:]]+)?(\")$'

# get current version from version file
CURRENT_VERSION=`sed -n -E "s/$VERSION_REGEX/\2/p" $VERSION_FILE_PATH`
pip install poetry

- name: Set version using Poetry
run: |
# Extract the current version
CURRENT_VERSION=$(poetry version -s)
echo "Current version: $CURRENT_VERSION"

# switch case for incrementing_version based on input
# Increment version
case ${{ inputs.increment_version }} in
major)
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$1=$1+1; $2=0; $3=0; print $0}' OFS=".")
;;
NEW_VERSION=$(poetry version major | awk '{print $NF}')
;;
minor)
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$2=$2+1; $3=0; print $0}' OFS=".")
;;
NEW_VERSION=$(poetry version minor | awk '{print $NF}')
;;
patch)
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$3=$3+1; print $0}' OFS=".")
;;
NEW_VERSION=$(poetry version patch | awk '{print $NF}')
;;
*)
echo "Invalid input for increment_version"
exit 1
;;
echo "Invalid input for increment_version"
exit 1
;;
esac
echo "New version: $NEW_VERSION"
echo "RELEASE_VERSION=$NEW_VERSION" >> $GITHUB_ENV

# update version file
sed -i -E "s/$VERSION_REGEX/\1$NEW_VERSION\8/" $VERSION_FILE_PATH

- name: Install python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -r requirements-release.txt

- name: Update CHANGELOG.md
run: git-changelog . -o $CHANGELOG_FILE_PATH

- name: Build package
run: python -m build
- name: Build package with Poetry
run: |
poetry build

- name: Commit and push changes
run: |
git config --global user.name "github-actions"
git config --global user.email "github@actions.com"
git add $CHANGELOG_FILE_PATH $VERSION_FILE_PATH
git add $CHANGELOG_FILE_PATH pyproject.toml
git commit -m "Increment version to $NEW_VERSION"
git push

- name: Publish a Python distribution to PyPI
- name: Publish package to PyPI
run: |
python -m twine upload dist/* -u ${{ secrets.PYPI_API_USER }} -p ${{ secrets.PYPI_API_TOKEN }}
poetry publish --username ${{ secrets.PYPI_API_USER }} --password ${{ secrets.PYPI_API_TOKEN }}

- name: Release New Version
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
name: v${{ env.RELEASE_VERSION }}
Expand All @@ -106,4 +101,4 @@ jobs:
contents: read
pages: write
id-token: write
uses: ./.github/workflows/deploy_docs.yaml
uses: ./.github/workflows/deploy_docs.yaml
32 changes: 17 additions & 15 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ on: [push, workflow_call, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Python
id: setup_python
uses: actions/setup-python@v4
with:
python-version: |
3.7
3.8
3.9
3.10
3.11
- name: Install dependencies
run: |
pip install poetry
poetry install --with test

- name: Run tests
run: |
pip install -r requirements-tests.txt
pytest tests
- name: Run tests
run: |
poetry run pytest tests
2 changes: 1 addition & 1 deletion nest/cli/templates/abstract_empty_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def generate_controller_file(self, name) -> str:
from src.{name}.{name}_model import {self.capitalized_name}


@Controller("{name}")
@Controller("{name}", tag="{name}")
class {self.capitalized_name}Controller:

service: {self.capitalized_name}Service = Depends({self.capitalized_name}Service)
Expand Down
3 changes: 1 addition & 2 deletions nest/cli/templates/base_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def __init__(self, module_name: str):
)
self.class_name = f"{self.capitalized_module_name}Module"
self.base_path = Path(os.getcwd())
self.version = __version__
self.nest_path = Path(__file__).parent.parent.parent

@staticmethod
Expand Down Expand Up @@ -368,7 +367,7 @@ def generate_module(self, module_name: str, path: str = None):
def generate_empty_controller_file(self) -> str:
return f"""from nest.core import Controller

@Controller("{self.module_name}")
@Controller("{self.module_name}", tag="{self.module_name}")
class {self.capitalized_module_name}Controller:
...
"""
Expand Down
4 changes: 2 additions & 2 deletions nest/cli/templates/blank_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def controller_file(self):
from .{self.module_name}_model import {self.capitalized_module_name}


@Controller("{self.module_name}")
@Controller("{self.module_name}", tag="{self.module_name}")
class {self.capitalized_module_name}Controller:

def __init__(self, {self.module_name}_service: {self.capitalized_module_name}Service):
Expand Down Expand Up @@ -139,4 +139,4 @@ def settings_file(self):
"""

def requirements_file(self):
return f"""pynest-api=={self.version}"""
return f"""pynest-api"""
2 changes: 1 addition & 1 deletion nest/cli/templates/cli_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def generate_project(self, project_name: str):
self.create_template(src_path / "app_service.py", self.app_service_file())

def requirements_file(self):
return f"""pynest-api=={self.version}"""
return f"""pynest-api"""

def config_file(self):
return ""
Expand Down
Loading
Loading