Skip to content

Commit

Permalink
update project scaffolding (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadavidthomas authored Jan 30, 2024
1 parent dc0d092 commit 5feda59
Show file tree
Hide file tree
Showing 18 changed files with 825 additions and 75 deletions.
14 changes: 6 additions & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
# http://editorconfig.org

root = true

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

[*.{py,rst,ini}]
[{,.}{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]
indent_size = 4
indent_style = space
trim_trailing_whitespace = false


[{Makefile,*.bat}]
indent_style = tab
Empty file added .env.example
Empty file.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
timezone: America/Chicago
labels:
- "dependabot"
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: release

on:
release:
types: [created]
workflow_dispatch:
inputs:
pypi:
description: "Publish to PyPI"
required: false
default: true
type: boolean

jobs:
check:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- name: Check most recent test run on `main`
id: latest-test-result
run: |
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' || inputs.pypi }}
runs-on: ubuntu-latest
needs: check
environment: release
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install hatch
- name: Build package
run: |
hatch build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
90 changes: 90 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: test

on:
push:
branches: main
pull_request:

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
test:
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
django-version: ["3.2", "4.2", "5.0", "main"]
env:
NOX_SESSION: "tests(python='${{ matrix.python-version }}', django='${{ matrix.django-version }}')"
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
allow-prereleases: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip nox
- name: Check if test session exists
run: |
if nox -l | grep "${{ env.NOX_SESSION }}"; then
echo "Session exists, proceeding with tests"
echo "RUN_TESTS=true" >> $GITHUB_ENV
else
echo "Session does not exist, skipping tests"
echo "RUN_TESTS=false" >> $GITHUB_ENV
fi
- name: Run tests
if: env.RUN_TESTS == 'true'
run: |
python -m nox --session "${{ env.NOX_SESSION }}"
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

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

- uses: wntrblm/nox@main
with:
python-versions: "3.8"

- name: Run mypy
run: nox --session mypy

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

- uses: wntrblm/nox@main
with:
python-versions: "3.8"

- name: Run coverage
run: nox --session coverage
51 changes: 41 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,60 @@ repos:
language_version: python3.8
args: [--target-version, "3.2"]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.262
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: ruff
alias: autoformat
args: ["--fix"]
args: [--fix]
- id: ruff-format

- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: black
language_version: python3.8
args: [--target-version, "py38"]
- id: blacken-docs
alias: autoformat
additional_dependencies:
- black==22.12.0

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
hooks:
- id: prettier
# lint the following with prettier:
# - javascript
# - svelte
# - typescript
# - JSX/TSX
# - CSS
# - yaml
# ignore any minified code
files: '^(?!.*\.min\..*)(?P<name>[\w-]+(\.[\w-]+)*\.(js|jsx|ts|tsx|yml|yaml|css))$'
files: '^(?!.*\.min\..*)(?P<name>[\w-]+(\.[\w-]+)*\.(js|jsx|svelte|ts|tsx|yml|yaml|css))$'

- repo: https://github.com/rtts/djhtml
rev: "3.0.6"
hooks:
- id: djhtml
entry: djhtml --tabwidth 2
alias: autoformat

- repo: local
hooks:
- id: rustywind
name: rustywind Tailwind CSS class linter
language: node
additional_dependencies:
- [email protected]
entry: rustywind
args: [--write]
types_or: [html, jsx, tsx]

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.11.0
hooks:
- id: pretty-format-toml
args: [--autofix]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
hooks:
- id: validate-pyproject
24 changes: 24 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"

sphinx:
configuration: docs/conf.py

formats:
- pdf
- epub

python:
install:
- method: pip
path: .
extra_requirements:
- docs
3 changes: 3 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Authors

Josh Thomas <[email protected]>
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project attempts to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!--
## [${version}]
### Added - for new features
### Changed - for changes in existing functionality
### Deprecated - for soon-to-be removed features
### Removed - for now removed features
### Fixed - for any bug fixes
### Security - in case of vulnerabilities
[${version}]: https://github.com/westerveltco/django-q-registry/releases/tag/v${version}
-->
## [Unreleased]

## [0.1.0]

Initial release!

### Added

- Initial documentation.
- Initial tests.
- Initial CI/CD (GitHub Actions).

### New Contributors

- Josh Thomas <[email protected]> (maintainer)

[unreleased]: https://github.com/westerveltco/django-q-registry/compare/v0.1.0...HEAD
53 changes: 53 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Contributing

All contributions are welcome! Besides code contributions, this includes things like documentation improvements, bug reports, and feature requests.

You should first check if there is a [GitHub issue](https://github.com/westerveltco/django-q-registry/issues) already open or related to what you would like to contribute. If there is, please comment on that issue to let others know you are working on it. If there is not, please open a new issue to discuss your contribution.

Not all contributions need to start with an issue, such as typo fixes in documentation or version bumps to Python or Django that require no internal code changes, but generally, it is a good idea to open an issue first.

We adhere to Django's Code of Conduct in all interactions and expect all contributors to do the same. Please read the [Code of Conduct](https://www.djangoproject.com/conduct/) before contributing.

## Setup

The following setup steps assume you are using a Unix-like operating system, such as Linux or macOS, and that you have a [supported](#requirements) version of Python installed. If you are using Windows, you will need to adjust the commands accordingly. If you do not have Python installed, you can visit [python.org](https://www.python.org/) for instructions on how to install it for your operating system.

1. Fork the repository and clone it locally.
2. Create a virtual environment and activate it. You can use whatever tool you prefer for this. Below is an example using the Python standard library's `venv` module:

```shell
python -m venv venv
source venv/bin/activate
```

3. Install `django-q-registry` and the `dev` dependencies in editable mode:

```shell
python -m pip install -e '.[dev]'
```

## Testing

We use [`pytest`](https://docs.pytest.org/) for testing and [`nox`](https://nox.thea.codes/) to run the tests in multiple environments.

To run the test suite against the current environment, run:

```shell
python -m pytest
```

To run the test suite against all supported versions of Python and Django, run:

```shell
python -m nox
```

## `just`

[`just`](https://github.com/casey/just) is a command runner that is used to run common commands, similar to `make` or `invoke`. A `Justfile` is provided at the base of the repository, which contains commands for common development tasks, such as running the test suite or linting.

To see a list of all available commands, ensure `just` is installed and run the following command at the base of the repository:

```shell
just
```
Loading

0 comments on commit 5feda59

Please sign in to comment.