Skip to content

Commit

Permalink
Merge pull request #39 from micktwomey/update-build-env
Browse files Browse the repository at this point in the history
Update development environment
  • Loading branch information
micktwomey authored Oct 1, 2024
2 parents c147acc + c9b45e0 commit 00c9262
Show file tree
Hide file tree
Showing 11 changed files with 315 additions and 555 deletions.
40 changes: 21 additions & 19 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,47 @@ jobs:
strategy:
max-parallel: 8
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev", "pypy3.10"]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
allow-prereleases: true
- name: Install nox
run: python -m pip install --upgrade nox
- name: nox test
# Little hack to detect major.minor version, matrix version not always compatible with nox expectation
run: nox --python $(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') --session test
- uses: snok/install-poetry@v1
- run: poetry install
- uses: extractions/setup-just@v2
- name: just test
run: just test

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install nox
run: python -m pip install --upgrade nox
- name: nox lint
run: nox --session lint
python-version: "3.12"
- uses: snok/install-poetry@v1
- run: poetry install
- uses: extractions/setup-just@v2
- name: just lint
run: just lint

docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install nox
run: python -m pip install --upgrade nox
- name: nox docs
run: nox --session docs
python-version: "3.12"
- uses: snok/install-poetry@v1
- run: poetry install
- uses: extractions/setup-just@v2
- name: just docs
run: just docs
10 changes: 3 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@
# To update: run `pre-commit autoupdate`
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.272
rev: v0.6.8
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.11.2
hooks:
- id: mypy
1 change: 0 additions & 1 deletion .tool-versions

This file was deleted.

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Switch completely to [just](https://just.systems/) for development tasts, remove nox. Rely on Github actions matrix of python versions for testing across all supported python versions.
- Remove black, rely on ruff for formatting.

## [2.1.0] - 2023-10-03
### Fixed
Expand Down
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ include .editorconfig
include .envrc
include .gitignore
include .pre-commit-config.yaml
include .tool-versions
include LICENSE
include noxfile.py
include poetry.lock
include pyproject.toml
include README.rst
include setup.py
include justfile
66 changes: 13 additions & 53 deletions devenv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1686239587,
"narHash": "sha256-MpF2msSM7INvzOfT+Zs8KY4tN3IhDOhnQ7Ao5aNvEiI=",
"lastModified": 1727717746,
"owner": "cachix",
"repo": "devenv",
"rev": "9d51052c5983724a9225fa62587e0cbe51e50622",
"rev": "68ae63d9fcc5dfdd3e04b906bf37c86b0b9ed54d",
"type": "github"
},
"original": {
Expand All @@ -20,11 +19,10 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"lastModified": 1696426674,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
Expand All @@ -33,24 +31,6 @@
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
Expand All @@ -59,11 +39,10 @@
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
Expand All @@ -74,11 +53,10 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1686089707,
"narHash": "sha256-LTNlJcru2qJ0XhlhG9Acp5KyjB774Pza3tRH0pKIb3o=",
"lastModified": 1727716680,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "af21c31b2a1ec5d361ed8050edd0303c31306397",
"rev": "b5b22b42c0d10c7d2463e90a546c394711e3a724",
"type": "github"
},
"original": {
Expand All @@ -90,36 +68,33 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"lastModified": 1727540905,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"rev": "fbca5e745367ae7632731639de5c21f29c8744ed",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1686213770,
"narHash": "sha256-Re6xXLEqQ/HRnThryumyGzEf3Uv0Pl4cuG50MrDofP8=",
"lastModified": 1727514110,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "182af51202998af5b64ddecaa7ff9be06425399b",
"rev": "85f7a7177c678de68224af3402ab8ee1bcee25c8",
"type": "github"
},
"original": {
Expand All @@ -134,21 +109,6 @@
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
Expand Down
26 changes: 10 additions & 16 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
{ pkgs, ... }:

{
let
python-pkg = pkgs.python312;
in {
packages = [
pkgs.gh
pkgs.git
pkgs.just
pkgs.python38
pkgs.python39
pkgs.python310
pkgs.python311
pkgs.python312
python-pkg
];

enterShell = ''
git --version
# type -a python
python --version
poetry install
'';

languages.python = {
enable = true;
package = pkgs.python311;
poetry.enable = true;
poetry.package = pkgs.poetry;
package = python-pkg;
venv.enable = true;
poetry.enable = true;
poetry.activate.enable = true;
poetry.install.enable = true;
poetry.install.installRootPackage = true;
};

# Note: I'm not using devenv's pre-commit support as isn't portable
Expand Down
24 changes: 10 additions & 14 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
project := "iso8601"

# Run linting and test tasks
default: pre-commit lint test
default: pre-commit lint test docs

# Run pre-commit
pre-commit COMMAND="run" *ARGS="--all-files":
poetry run pre-commit {{COMMAND}} {{ARGS}}

# Run all linting actions
lint: ruff mypy black
lint: ruff mypy

# Lint code with ruff
ruff COMMAND="check" *ARGS=".":
Expand All @@ -18,34 +18,30 @@ ruff COMMAND="check" *ARGS=".":
mypy *ARGS=".":
poetry run mypy {{ARGS}}

# Check files with black
black *ARGS=".":
poetry run black {{ARGS}}

# Run tests
test: pytest nox
test: pytest

# Run pytest tests
pytest *ARGS="-v":
poetry run pytest {{ARGS}}

# Run nox tests
nox *ARGS="-x":
poetry run nox {{ARGS}}
# Run sphinx build
docs:
poetry run sphinx-build docs docs/_build

# Add a CHANGELOG.md entry, e.g. just changelog-add added "My entry"
changelog-add TYPE ENTRY:
changelog-manager add {{TYPE}} "{{ENTRY}}"
poetry run changelog-manager add {{TYPE}} "{{ENTRY}}"

# Find out what your next released version might be based on the changelog.
next-version:
changelog-manager suggest
poetry run changelog-manager suggest

# Build and create files for a release
prepare-release:
#!/bin/bash
set -xeuo pipefail
changelog-manager release
poetry run changelog-manager release
poetry version $(changelog-manager current)
rm -rvf dist
poetry build
Expand All @@ -62,7 +58,7 @@ do-release:
fi
git add pyproject.toml CHANGELOG.md
mkdir -p build
changelog-manager display --version $VERSION > build/release-notes.md
poetry run changelog-manager display --version $VERSION > build/release-notes.md
if [ ! -f dist/{{project}}-${VERSION}.tar.gz ]; then
echo "Missing expected file in dist, did you run 'just prepare-release'?"
exit 1
Expand Down
Loading

0 comments on commit 00c9262

Please sign in to comment.