From 5aff64df2b15209e0922b5b53d2b14a7887f2d28 Mon Sep 17 00:00:00 2001 From: larsrollik <larsrollik@users.noreply.github.com> Date: Sat, 30 Nov 2024 00:56:43 +0000 Subject: [PATCH 01/21] From 'feature/readme-format':\n\n --- .bumpversion.cfg | 2 +- README.md | 8 ++++++-- pyproject.toml | 2 +- templatepy/__init__.py | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 61d8d57..c115708 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.4 +current_version = 0.2.5.dev0 commit = True tag = False tag_name = v{new_version} diff --git a/README.md b/README.md index 97fda10..8985cf1 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ # templatepy Template repo for python repositories & PyPi integration --- -**Version: "0.2.4"** +**Version: "0.2.5.dev0"** ## Usage @@ -239,7 +239,11 @@ git push origin --tags # Push the new tag(s) created by bumpversion # 5. Open a pull request from the feature branch to the main branch # This can be done via GitHub UI, or using GitHub CLI -gh pr create --base main --head feature/my-new-feature --title "New Feature" --body "This is a new feature that adds feature.txt." +gh pr create \ + --base main \ + --head feature/my-new-feature \ + --title "pr_title" \ + --body "pr_body" # 6. After the PR is accepted and merged, delete the feature branch locally and remotely git checkout main # Switch back to main branch diff --git a/pyproject.toml b/pyproject.toml index 4b7a053..78ebe8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "templatepy" -version = "0.2.4" +version = "0.2.5.dev0" authors = [ { name = "Lars B. Rollik", email = "L.B.Rollik@protonmail.com" } ] diff --git a/templatepy/__init__.py b/templatepy/__init__.py index 2d28942..a84e8a3 100644 --- a/templatepy/__init__.py +++ b/templatepy/__init__.py @@ -1,5 +1,5 @@ __author__ = "Lars B. Rollik" -__version__ = "0.2.4" +__version__ = "0.2.5.dev0" def run(): From 563aa0a26c9abc55e30c8917223d50d3c79758a7 Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 01:12:41 +0000 Subject: [PATCH 02/21] updating prod with permissions --- .github/workflows/pr-to-prod.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pr-to-prod.yaml b/.github/workflows/pr-to-prod.yaml index d65bba0..b24142a 100644 --- a/.github/workflows/pr-to-prod.yaml +++ b/.github/workflows/pr-to-prod.yaml @@ -12,6 +12,10 @@ jobs: runs-on: ubuntu-latest if: github.event.pull_request.merged == true + permissions: + contents: write + actions: write + steps: # Step 1: Checkout Repository - name: Checkout Repository From 1cbb55bedc83f2052d627ec27fa64b1808249191 Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 10:21:46 +0000 Subject: [PATCH 03/21] updated workflow manually in prod --- .bumpversion.cfg | 2 +- .github/workflows/pr-to-prod.yaml | 9 ++++++++- README.md | 2 +- pyproject.toml | 3 ++- templatepy/__init__.py | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index c115708..eab32d2 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.5.dev0 +current_version = 0.2.5 commit = True tag = False tag_name = v{new_version} diff --git a/.github/workflows/pr-to-prod.yaml b/.github/workflows/pr-to-prod.yaml index b24142a..2b1ab3e 100644 --- a/.github/workflows/pr-to-prod.yaml +++ b/.github/workflows/pr-to-prod.yaml @@ -47,8 +47,15 @@ jobs: echo "No new commits to squash merge. Exiting." exit 0 fi + + # Generate the commit message COMMIT_MSG="From '${FEATURE_BRANCH}':\n\n$(git log --format='- %s' main..HEAD)" - echo "COMMIT_MSG=${COMMIT_MSG}" >> $GITHUB_ENV + + # Escape the commit message to make it safe for GITHUB_ENV + ESCAPED_COMMIT_MSG=$(echo "$COMMIT_MSG" | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/"/\\"/g') + + # Write the escaped commit message to GITHUB_ENV + echo "COMMIT_MSG=${ESCAPED_COMMIT_MSG}" >> $GITHUB_ENV # Step 5: Perform Squash Merge and Resolve Conflicts in Favor of Main - name: Squash and Resolve Conflicts in Favor of "main" diff --git a/README.md b/README.md index 8985cf1..b085400 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ # templatepy Template repo for python repositories & PyPi integration --- -**Version: "0.2.5.dev0"** +**Version: "0.2.5"** ## Usage diff --git a/pyproject.toml b/pyproject.toml index 78ebe8d..5587fb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "templatepy" -version = "0.2.5.dev0" +version = "0.2.5" authors = [ { name = "Lars B. Rollik", email = "L.B.Rollik@protonmail.com" } ] @@ -15,6 +15,7 @@ classifiers = [ "Intended Audience :: Developers", "Topic :: Software Development :: Libraries :: Python Modules", "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", diff --git a/templatepy/__init__.py b/templatepy/__init__.py index a84e8a3..6f97565 100644 --- a/templatepy/__init__.py +++ b/templatepy/__init__.py @@ -1,5 +1,5 @@ __author__ = "Lars B. Rollik" -__version__ = "0.2.5.dev0" +__version__ = "0.2.5" def run(): From 5011925cee2e4afcec4354b04097db19b25d198c Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 10:25:56 +0000 Subject: [PATCH 04/21] print version --- .github/workflows/release-to-deploy.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release-to-deploy.yaml b/.github/workflows/release-to-deploy.yaml index a51aca1..b2c88b9 100644 --- a/.github/workflows/release-to-deploy.yaml +++ b/.github/workflows/release-to-deploy.yaml @@ -38,13 +38,13 @@ jobs: echo "Version ${VERSION} is valid and tag doesn't exist. Proceeding with release." - # print-version: -# needs: check-version-and-tag -# runs-on: ubuntu-latest -# steps: -# - name: Print version -# run: | -# echo "The version from pyproject.toml is: ${{ needs.check-version-and-tag.outputs.version }}" + print-version: + needs: check-version-and-tag + runs-on: ubuntu-latest + steps: + - name: Print version + run: | + echo "The version from pyproject.toml is: v${{ env.VERSION }}" release: needs: check-version-and-tag From f79a33a35e6919b61a0e3c9f12d0e299c91ff0b0 Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 10:29:05 +0000 Subject: [PATCH 05/21] fix handdown of version in env --- .github/workflows/release-to-deploy.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release-to-deploy.yaml b/.github/workflows/release-to-deploy.yaml index b2c88b9..36a9ace 100644 --- a/.github/workflows/release-to-deploy.yaml +++ b/.github/workflows/release-to-deploy.yaml @@ -9,6 +9,8 @@ jobs: # Step 1: Check if the version is a full release and if the tag already exists check-version-and-tag: runs-on: ubuntu-latest + outputs: + version: ${{ steps.get_version.outputs.version }} steps: - uses: actions/checkout@v4 From 90e14eaf9ff28f6bf7d2c5bfc27fc0f7d640a85a Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 10:36:07 +0000 Subject: [PATCH 06/21] testing fix to var handdown in jobs --- .github/workflows/release-to-deploy.yaml | 35 +++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release-to-deploy.yaml b/.github/workflows/release-to-deploy.yaml index 36a9ace..0cf1257 100644 --- a/.github/workflows/release-to-deploy.yaml +++ b/.github/workflows/release-to-deploy.yaml @@ -6,11 +6,10 @@ on: - prod # Trigger only on push to prod branch jobs: - # Step 1: Check if the version is a full release and if the tag already exists check-version-and-tag: runs-on: ubuntu-latest outputs: - version: ${{ steps.get_version.outputs.version }} + version: ${{ steps.get-version.outputs.version }} steps: - uses: actions/checkout@v4 @@ -19,38 +18,41 @@ jobs: python -m pip install toml # Install toml to parse pyproject.toml - name: Get version from pyproject.toml - id: get_version + id: get-version run: | VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") - echo "VERSION=${VERSION}" >> $GITHUB_ENV # Set version as an environment variable + echo "version=${VERSION}" >> $GITHUB_OUTPUT # Set version as an output - name: Validate version and check if tag exists run: | - # Use the version set in the environment variable - if [[ "${{ env.VERSION }}" =~ (dev|rc)$ ]]; then - echo "Skipping release for version ${VERSION}. This is a pre-release version (dev/rc)." + if [[ "${{ steps.get-version.outputs.version }}" =~ (dev|rc)$ ]]; then + echo "Skipping release for version ${{ steps.get-version.outputs.version }}. This is a pre-release version (dev/rc)." exit 0 # Skip release for dev/rc versions fi - TAG_EXISTS=$(git tag -l "v${{ env.VERSION }}") + TAG_EXISTS=$(git tag -l "v${{ steps.get-version.outputs.version }}") if [[ -n "$TAG_EXISTS" ]]; then - echo "Tag v${{ env.VERSION }} already exists. Skipping release." + echo "Tag v${{ steps.get-version.outputs.version }} already exists. Skipping release." exit 0 # Skip release if tag exists fi - echo "Version ${VERSION} is valid and tag doesn't exist. Proceeding with release." + echo "Version ${{ steps.get-version.outputs.version }} is valid and tag doesn't exist. Proceeding with release." print-version: - needs: check-version-and-tag + needs: [check-version-and-tag] runs-on: ubuntu-latest + env: + VERSION: ${{ needs.check-version-and-tag.outputs.version }} steps: - name: Print version run: | - echo "The version from pyproject.toml is: v${{ env.VERSION }}" + echo "The version from pyproject.toml is: v${VERSION}" release: - needs: check-version-and-tag + needs: [check-version-and-tag] runs-on: ubuntu-latest + env: + VERSION: ${{ needs.check-version-and-tag.outputs.version }} steps: - uses: actions/checkout@v4 @@ -60,12 +62,13 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: "v${{ env.VERSION }}" # Access the version from the environment variable - release_name: "Release v${{ env.VERSION }}" - body: "Release: v${{ env.VERSION }}" + tag_name: "v${VERSION}" # Use env.VERSION for simplicity + release_name: "Release v${VERSION}" + body: "Release: v${VERSION}" draft: false prerelease: false + # Step 3: Deploy to PyPI if it's a valid release deploy: needs: release From d4b118720e2ff723521c7de786cb085741eaca23 Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 10:49:04 +0000 Subject: [PATCH 07/21] reformat --- .github/workflows/release-to-deploy.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-to-deploy.yaml b/.github/workflows/release-to-deploy.yaml index 0cf1257..5e643af 100644 --- a/.github/workflows/release-to-deploy.yaml +++ b/.github/workflows/release-to-deploy.yaml @@ -24,19 +24,21 @@ jobs: echo "version=${VERSION}" >> $GITHUB_OUTPUT # Set version as an output - name: Validate version and check if tag exists + env: + VERSION: ${{ steps.get-version.outputs.version }} run: | - if [[ "${{ steps.get-version.outputs.version }}" =~ (dev|rc)$ ]]; then - echo "Skipping release for version ${{ steps.get-version.outputs.version }}. This is a pre-release version (dev/rc)." + if [[ "$VERSION" =~ (dev|rc)$ ]]; then + echo "Skipping release for version $VERSION. This is a pre-release version (dev/rc)." exit 0 # Skip release for dev/rc versions fi - TAG_EXISTS=$(git tag -l "v${{ steps.get-version.outputs.version }}") + TAG_EXISTS=$(git tag -l "v$VERSION") if [[ -n "$TAG_EXISTS" ]]; then - echo "Tag v${{ steps.get-version.outputs.version }} already exists. Skipping release." + echo "Tag v$VERSION already exists. Skipping release." exit 0 # Skip release if tag exists fi - echo "Version ${{ steps.get-version.outputs.version }} is valid and tag doesn't exist. Proceeding with release." + echo "Version $VERSION is valid and tag doesn't exist. Proceeding with release." print-version: needs: [check-version-and-tag] From 689a64f1066665c1012745b826c2bff55884bd69 Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 10:56:13 +0000 Subject: [PATCH 08/21] fix for var env address --- .github/workflows/release-to-deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-to-deploy.yaml b/.github/workflows/release-to-deploy.yaml index 5e643af..b287d3c 100644 --- a/.github/workflows/release-to-deploy.yaml +++ b/.github/workflows/release-to-deploy.yaml @@ -53,8 +53,7 @@ jobs: release: needs: [check-version-and-tag] runs-on: ubuntu-latest - env: - VERSION: ${{ needs.check-version-and-tag.outputs.version }} + if: needs.check-version-and-tag.outputs.version != null # Proceed only if version is valid steps: - uses: actions/checkout@v4 @@ -63,6 +62,7 @@ jobs: uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ needs.check-version-and-tag.outputs.version }} with: tag_name: "v${VERSION}" # Use env.VERSION for simplicity release_name: "Release v${VERSION}" From 6a68adeefb3993eed49d51b10af0898e595d87ae Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 11:18:19 +0000 Subject: [PATCH 09/21] replacing release action with gh cli --- .github/workflows/release-to-deploy.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/release-to-deploy.yaml b/.github/workflows/release-to-deploy.yaml index b287d3c..8be008e 100644 --- a/.github/workflows/release-to-deploy.yaml +++ b/.github/workflows/release-to-deploy.yaml @@ -70,6 +70,30 @@ jobs: draft: false prerelease: false + release: + needs: [check-version-and-tag] + runs-on: ubuntu-latest + env: + VERSION: ${{ needs.check-version-and-tag.outputs.version }} + steps: + - uses: actions/checkout@v4 + + - name: Install GitHub CLI + run: | + sudo apt-get update + sudo apt-get install -y gh + + - name: Authenticate GitHub CLI + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token + + - name: Create Release + run: | + gh release create "v${VERSION}" \ + --title "Release v${VERSION}" \ + --notes "Release: v${VERSION}" # Step 3: Deploy to PyPI if it's a valid release deploy: From 87742293f0d2f80fa281395eadd9921f681d22f1 Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 11:19:17 +0000 Subject: [PATCH 10/21] replacing release action with gh cli, fix --- .github/workflows/release-to-deploy.yaml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.github/workflows/release-to-deploy.yaml b/.github/workflows/release-to-deploy.yaml index 8be008e..851798d 100644 --- a/.github/workflows/release-to-deploy.yaml +++ b/.github/workflows/release-to-deploy.yaml @@ -50,26 +50,6 @@ jobs: run: | echo "The version from pyproject.toml is: v${VERSION}" - release: - needs: [check-version-and-tag] - runs-on: ubuntu-latest - if: needs.check-version-and-tag.outputs.version != null # Proceed only if version is valid - steps: - - uses: actions/checkout@v4 - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERSION: ${{ needs.check-version-and-tag.outputs.version }} - with: - tag_name: "v${VERSION}" # Use env.VERSION for simplicity - release_name: "Release v${VERSION}" - body: "Release: v${VERSION}" - draft: false - prerelease: false - release: needs: [check-version-and-tag] runs-on: ubuntu-latest From 06f0981cdee3d2e46fb6616a7e1915d7aa648fdd Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 11:30:27 +0000 Subject: [PATCH 11/21] rewrite according to docs --- .github/workflows/release-to-deploy.yaml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release-to-deploy.yaml b/.github/workflows/release-to-deploy.yaml index 851798d..a593c35 100644 --- a/.github/workflows/release-to-deploy.yaml +++ b/.github/workflows/release-to-deploy.yaml @@ -55,20 +55,13 @@ jobs: runs-on: ubuntu-latest env: VERSION: ${{ needs.check-version-and-tag.outputs.version }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: - uses: actions/checkout@v4 - - name: Install GitHub CLI - run: | - sudo apt-get update - sudo apt-get install -y gh - - - name: Authenticate GitHub CLI - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token - - name: Create Release run: | gh release create "v${VERSION}" \ From 49f40ebc04d4a191638486d4401389fdd507155a Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 11:32:35 +0000 Subject: [PATCH 12/21] removed comments --- .github/workflows/release-to-deploy.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-to-deploy.yaml b/.github/workflows/release-to-deploy.yaml index a593c35..197e1bc 100644 --- a/.github/workflows/release-to-deploy.yaml +++ b/.github/workflows/release-to-deploy.yaml @@ -3,7 +3,7 @@ name: Release and Deploy from Prod on: push: branches: - - prod # Trigger only on push to prod branch + - prod jobs: check-version-and-tag: @@ -40,6 +40,7 @@ jobs: echo "Version $VERSION is valid and tag doesn't exist. Proceeding with release." + print-version: needs: [check-version-and-tag] runs-on: ubuntu-latest @@ -50,6 +51,7 @@ jobs: run: | echo "The version from pyproject.toml is: v${VERSION}" + release: needs: [check-version-and-tag] runs-on: ubuntu-latest @@ -68,7 +70,7 @@ jobs: --title "Release v${VERSION}" \ --notes "Release: v${VERSION}" - # Step 3: Deploy to PyPI if it's a valid release + deploy: needs: release if: success() # Proceed if release creation is successful From 1b42026d19a7ac0378aade262dcb3ed82e53c576 Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 15:23:47 +0000 Subject: [PATCH 13/21] propagate workflow fix --- .bumpversion.cfg | 2 +- .github/workflows/pr-to-prod.yaml | 19 +++++++++++++------ README.md | 12 +++++++++++- pyproject.toml | 2 +- templatepy/__init__.py | 2 +- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index eab32d2..b1b1536 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.5 +current_version = 0.2.6.dev0 commit = True tag = False tag_name = v{new_version} diff --git a/.github/workflows/pr-to-prod.yaml b/.github/workflows/pr-to-prod.yaml index 2b1ab3e..a8702c7 100644 --- a/.github/workflows/pr-to-prod.yaml +++ b/.github/workflows/pr-to-prod.yaml @@ -59,6 +59,8 @@ jobs: # Step 5: Perform Squash Merge and Resolve Conflicts in Favor of Main - name: Squash and Resolve Conflicts in Favor of "main" + env: + COMMIT_MSG: ${{ steps.commit_message.outputs.COMMIT_MSG }} run: | # Fetch latest changes for safety git fetch origin main @@ -68,16 +70,21 @@ jobs: git checkout prod # Perform a squash merge from 'main' (staged changes without committing) - git merge --squash main + git merge --squash main || true # Resolve conflicts in favor of 'main' git checkout -f main -- . - # Stage all changes (mark conflicts as resolved) + # Stage all changes to mark conflicts as resolved git add . - # Commit the squashed changes with the generated message - git commit -m "${{ env.COMMIT_MSG }}" + # Check if there are changes to commit + if git diff --cached --quiet; then + echo "No changes to commit." + else + # Commit the squashed changes with the generated message + git commit -m "$COMMIT_MSG" - # Push the updated 'prod' branch to the repository - git push origin prod + # Push the updated 'prod' branch to the repository + git push origin prod + fi diff --git a/README.md b/README.md index b085400..9e2693a 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ # templatepy Template repo for python repositories & PyPi integration --- -**Version: "0.2.5"** +**Version: "0.2.6.dev0"** ## Usage @@ -279,6 +279,16 @@ For further reading on the transition to `pyproject.toml` and the removal of `se - [PEP-518](https://peps.python.org/pep-0518/) - [Discussion on Setup.cfg Deprecation](https://stackoverflow.com/questions/44878600/is-setup-cfg-deprecated) +#### Using Github CLI in actions workflows + +[CLI in actions (docs)](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-github-cli-in-workflows) + +```yaml +- name: Create a pull request + run: gh pr create --title "My pull request" --body "This is an amazing PR" --label bug + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} +``` ## Common issues diff --git a/pyproject.toml b/pyproject.toml index 5587fb6..2c91997 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "templatepy" -version = "0.2.5" +version = "0.2.6.dev0" authors = [ { name = "Lars B. Rollik", email = "L.B.Rollik@protonmail.com" } ] diff --git a/templatepy/__init__.py b/templatepy/__init__.py index 6f97565..6ba770a 100644 --- a/templatepy/__init__.py +++ b/templatepy/__init__.py @@ -1,5 +1,5 @@ __author__ = "Lars B. Rollik" -__version__ = "0.2.5" +__version__ = "0.2.6.dev0" def run(): From 292c5e48d7bd955bdf81c11b80eb43dc4de18d19 Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 15:30:37 +0000 Subject: [PATCH 14/21] propagate fix --- .github/workflows/release-to-deploy.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release-to-deploy.yaml b/.github/workflows/release-to-deploy.yaml index 197e1bc..c3eda6a 100644 --- a/.github/workflows/release-to-deploy.yaml +++ b/.github/workflows/release-to-deploy.yaml @@ -27,7 +27,7 @@ jobs: env: VERSION: ${{ steps.get-version.outputs.version }} run: | - if [[ "$VERSION" =~ (dev|rc)$ ]]; then + if [[ "$VERSION" =~ (dev|rc)[0-9]*$ ]]; then echo "Skipping release for version $VERSION. This is a pre-release version (dev/rc)." exit 0 # Skip release for dev/rc versions fi @@ -60,7 +60,6 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} permissions: contents: write - steps: - uses: actions/checkout@v4 From 026ca9df628baa1a3daf0999d6faba363865f3e8 Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 15:44:55 +0000 Subject: [PATCH 15/21] fix to prod --- .bumpversion.cfg | 2 +- .github/workflows/pr-to-prod.yaml | 7 ++++++- README.md | 11 +++++++---- pyproject.toml | 2 +- templatepy/__init__.py | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index b1b1536..b93cdec 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.6.dev0 +current_version = 0.2.6 commit = True tag = False tag_name = v{new_version} diff --git a/.github/workflows/pr-to-prod.yaml b/.github/workflows/pr-to-prod.yaml index a8702c7..e106076 100644 --- a/.github/workflows/pr-to-prod.yaml +++ b/.github/workflows/pr-to-prod.yaml @@ -78,10 +78,15 @@ jobs: # Stage all changes to mark conflicts as resolved git add . - # Check if there are changes to commit + # Ensure there are no empty changes before committing if git diff --cached --quiet; then echo "No changes to commit." else + # Ensure there's a commit message before committing + if [ -z "$COMMIT_MSG" ]; then + COMMIT_MSG="Squash merge from 'main' into 'prod'." + fi + # Commit the squashed changes with the generated message git commit -m "$COMMIT_MSG" diff --git a/README.md b/README.md index 9e2693a..180d1dd 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ # templatepy Template repo for python repositories & PyPi integration --- -**Version: "0.2.6.dev0"** +**Version: "0.2.6"** ## Usage @@ -279,9 +279,11 @@ For further reading on the transition to `pyproject.toml` and the removal of `se - [PEP-518](https://peps.python.org/pep-0518/) - [Discussion on Setup.cfg Deprecation](https://stackoverflow.com/questions/44878600/is-setup-cfg-deprecated) -#### Using Github CLI in actions workflows +#### Using GitHub CLI in Workflow Actions -[CLI in actions (docs)](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-github-cli-in-workflows) +Easily integrate GitHub CLI into workflows to perform repository tasks. See the [GitHub CLI in workflows documentation](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-github-cli-in-workflows). + +**Example: Create a pull request** ```yaml - name: Create a pull request @@ -290,6 +292,7 @@ For further reading on the transition to `pyproject.toml` and the removal of `se GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` + ## Common issues ### `bump2version` fails on git tag with exit status 128 @@ -310,7 +313,7 @@ For further reading on the transition to `pyproject.toml` and the removal of `se Which one is the key id you might ask? ``` -/home/user/.gnupg/secring.gpg +/home/$USER/.gnupg/secring.gpg ------------------------------ sec 4096R/<KEY_ID> 2024-11-22 [expires: 2025-11-22] uid Your Name <youremail@example.com> diff --git a/pyproject.toml b/pyproject.toml index 2c91997..d927df4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "templatepy" -version = "0.2.6.dev0" +version = "0.2.6" authors = [ { name = "Lars B. Rollik", email = "L.B.Rollik@protonmail.com" } ] diff --git a/templatepy/__init__.py b/templatepy/__init__.py index 6ba770a..3e0ea9b 100644 --- a/templatepy/__init__.py +++ b/templatepy/__init__.py @@ -1,5 +1,5 @@ __author__ = "Lars B. Rollik" -__version__ = "0.2.6.dev0" +__version__ = "0.2.6" def run(): From f38d333a7a04f5e2e2ad6fb122dfb01667577a50 Mon Sep 17 00:00:00 2001 From: larsrollik <larsrollik@users.noreply.github.com> Date: Sat, 30 Nov 2024 16:09:15 +0000 Subject: [PATCH 16/21] Squash merge from 'main' into 'prod'. --- .bumpversion.cfg | 2 +- .pre-commit-config.yaml | 55 ++++++++++++++++++++++++----------------- README.md | 2 +- pyproject.toml | 2 +- templatepy/__init__.py | 2 +- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index b93cdec..0fb163c 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.6 +current_version = 0.2.7.dev0 commit = True tag = False tag_name = v{new_version} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d8eca1a..e71cf29 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,27 +1,36 @@ +# Update versions with: pre-commit autoupdate +# Check for other available hooks: https://github.com/pre-commit/pre-commit-hooks repos: -- repo: https://github.com/asottile/reorder_python_imports - rev: v2.6.0 + - repo: https://github.com/asottile/reorder_python_imports + rev: v3.14.0 hooks: - - id: reorder-python-imports -- repo: https://github.com/ambv/black - rev: 22.6.0 + - id: reorder-python-imports + + - repo: https://github.com/ambv/black + rev: 24.10.0 hooks: - - id: black -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + - id: black + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 hooks: - - id: end-of-file-fixer - exclude: '.bumpversion.cfg' - - id: trailing-whitespace - exclude: '.bumpversion.cfg' - - id: check-case-conflict - - id: check-merge-conflict - - id: check-yaml - args: [ '--unsafe' ] - - id: detect-private-key - - id: forbid-new-submodules - - id: check-json - - id: pretty-format-json - args: ['--autofix', '--indent=4', '--no-ensure-ascii', ] - - id: check-added-large-files - - id: flake8 + - id: end-of-file-fixer + exclude: '.bumpversion.cfg' + - id: trailing-whitespace + exclude: '.bumpversion.cfg' + - id: check-case-conflict + - id: check-merge-conflict + - id: check-yaml + args: [ '--unsafe' ] + - id: debug-statements + - id: detect-private-key + - id: forbid-new-submodules + - id: check-json + - id: pretty-format-json + args: ['--autofix', '--indent=4', '--no-ensure-ascii'] + - id: check-added-large-files + + - repo: https://github.com/PyCQA/flake8 + rev: 7.1.1 + hooks: + - id: flake8 diff --git a/README.md b/README.md index 180d1dd..58da76c 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ # templatepy Template repo for python repositories & PyPi integration --- -**Version: "0.2.6"** +**Version: "0.2.7.dev0"** ## Usage diff --git a/pyproject.toml b/pyproject.toml index d927df4..5c129a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "templatepy" -version = "0.2.6" +version = "0.2.7.dev0" authors = [ { name = "Lars B. Rollik", email = "L.B.Rollik@protonmail.com" } ] diff --git a/templatepy/__init__.py b/templatepy/__init__.py index 3e0ea9b..f32a034 100644 --- a/templatepy/__init__.py +++ b/templatepy/__init__.py @@ -1,5 +1,5 @@ __author__ = "Lars B. Rollik" -__version__ = "0.2.6" +__version__ = "0.2.7.dev0" def run(): From d5fd92f10163514adc2bfe266ec11b77ecaa4aef Mon Sep 17 00:00:00 2001 From: "Lars B. Rollik" <l.b.rollik@protonmail.com> Date: Sat, 30 Nov 2024 16:23:14 +0000 Subject: [PATCH 17/21] updating workflows from main --- .github/workflows/pr-to-prod.yaml | 2 +- .github/workflows/pre-pr-checks.yaml | 2 +- .github/workflows/release-to-deploy.yaml | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr-to-prod.yaml b/.github/workflows/pr-to-prod.yaml index e106076..6c03218 100644 --- a/.github/workflows/pr-to-prod.yaml +++ b/.github/workflows/pr-to-prod.yaml @@ -1,4 +1,4 @@ -name: PR into main -> Squash Merge to Prod +name: pr_to_prod on: pull_request: diff --git a/.github/workflows/pre-pr-checks.yaml b/.github/workflows/pre-pr-checks.yaml index ce022ae..5c9879a 100644 --- a/.github/workflows/pre-pr-checks.yaml +++ b/.github/workflows/pre-pr-checks.yaml @@ -1,6 +1,6 @@ # Commits in feature branches will run linting and testing jobs. # PRs targeting the main branch will run the full pre-PR checks. -name: Pre-PR Checks +name: pre_pr_checks on: push: diff --git a/.github/workflows/release-to-deploy.yaml b/.github/workflows/release-to-deploy.yaml index c3eda6a..8d1fd3f 100644 --- a/.github/workflows/release-to-deploy.yaml +++ b/.github/workflows/release-to-deploy.yaml @@ -1,9 +1,15 @@ -name: Release and Deploy from Prod +name: release_to_deploy + +#on: +# push: +# branches: +# - prod on: - push: - branches: - - prod + workflow_run: + workflows: [pr_to_prod] + types: + - completed jobs: check-version-and-tag: From 769028647cc62dd860a70a8eb32de1fd7d3632a0 Mon Sep 17 00:00:00 2001 From: larsrollik <larsrollik@users.noreply.github.com> Date: Sat, 30 Nov 2024 16:29:02 +0000 Subject: [PATCH 18/21] Squash merge from 'main' into 'prod'. --- .bumpversion.cfg | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 22 +++++++++------------- README.md | 2 +- pyproject.toml | 2 +- templatepy/__init__.py | 2 +- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 0fb163c..04ab5f3 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.7.dev0 +current_version = 0.2.7 commit = True tag = False tag_name = v{new_version} diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 82e4bc9..8e8ba30 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,41 +1,37 @@ # Checklist **Please complete this checklist before submission** -- [ ] All changes were made in a **separate** branch. (Branches **MUST** have descriptive names that start with either the `fix/` or `feature/` prefixes. Good examples are: `fix/some-bug-issue` or `feature/issue-templates`. +- [ ] All changes were made in a **separate** branch. (Branches **MUST** have descriptive names that start with either the `fix/` or `feature/` prefixes. Good examples are: `fix/some-bug-issue` or `feature/issue-templates`). - [ ] The PR commit has a descriptive commit message with a short title (first line). -- [ ] The PR targets the `dev` branch, never the `main`. +- [ ] The PR targets the `main` branch (not `dev`). - [ ] Tests for the changes have been added where applicable (for bug fixes/features). - [ ] The documentation has been updated to reflect any changes. -- [ ] The code has been linted and formatted locally (see `pre-commit-config.yaml`) +- [ ] The code has been linted and formatted locally (see `pre-commit-config.yaml`). - [ ] Add `closes #X` (where X is the issue number) in the comment to auto-close the issue that this PR fixes (if applicable). - # Description template for PR ## **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) - [ ] Bug fix - [ ] New feature - [ ] Other: - ## What is the current behavior? Link any open issues or pull requests here. - ## What is the new behavior / fix / change? - +Describe the change that this PR introduces. ## Does this PR introduce a breaking change for backwards compatibility? In particular, what does the user have to consider due to this PR? - ## Has this PR been tested? -Please explain (1) how has this PR been tested, and (2) if tests have been added to the code base. - +Please explain: +1. **How** has this PR been tested? +2. If tests have been added to the code base, briefly describe them. ## Does this PR require an update to the documentation? -If any features have changed, or have been added. Please explain how the documentation has been updated (and link to the associated PR). - +If any features have changed, or have been added, please explain how the documentation has been updated (and link to the associated PR). ## Other information Add any further details here. -<!-- Closes #X --> +<!-- Closes #X --> diff --git a/README.md b/README.md index 58da76c..4b1f0e9 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ # templatepy Template repo for python repositories & PyPi integration --- -**Version: "0.2.7.dev0"** +**Version: "0.2.7"** ## Usage diff --git a/pyproject.toml b/pyproject.toml index 5c129a6..c25aae1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "templatepy" -version = "0.2.7.dev0" +version = "0.2.7" authors = [ { name = "Lars B. Rollik", email = "L.B.Rollik@protonmail.com" } ] diff --git a/templatepy/__init__.py b/templatepy/__init__.py index f32a034..4978ed8 100644 --- a/templatepy/__init__.py +++ b/templatepy/__init__.py @@ -1,5 +1,5 @@ __author__ = "Lars B. Rollik" -__version__ = "0.2.7.dev0" +__version__ = "0.2.7" def run(): From 5dfba13b2c4720f73c6787de9019493fd2dec72f Mon Sep 17 00:00:00 2001 From: larsrollik <larsrollik@users.noreply.github.com> Date: Thu, 20 Feb 2025 12:22:35 +0000 Subject: [PATCH 19/21] Squash merge from 'main' into 'prod'. --- .github/workflows/pre-pr-checks.yaml | 10 ++- .pre-commit-config.yaml | 46 ++++------- README.md | 19 +++-- pyproject.toml | 80 +++++++++++++------ templatepy/__init__.py | 10 ++- .../test_integration/test_placeholder.py | 13 ++- tests/tests/test_unit/test_unit.py | 12 ++- 7 files changed, 107 insertions(+), 83 deletions(-) diff --git a/.github/workflows/pre-pr-checks.yaml b/.github/workflows/pre-pr-checks.yaml index 65efe05..e24e75f 100644 --- a/.github/workflows/pre-pr-checks.yaml +++ b/.github/workflows/pre-pr-checks.yaml @@ -16,28 +16,30 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10', '3.11'] + python-version: ['3.12'] # '3.10', '3.11', steps: - uses: actions/checkout@v4 + - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install --upgrade pip pip install .[dev] + - name: Run linting run: | - black ./ --check --verbose - flake8 --verbose + pre-commit run --all-files --verbose --show-diff-on-failure # Testing job runs on all branches (including feature branches) test: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10', '3.11'] + python-version: ['3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 - name: Set up Python diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e71cf29..a5532be 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,36 +1,20 @@ # Update versions with: pre-commit autoupdate -# Check for other available hooks: https://github.com/pre-commit/pre-commit-hooks repos: - - repo: https://github.com/asottile/reorder_python_imports - rev: v3.14.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.8.3 hooks: - - id: reorder-python-imports + # Run the linter. + - id: ruff + args: + - "--fix" + - "--show-fixes" + # Run the formatter. + - id: ruff-format - - repo: https://github.com/ambv/black - rev: 24.10.0 + # Add mypy for static type checking + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.13.0 hooks: - - id: black - - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 - hooks: - - id: end-of-file-fixer - exclude: '.bumpversion.cfg' - - id: trailing-whitespace - exclude: '.bumpversion.cfg' - - id: check-case-conflict - - id: check-merge-conflict - - id: check-yaml - args: [ '--unsafe' ] - - id: debug-statements - - id: detect-private-key - - id: forbid-new-submodules - - id: check-json - - id: pretty-format-json - args: ['--autofix', '--indent=4', '--no-ensure-ascii'] - - id: check-added-large-files - - - repo: https://github.com/PyCQA/flake8 - rev: 7.1.1 - hooks: - - id: flake8 + - id: mypy + additional_dependencies: ["types-toml"] \ No newline at end of file diff --git a/README.md b/README.md index 450c4a4..ca77366 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,10 @@ [bump2version]: (https://github.com/c4urself/bump2version [pre-commit]: https://pre-commit.com -[black]: https://github.com/psf/black + +[//]: # ([black]: https://github.com/psf/black) +[ruff]: https://docs.astral.sh/ruff +[mypy]: https://mypy.readthedocs.io [pypi]: pypi.org [test.pypi]: test.pypi.org @@ -28,7 +31,6 @@ [](https://pypi.org/project/templatepy) [](https://pypi.org/project/templatepy)  -[](https://github.com/python/black) [](https://github.com/pre-commit/pre-commit) @@ -76,7 +78,7 @@ Template repo for python repositories & PyPi integration Central configuration file that replaces the traditional `setup.cfg` and `setup.py` files: - **Build System**: Specifies the build system requirements and configuration, as defined in [PEP 518](https://peps.python.org/pep-0518/) and [PEP 621](https://peps.python.org/pep-0621/). - **Package Metadata**: Includes the project's metadata (name, version, dependencies, etc.). - - **Code Formatting**: Configuration for tools like [black] and [flake8] (if used). + - **Code Formatting**: Configuration for tools like [ruff] and [mypy] (if used). - **Optional Dependencies**: Organizes extra dependencies for development or other environments. - **`setup.py`**: @@ -213,7 +215,8 @@ The package will then be automatically uploaded to [PyPI](https://pypi.org/) or 3) Use bumpversion to bump the version (you can adjust patch, minor, or major based on what change you want), and create a release tag. 4) Push both the feature branch and the release tag to the remote repository. 5) Open a pull request using GitHub CLI (gh pr create) or the GitHub UI to merge the feature branch into main. -6) After the PR is merged, delete the feature branch both locally and remotely. +6) Review the pull request online or in the CLI (e.g.: `gh pr list`, `gh pr view <nr>`, `gh pr merge <nr> --merge --delete-branch`) +7) After the PR is merged, delete the feature branch both locally and remotely. ### Example commands for the workflow: @@ -245,7 +248,13 @@ gh pr create \ --title "pr_title" \ --body "pr_body" -# 6. After the PR is accepted and merged, delete the feature branch locally and remotely +# 6. +gh pr list # -> shows PRs and their IDs +gh pr view <id> + +gh pr merge <id> --merge --delete-branch + +# 7. After the PR is accepted and merged, delete the feature branch locally and remotely git checkout main # Switch back to main branch git pull origin main # Ensure your main branch is up-to-date git branch -d feature/my-new-feature # Delete the local feature branch diff --git a/pyproject.toml b/pyproject.toml index c25aae1..422af17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,29 +58,57 @@ where = [""] [tool.pytest.ini_options] addopts = "--cov=templatepy --cov-report=term-missing --maxfail=5" -[tool.black] -target-version = ["py310", "py311"] #, "py312" -skip-string-normalization = false -line-length = 79 -include = '\\.pyi?$' -exclude = ''' -/( - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | _build - | buck-out - | build - | dist -)/ -''' - -[tool.flake8] -ignore = ["E203", "E266", "E501", "W503", "F403", "F401"] -max-line-length = 79 -max-complexity = 18 -select = ["B", "C", "E", "F", "W", "T4", "B9"] -exclude = ["__init__.py", "build", "__pycache__", ".git", "tests"] +[tool.ruff] +line-length = 88 +indent-width = 4 +include = ["*.pyi"] +extend-exclude = ["*.eggs", "*.git", "*.hg", "*.mypy_cache", "*.tox", "*.venv", "*_build", "*buck-out", "*build", "*dist"] + +[tool.ruff.lint] +select = [ + "E", # Pyflakes (general errors) + "W", # Pycodestyle warnings + "F", # Pyflakes checks (includes unused imports) + "I", # isort (import sorting) + "UP", # pyupgrade (Python syntax upgrades) + "YTT", # check for YAML issues + "SIM", # detect unnecessary comprehensions, loops, etc. + "PTH", # checks for pathlib best practices + "TCH", + "PYI", +] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +[tool.ruff.format] +# Like Black, use double quotes for strings. +quote-style = "double" +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = true +docstring-code-line-length = "dynamic" + +[tool.ruff.lint.pydocstyle] +convention = "numpy" # Accepts: "google", "numpy", or "pep257". + +[tool.ruff.lint.per-file-ignores] +".bumpversion.cfg" = ["E501", "W291", "W292"] # Equivalent to excluding it from whitespace checks + +[tool.mypy] +# strict = true +# follow_imports = "silent" +warn_return_any = false +ignore_missing_imports = true diff --git a/templatepy/__init__.py b/templatepy/__init__.py index 4978ed8..1f1e1ef 100644 --- a/templatepy/__init__.py +++ b/templatepy/__init__.py @@ -1,7 +1,13 @@ __author__ = "Lars B. Rollik" -__version__ = "0.2.7" + +from importlib.metadata import PackageNotFoundError, version + +try: + __version__ = version("subject_weight_db") +except PackageNotFoundError: + __version__ = "" def run(): - """Example `run` function for entrypoint in `setup.cfg`""" + """Example `run` function for entrypoint defined in `pyproject.toml`.""" print("Hello, world!") diff --git a/tests/tests/test_integration/test_placeholder.py b/tests/tests/test_integration/test_placeholder.py index f02932c..3ab3427 100644 --- a/tests/tests/test_integration/test_placeholder.py +++ b/tests/tests/test_integration/test_placeholder.py @@ -3,13 +3,13 @@ import toml -def get_package_name(): +def get_package_name() -> str: """Retrieve package name from pyproject.toml.""" project_data = toml.load("pyproject.toml") - return project_data["project"]["name"] + return str(project_data["project"]["name"]) -def test_package_functionality(): +def test_package_functionality() -> None: """Test the package dynamically after installation.""" package_name = get_package_name() @@ -19,13 +19,10 @@ def test_package_functionality(): # Dynamically import the package result = subprocess.run( ["python", "-c", f"import {package_name}"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, text=True, ) - assert ( - result.returncode == 0 - ), f"Dynamic package import failed: {result.stderr}" + assert result.returncode == 0, f"Dynamic package import failed: {result.stderr}" # Cleanup: Uninstall the package subprocess.run(["pip", "uninstall", "-y", package_name], check=True) diff --git a/tests/tests/test_unit/test_unit.py b/tests/tests/test_unit/test_unit.py index a560b58..76d1a3b 100644 --- a/tests/tests/test_unit/test_unit.py +++ b/tests/tests/test_unit/test_unit.py @@ -2,7 +2,7 @@ import sys -def ensure_toml_installed(): +def ensure_toml_installed() -> None: """Ensure toml is installed in the current environment.""" try: __import__("toml") @@ -13,12 +13,12 @@ def ensure_toml_installed(): ) -def test_python_version(): +def test_python_version() -> None: """Test that Python version is compatible with the environment.""" assert sys.version_info >= (3, 8), "Python version must be 3.8 or higher" -def test_package_installation(): +def test_package_installation() -> None: """Test dynamic installation and uninstallation of the package.""" ensure_toml_installed() import toml @@ -32,8 +32,7 @@ def test_package_installation(): # Check that the package is installed result = subprocess.run( [sys.executable, "-m", "pip", "show", package_name], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, text=True, ) assert result.returncode == 0, "Package installation failed" @@ -47,8 +46,7 @@ def test_package_installation(): # Verify the package is uninstalled result = subprocess.run( [sys.executable, "-m", "pip", "show", package_name], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, text=True, ) assert result.returncode != 0, "Package uninstallation failed" From 803908116529ab0526dc5ce93d9e7406a0bc7040 Mon Sep 17 00:00:00 2001 From: larsrollik <larsrollik@users.noreply.github.com> Date: Thu, 20 Feb 2025 13:14:51 +0000 Subject: [PATCH 20/21] Squash merge from 'main' into 'prod'. --- .bumpversion.cfg | 2 +- README.md | 2 +- pyproject.toml | 2 +- templatepy/__init__.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 04ab5f3..cb3c088 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.7 +current_version = 0.2.8.dev0 commit = True tag = False tag_name = v{new_version} diff --git a/README.md b/README.md index ca77366..3ed21c5 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ # templatepy Template repo for python repositories & PyPi integration --- -**Version: "0.2.7"** +**Version: "0.2.8.dev0"** ## Usage diff --git a/pyproject.toml b/pyproject.toml index 422af17..5fd9c32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "templatepy" -version = "0.2.7" +version = "0.2.8.dev0" authors = [ { name = "Lars B. Rollik", email = "L.B.Rollik@protonmail.com" } ] diff --git a/templatepy/__init__.py b/templatepy/__init__.py index 1f1e1ef..7c59ee0 100644 --- a/templatepy/__init__.py +++ b/templatepy/__init__.py @@ -5,7 +5,7 @@ try: __version__ = version("subject_weight_db") except PackageNotFoundError: - __version__ = "" + __version__ = "0.2.8.dev0" def run(): From d14c39b2ea4cd3a6728fed0a42dd3e8c2f774ac4 Mon Sep 17 00:00:00 2001 From: larsrollik <larsrollik@users.noreply.github.com> Date: Thu, 20 Feb 2025 13:33:21 +0000 Subject: [PATCH 21/21] Squash merge from 'main' into 'prod'. --- .bumpversion.cfg | 2 +- README.md | 2 +- pyproject.toml | 6 +++--- templatepy/__init__.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index cb3c088..7f9e0b3 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.8.dev0 +current_version = 0.2.9 commit = True tag = False tag_name = v{new_version} diff --git a/README.md b/README.md index 3ed21c5..96589fa 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ # templatepy Template repo for python repositories & PyPi integration --- -**Version: "0.2.8.dev0"** +**Version: "0.2.9"** ## Usage diff --git a/pyproject.toml b/pyproject.toml index 5fd9c32..f9af905 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "templatepy" -version = "0.2.8.dev0" +version = "0.2.9" authors = [ { name = "Lars B. Rollik", email = "L.B.Rollik@protonmail.com" } ] @@ -74,8 +74,8 @@ select = [ "YTT", # check for YAML issues "SIM", # detect unnecessary comprehensions, loops, etc. "PTH", # checks for pathlib best practices - "TCH", - "PYI", + "TCH", # checks for typing best practices + "PYI", # checks for pyi files ] ignore = [] diff --git a/templatepy/__init__.py b/templatepy/__init__.py index 7c59ee0..d60b33a 100644 --- a/templatepy/__init__.py +++ b/templatepy/__init__.py @@ -5,7 +5,7 @@ try: __version__ = version("subject_weight_db") except PackageNotFoundError: - __version__ = "0.2.8.dev0" + __version__ = "0.2.9" def run():