Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactored for 3.12+ #71

Merged
merged 2 commits into from
Nov 3, 2024
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
57 changes: 0 additions & 57 deletions .github/workflows/publish.yml

This file was deleted.

121 changes: 121 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

on: push

env:
# Change these for your project's URLs
PYPI_URL: https://pypi.org/project/the-well-maintained-test/
PYPI_TEST_URL: https://test.pypi.org/project/the-well-maintained-test/

jobs:

build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
run:
python3 -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: ${{ env.PYPI_URL }}
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.10

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'

# publish-to-testpypi:
# name: Publish Python 🐍 distribution 📦 to TestPyPI
# if: startsWith(github.ref, 'refs/tags/') # only publish to TestPyPI on tag pushes
# needs:
# - build
# runs-on: ubuntu-latest

# environment:
# name: testpypi
# url: ${{ env.PYPI_TEST_URL }}

# permissions:
# id-token: write # IMPORTANT: mandatory for trusted publishing

# steps:
# - name: Download all the dists
# uses: actions/download-artifact@v4
# with:
# name: python-package-distributions
# path: dist/
# - name: Publish distribution 📦 to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1.10
# with:
# repository-url: https://test.pypi.org/legacy/
# skip-existing: true
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12-dev"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
23 changes: 23 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import nox

PYTHON_VERSIONS = [
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
"3.13",
]


@nox.session(python=PYTHON_VERSIONS)
def tests(session):
# Install pytest and any other test dependencies
session.install("pytest")
session.install("pytest-cov")

# Install the package itself
session.install(".")

# Run pytest with coverage reporting
session.run("pytest", "--cov", "--cov-report=term-missing", *session.posargs)
17 changes: 11 additions & 6 deletions src/the_well_maintained_test/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import re
from datetime import datetime
from datetime import datetime, timezone
from gettext import ngettext
from operator import attrgetter
from pathlib import Path
Expand Down Expand Up @@ -74,7 +74,12 @@ def bug_responding(bugs_url: str, headers: dict) -> str:
bug_comment_list = sorted(bug_comment_list, key=attrgetter("create_date"), reverse=True)
if bug_comment_list:
bug_turn_around_time_reply_days = (bug_comment_list[0].create_date - bug_create_date).days
days_since_last_bug_comment = (datetime.utcnow() - bug_comment_list[0].create_date).days
# If bug_comment_list[0].create_date is naive, make it timezone-aware
if bug_comment_list[0].create_date.tzinfo is None:
create_date = bug_comment_list[0].create_date.replace(tzinfo=timezone.utc)
else:
create_date = bug_comment_list[0].create_date
days_since_last_bug_comment = (datetime.now(timezone.utc) - create_date).days
# TODO: add logic to better colorize the message
message1 = f"The maintainer took {bug_turn_around_time_reply_days} "
message1 += "days to respond to the bug report"
Expand Down Expand Up @@ -197,8 +202,8 @@ def commit_in_last_year(commits_url: str, headers: dict) -> str:
"""
r = requests.get(commits_url, headers=headers).json()
last_commit_date = r.get("commit").get("author").get("date")
last_commit_date = datetime.strptime(last_commit_date, "%Y-%m-%dT%H:%M:%SZ")
days_since_last_commit = (datetime.utcnow() - last_commit_date).days
last_commit_date = datetime.strptime(last_commit_date, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=timezone.utc)
days_since_last_commit = (datetime.now(timezone.utc) - last_commit_date).days
if days_since_last_commit > 365:
message = f"[red]No. The last commit was {days_since_last_commit} days ago"
else:
Expand All @@ -216,8 +221,8 @@ def release_in_last_year(pypi_api_url: str) -> str:
releases = _get_release_date(r)
last_release_date = releases[0].upload_time
version = releases[0].version
last_release_date = datetime.strptime(last_release_date, "%Y-%m-%dT%H:%M:%S")
days_since_last_release = (datetime.utcnow() - last_release_date).days
last_release_date = datetime.strptime(last_release_date, "%Y-%m-%dT%H:%M:%S").replace(tzinfo=timezone.utc)
days_since_last_release = (datetime.now(timezone.utc) - last_release_date).days
if days_since_last_release > 365:
message = f"[red]No. Version {version} was last released {days_since_last_release} days ago"
else:
Expand Down
Loading