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

Integrating "ambient-package-update" #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
44 changes: 44 additions & 0 deletions .ambient-package-update/metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from ambient_package_update.metadata.author import PackageAuthor
from ambient_package_update.metadata.constants import (
DEV_DEPENDENCIES,
LICENSE_MIT,
SUPPORTED_DJANGO_VERSIONS,
SUPPORTED_PYTHON_VERSIONS,
)
from ambient_package_update.metadata.maintainer import PackageMaintainer
from ambient_package_update.metadata.package import PackageMetadata
from ambient_package_update.metadata.readme import ReadmeContent
Comment on lines +1 to +10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels overly verbose and would probably benefit from being something that could be imported as a module.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean one single import like

from ambient_package_update.metadata import ReadmeContent, PackageMetadata, PackageMaintainer

this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking more like how django suggests you handle models, from django.db import models

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable. Stick to known pattern. 👌


METADATA = PackageMetadata(
package_name="django-commons-playground",
github_package_group="django-commons",
authors=[
PackageAuthor(
name="Tim Schilling",
email="[email protected]",
),
],
maintainer=PackageMaintainer(
name="Tim Schilling",
email="[email protected]",
url="https://www.better-simple.com",
),
company="better-simple.com",
license=LICENSE_MIT,
license_year=2024,
development_status="5 - Production/Stable",
has_migrations=False,
readme_content=ReadmeContent(uses_internationalisation=False),
main_branch="main",
dependencies=[
f"Django>={SUPPORTED_DJANGO_VERSIONS[0]}",
],
Comment on lines +33 to +35
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this shouldn't have to be specified if we're also setting supported_django_versions=SUPPORTED_DJANGO_VERSIONS,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do understand your point though this is for the pyproject toml file and it defines the "real" dependency when you install the package. This defaults to the lowest version. I added it there so it's explicit and not implicit. Hope my reasoning is understandable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. I don't think it's clear why you're using the first element of that list. For the reader, they don't know the ordering of that list.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. I'll put this on my list of things I'll work on if we manage to make the "cooperation" work.

supported_django_versions=SUPPORTED_DJANGO_VERSIONS,
supported_python_versions=SUPPORTED_PYTHON_VERSIONS,
optional_dependencies={
"dev": [
*DEV_DEPENDENCIES,
],
},
ruff_ignore_list=[],
)
1 change: 1 addition & 0 deletions .ambient-package-update/templates/snippets/tagline.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is an example repository for Django Commons.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{py,rst,ini}]
indent_style = space
indent_size = 4
ij_continuation_indent_size = 8

[*.yml]
indent_style = space
indent_size = 2
88 changes: 88 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Unit tests

on:
push:
branches:
- main
pull_request:

jobs:
linting:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install required packages
run: pip install pre-commit

- name: Run pre-commit hooks
run: pre-commit run --all-files --hook-stage push


tests:
name: Python ${{ matrix.python-version }}, django ${{ matrix.django-version }}
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', ]
django-version: ['42', '50', '51', ]

exclude:
- python-version: '3.9'
django-version: 50
- python-version: '3.9'
django-version: 51

steps:
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: pip install tox
- name: Run Tests
env:
TOXENV: django${{ matrix.django-version }}
run: tox
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.python-version }}-${{ matrix.django-version }}
path: '${{ github.workspace }}/.coverage.*'
include-hidden-files: true
if-no-files-found: error

coverage:
name: Coverage
runs-on: ubuntu-24.04
needs: tests
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: python -m pip install --upgrade coverage[toml]

- name: Download data
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}
pattern: coverage-data-*
merge-multiple: true

- name: Combine coverage and fail if it's <100.0%
run: |
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report --fail-under=100.0
echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY
python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/
56 changes: 56 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# you find the full pre-commit-tools docu under:
# https://pre-commit.com/

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
# Run the Ruff linter.
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
# Run the Ruff formatter.
- id: ruff-format

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.19.0
hooks:
- id: blacken-docs
additional_dependencies:
- black==24.4.2
files: '(?:README\.md|docs\/.*\.(?:md|rst))'

- repo: https://github.com/asottile/pyupgrade
rev: v3.18.0
hooks:
- id: pyupgrade
args: [ --py39-plus ]
stages: [ pre-push ]

- repo: https://github.com/adamchainz/django-upgrade
rev: 1.22.1
hooks:
- id: django-upgrade
args: [--target-version, "4.2"]
stages: [ pre-push ]

- repo: https://github.com/adamchainz/djade-pre-commit
rev: 1.3.0
hooks:
- id: djade
args: [--target-version, "4.2"]
exclude: |
(?x)^(
charts/.*
|.*\.py
)$

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: no-commit-to-branch
args:
[
"--pattern",
'^^(?!(?:feature|hotfix|bugfix|refactor|maintenance)/[\w\d\-_#]+).*$',
]
stages: [ pre-commit ]
31 changes: 31 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-24.04
tools:
python: "3.12"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- method: pip
path: .
extra_requirements:
- dev
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we ignore files entirely? For example, I don't think Django Commons would be specifying the license for every project.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. The updater can already handle two kinds of licences. Why not disable it completely if required. I could integrate this easily.


Copyright (c) 2024 better-simple.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include README.md
include LICENSE.md
recursive-exclude * *.pyc
recursive-include django-commons-playground *.py *.html *.js *.cfg *.mo *.po
Loading