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

use django-twc-package as template #14

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
24 changes: 24 additions & 0 deletions .copier/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: v2024.17
_src_path: gh:westerveltco/django-twc-package
author_email: josh@joshthomas.dev
author_name: Josh Thomas
current_version: 0.1.1
django_versions:
- '3.2'
- '4.2'
- '5.0'
docs_domain: westervelt.dev
github_owner: westerveltco
github_repo: django-flyio
module_name: django_flyio
package_description: A set of simple utilities for Django apps running on Fly.io
package_name: django-flyio
python_versions:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
test_django_main: true
versioning_scheme: SemVer
11 changes: 6 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# http://editorconfig.org

root = true

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

[{{Justfile,.justfile},*.{py,rst,ini,md}}]
[{,.}{j,J}ustfile]
indent_size = 4

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

[*.py]
line_length = 120
multi_line_output = 3

[*.{css,html,js,json,sass,scss,yml,yaml}]
[*.{css,html,js,json,jsx,sass,scss,svelte,ts,tsx,yml,yaml}]
indent_size = 2
indent_style = space

[*.md]
trim_trailing_whitespace = false
Expand Down
Empty file added .env.example
Empty file.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
timezone: America/Chicago
labels:
- dependabot
groups:
gha:
patterns:
- "*"
68 changes: 48 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,58 @@ name: release

on:
release:
types: [created]
workflow_dispatch:
types: [released]

jobs:
publish:
check:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install hatch
- if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "PYPI_INDEX=test" >> $GITHUB_ENV
echo "PYPI_PASSWORD=${{ secrets.TEST_PYPI_PASSWORD }}" >> $GITHUB_ENV
- if: ${{ !env.PYPI_PASSWORD }}
- uses: actions/checkout@v4

- name: Check most recent test run on `main`
id: latest-test-result
run: |
echo "PYPI_INDEX=main" >> $GITHUB_ENV
echo "PYPI_PASSWORD=${{ secrets.PYPI_PASSWORD }}" >> $GITHUB_ENV
- name: Build and publish to PyPI
echo "result=$(gh run list \
--branch=main \
--workflow=test.yml \
--json headBranch,workflowName,conclusion \
--jq '.[] | select(.headBranch=="main" and .conclusion=="success") | .conclusion' \
| head -n 1)" >> $GITHUB_OUTPUT

- name: OK
if: ${{ (contains(steps.latest-test-result.outputs.result, 'success')) }}
run: exit 0

- name: Fail
if: ${{ !contains(steps.latest-test-result.outputs.result, 'success') }}
run: exit 1

pypi:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
needs: check
environment: release
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: westerveltco/setup-ci-action@v0
with:
python-version: 3.12
extra-python-dependencies: hatch

- name: Build package
run: |
hatch build
hatch publish -r ${{ env.PYPI_INDEX }} -u __token__ -a ${{ env.PYPI_PASSWORD }}

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
123 changes: 65 additions & 58 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: test

on:
push:
branches: main
pull_request_target:
branches: [main]
pull_request:

concurrency:
group: test-${{ github.head_ref }}
Expand All @@ -14,81 +14,88 @@ env:
FORCE_COLOR: "1"

jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: westerveltco/setup-ci-action@v0
with:
python-version: 3.8
extra-python-dependencies: nox

- id: set-matrix
run: |
echo "matrix=$(python -m nox -l --json | jq -c '[.[] | select(.name == "tests") | {"python-version": .python, "django-version": .call_spec.django}] | {include: .}')" >> $GITHUB_OUTPUT

test:
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}, psycopg ${{ matrix.psycopg-version }}
runs-on: 'ubuntu-latest'
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}
runs-on: ubuntu-latest
needs: generate-matrix
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12-dev']
django-version: ['3.2', '4.0', '4.1', '4.2', 'main']
psycopg-version: ['2', "3"]
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: westerveltco/setup-ci-action@v0
with:
python-version: ${{ matrix.python-version }}
extra-python-dependencies: nox
use-uv: true

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

- name: Run tests
run: |
nox --session "tests-${{ matrix.python-version }}(psycopg='${{ matrix.psycopg-version }}', django='${{ matrix.django-version }}')"
- name: Run tests
run: |
python -m nox --session "tests(python='${{ matrix.python-version }}', django='${{ matrix.django-version }}')"

tests:
runs-on: ubuntu-latest
needs: test
if: always()
steps:
- name: OK
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Fail
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- name: OK
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Fail
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1

types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install '.[types]'
- uses: westerveltco/setup-ci-action@v0
with:
python-version: 3.8
extra-python-dependencies: nox
use-uv: true

- name: Run mypy
run: |
mypy .
- name: Run mypy
run: |
python -m nox --session "mypy"

coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install '.[test]'

# https://hynek.me/articles/ditch-codecov-python/
- name: Run tests
run: |
coverage run -m pytest
python -m coverage html --skip-covered --skip-empty
python -m coverage report | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY
python -m coverage report --fail-under=100
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: westerveltco/setup-ci-action@v0
with:
python-version: 3.8
extra-python-dependencies: nox
use-uv: true

- name: Run coverage
run: |
python -m nox --session "coverage"
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,35 @@ cython_debug/
# 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/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
!.vscode/*.example
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

staticfiles/
mediafiles/

# pyright config for nvim-lspconfig
pyrightconfig.json
Loading
Loading