From b37e7564a5c76296be0a9dc1aff4c2d50a3f6b30 Mon Sep 17 00:00:00 2001 From: medaka <36759068+medaka0213@users.noreply.github.com> Date: Sun, 7 Apr 2024 21:02:45 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Poetry=E3=81=AB=E7=A7=BB=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 96 ----------------------------- .github/workflows/lint_and_test.yml | 19 +++--- .github/workflows/release.yml | 92 +++++++++++++++++++++++++++ .gitignore | 3 +- pyproject.toml | 25 ++++++++ readme.md | 6 ++ requirements.txt | 1 - setup.py | 28 --------- 8 files changed, 135 insertions(+), 135 deletions(-) delete mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/release.yml create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index ad70d88..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,96 +0,0 @@ -name: Upload pypi package release - -on: - push: - branches: - - master - release: - types: - - created - -env: - VERSION: ${{ github.event.release.tag_name != '' && github.event.release.tag_name || '0.0.0' }} - -jobs: - lint_and_test: - runs-on: ubuntu-latest - - services: - dynamodb: - image: amazon/dynamodb-local:2.0.0 - ports: - - 8000:8000 - options: --name dynamodb - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up Python 3.10 - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - - name: Install Python dependencies - run: | - pip install -r requirements.txt - pip install -r requirements-dev.txt - - - name: Run flake8 linter - run: | - flake8 ddb_single --max-line-length=120 - flake8 tests --max-line-length=120 - flake8 setup.py --max-line-length=120 - - - name: Run unittest - run: | - coverage run -m unittest discover -s tests/ - coverage report - - deploy: - runs-on: ubuntu-latest - needs: lint_and_test - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - - name: Install dependencies - run: | - pip install -r requirements.txt - pip install -r requirements-dev.txt - - - name: Replace version - run: | - echo "__VERSION__ = '${{ env.VERSION }}'" >> ddb_single/__init__.py - rm -rf ./tests - - - name: Build - run: | - python setup.py sdist --formats=zip - - - name: Publish a Python distribution to PyPI - if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - - - name: Generate docs - run: | - cp ./readme.md ./docs_src/readme.md - sphinx-apidoc -f -o ./docs_src ./ddb_single - sphinx-build ./docs_src ./docs - - - name: Publish github pages - uses: JamesIves/github-pages-deploy-action@4.1.5 - with: - branch: gh-pages - folder: ./docs - clean: true - commit-message: Deploy as of ${{ github.sha }} diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index f3ad99e..762b67e 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -23,23 +23,24 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Set up Python 3.10 + - name: Set up Python 3.12 uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: "3.12" - name: Install Python dependencies run: | - pip install -r requirements.txt - pip install -r requirements-dev.txt + pip install poetry + poetry install - name: Run flake8 linter run: | - flake8 ddb_single --max-line-length=120 - flake8 tests --max-line-length=120 - flake8 setup.py --max-line-length=120 + poetry run flake8 . - name: Run unittest run: | - coverage run -m unittest discover -s tests/ - coverage report + poetry run pytest --cov=ddb_single -v + + - name: Test Build + run: | + poetry build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0feb679 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,92 @@ +name: Release +on: + workflow_dispatch: + inputs: + rule: + description: "Rule to run" + required: false + default: patch + type: choice + options: + - major + - minor + - patch + - premajor + - preminor + - prepatch + - prerelease + +jobs: + build: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.12 + + - name: Install dependencies + run: | + pip install poetry + + - name: Get changelog + id: tag_version + uses: mathieudutour/github-tag-action@v5.5 + with: + github_token: ${{ secrets.GH_TOKEN }} + dry_run: true + + - name: Update version + run: | + poetry version ${{ github.event.inputs.rule }} + version=$(poetry version -s) + echo "VERSION=$version" >> $GITHUB_ENV + + - name: Commit and push changes + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git commit -am "[skip ci] Update version to ${{ env.VERSION }}" + git push + + - name: Create and push tag + run: | + git tag v${{ env.VERSION }} + git push origin v${{ env.VERSION }} + + - name: Create GitHub Release + uses: actions/create-release@v1 + with: + tag_name: v${{ env.VERSION }} + release_name: Release v${{ env.VERSION }} + draft: false + prerelease: false + body: ${{ steps.tag_version.outputs.changelog }} + + - name: Publish package + env: + PYPI_LOCAL_USERNAME: __token__ + PYPI_LOCAL_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + poetry build + poetry publish -u $PYPI_LOCAL_USERNAME -p $PYPI_LOCAL_PASSWORD + + - name: Generate docs + run: | + cp ./readme.md ./docs_src/readme.md + poetry run sphinx-apidoc -f -o ./docs_src ./ddb_single + poetry run sphinx-build ./docs_src ./docs + + - name: Publish github pages + uses: JamesIves/github-pages-deploy-action@4.1.5 + with: + branch: gh-pages + folder: ./docs + clean: true + commit-message: Deploy as of ${{ github.sha }} diff --git a/.gitignore b/.gitignore index 2fe14c1..d17a65b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ build dist shared-local-instance.db .coverage -docs \ No newline at end of file +docs +poetry.lock diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e2726bf --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,25 @@ + +[tool.poetry] +name = "ddb_single" +version = "0.4.7" +description = "Python DynamoDB interface, specialized in single-table design." +authors = ["medaka <36759068+medaka0213@users.noreply.github.com>"] +license = "MIT" +homepage = "https://medaka0213.github.io/DynamoDB-SingleTable/" +repository = "https://github.com/medaka0213/DynamoDB-SingleTable" +keywords = ["aws", "dynamodb", "serverless"] +packages = [{ include = "ddb_single" }] + +[tool.poetry.dependencies] +python = "^3.10" +boto3 = "^1.34.79" + +[tool.poetry.dev-dependencies] + +[tool.poetry.group.dev.dependencies] +sphinx = "^7.2.6" +sphinx-rtd-theme = "^2.0.0" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/readme.md b/readme.md index 4b14516..5e0c65e 100644 --- a/readme.md +++ b/readme.md @@ -16,6 +16,12 @@ It makes effective and easy to manage your whole data models for single service. pip install ddb-single ``` +### Start DynamoDB Local + +``` +docker run -d --rm -p 8000:8000 amazon/dynamodb-local +``` + ### Init Table ```python diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 1db657b..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -boto3 \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 272de39..0000000 --- a/setup.py +++ /dev/null @@ -1,28 +0,0 @@ -import ddb_single -import os -from setuptools import setup - -DESCRIPTION = "Python DynamoDB interface, specialized in single-table design." -LONG_DESCRIPTION = DESCRIPTION -if os.path.exists("readme.md"): - with open("readme.md", "r") as fp: - LONG_DESCRIPTION = fp.read() - -setup( - name="ddb_single", - version=ddb_single.__VERSION__, - description=DESCRIPTION, - url="https://github.com/medaka0213/DynamoDB-SingleTable", - author="medaka", - license="MIT", - keywords="aws dynamodb serverless", - packages=[ - "ddb_single", - ], - long_description=LONG_DESCRIPTION, - long_description_content_type="text/markdown", - install_requires=["boto3"], - classifiers=[ - "Programming Language :: Python :: 3.9", - ], -) From 6f47cba22fb47c91f1ada70320bc5e09a5457f20 Mon Sep 17 00:00:00 2001 From: medaka <36759068+medaka0213@users.noreply.github.com> Date: Sun, 7 Apr 2024 21:05:45 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B6=B3=E3=82=8A=E3=81=AA=E3=81=84?= =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 52 ++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e2726bf..f85b6dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,25 +1,27 @@ - -[tool.poetry] -name = "ddb_single" -version = "0.4.7" -description = "Python DynamoDB interface, specialized in single-table design." -authors = ["medaka <36759068+medaka0213@users.noreply.github.com>"] -license = "MIT" -homepage = "https://medaka0213.github.io/DynamoDB-SingleTable/" -repository = "https://github.com/medaka0213/DynamoDB-SingleTable" -keywords = ["aws", "dynamodb", "serverless"] -packages = [{ include = "ddb_single" }] - -[tool.poetry.dependencies] -python = "^3.10" -boto3 = "^1.34.79" - -[tool.poetry.dev-dependencies] - -[tool.poetry.group.dev.dependencies] -sphinx = "^7.2.6" -sphinx-rtd-theme = "^2.0.0" - -[build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" + +[tool.poetry] +name = "ddb_single" +version = "0.4.7" +description = "Python DynamoDB interface, specialized in single-table design." +authors = ["medaka <36759068+medaka0213@users.noreply.github.com>"] +license = "MIT" +homepage = "https://medaka0213.github.io/DynamoDB-SingleTable/" +repository = "https://github.com/medaka0213/DynamoDB-SingleTable" +keywords = ["aws", "dynamodb", "serverless"] +packages = [{ include = "ddb_single" }] + +[tool.poetry.dependencies] +python = "^3.10" +boto3 = "^1.34.79" + +[tool.poetry.dev-dependencies] + +[tool.poetry.group.dev.dependencies] +sphinx = "^7.2.6" +sphinx-rtd-theme = "^2.0.0" +pyproject-flake8 = "^6.1.0" +pytest-cov = "^5.0.0" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api"