Skip to content

Commit

Permalink
Modernize (#14)
Browse files Browse the repository at this point in the history
## Summary

Moderrnize the repo to latest tools, upgrade Python, and incorporate
suggested fix to `EdgeNode.disconnect()`.

### Why?

Movin' on up!

### How?

- Add support for Python 3.13.
- Remove support for Python 3.8.
- Stop testing for pypy.
- Remove docker.
- Modernize to uv.
- Simplify release process and docs.
- Incorporate fix from [this
PR](#12) resolving an issue
with `EdgeNode.disconnect()`.

If you have any questions not answered by a quick readthrough of the
[contributor
guide](https://pysparkplug.mattefay.com/en/latest/contributor_guide.html),
add them to this PR and submit it.
  • Loading branch information
matteosox authored Oct 24, 2024
1 parent e889f0c commit 3c7316c
Show file tree
Hide file tree
Showing 59 changed files with 2,147 additions and 1,873 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ src/**/*.egg-info/
!pyproject.toml
!README.md
!LICENSE
!requirements/requirements.txt
110 changes: 44 additions & 66 deletions .github/CONTRIBUTING.md

Large diffs are not rendered by default.

16 changes: 3 additions & 13 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,8 @@ What is my [purpose](https://youtu.be/X7HmltUWXgs?t=52)?

But how?!

## Checklist

Most checks are automated, but a few aren't, so make sure to go through and tick them off, even if they don't apply. This checklist is here to help, not deter you. Remember, "Slow is smooth, and smooth is fast".

- [ ] **Unit tests**
- Every input should have a test for it.
- Every potential raised exception should have a test ensuring it is raised.
- [ ] **Documentation**
- New functions/classes/etc. must be added to `docs/api.rst`.
- Changed/added classes/methods/functions have appropriate `versionadded`, `versionchanged`, or `deprecated` [directives](http://www.sphinx-doc.org/en/stable/markup/para.html#directive-versionadded).
- The appropriate entry in `CHANGELOG.md` has been included in the "Unreleased" section, i.e. "Added", "Changed", "Deprecated", "Removed", "Fixed", or "Security".
- [ ] **Future work**
- Future work should be documented in the contributor guide, i.e. `.github/CONTRIBUTING.md`.
## Mantra

_Remember, "Slow is smooth, and smooth is fast"._

If you have any questions not answered by a quick readthrough of the [contributor guide](https://pysparkplug.mattefay.com/en/latest/contributor_guide.html), add them to this PR and submit it.
70 changes: 42 additions & 28 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,76 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

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

- name: Install just
uses: extractions/setup-just@v2

- name: Test
run: ./nox.sh
run: just test

- name: Create draft Github release
- name: Publish Draft Release
if: ${{ github.ref == 'refs/heads/main' }}
run: ./nox.sh -s draft_release
run: just draft
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish package to testpypi
- name: Publish to TestPyPI
if: ${{ github.ref == 'refs/heads/main' }}
run: ./nox.sh -s publish -- testpypi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TESTPYPI_TOKEN }}
run: just repository=testpypi publish

os_compatibility:
runs-on: ${{ matrix.os }}
name: "OS: ${{ matrix.os }} Python: ${{ matrix.python-version }}"
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
permissions:
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install --upgrade pip wheel setuptools
pip install coverage[toml] nox==2023.04.22
- name: Run unit tests
run: nox --session unit_tests-${{ matrix.python-version }}

- name: Generate coverage report
- name: Run unit tests with coverage
run: |
coverage xml --fail-under 0
uv run --python ${{ matrix.python-version }} coverage run -m pytest test/unit_tests
uv run --python ${{ matrix.python-version }} coverage combine
uv run --python ${{ matrix.python-version }} coverage xml --fail-under 0
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
env_vars: OS,PYTHON
fail_ci_if_error: true
verbose: true
use_oidc: true
23 changes: 0 additions & 23 deletions .github/workflows/publish.yaml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
release:
types:
- published
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true

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

- name: Install just
uses: extractions/setup-just@v2

- name: Publish package to pypi
run: just publish
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ src/pysparkplug/_version.py
/.vscode/
/*.code-workspace

# Cache from Docker container
/.cache

# Docs
/docs/build
/docs/api/

# Coverage
.coverage*
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
23 changes: 8 additions & 15 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@

version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
os: ubuntu-lts-latest
tools:
python: "3.11"

# Declare the Python requirements required to build your docs
python:
install:
- method: pip
path: .
- requirements: requirements/docs.txt

# Build documentation in the docs/source directory with Sphinx
sphinx:
fail_on_warning: true
configuration: docs/conf.py
python: "3.12"
commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv sync --locked
- uv run sphinx-build -T -W -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes for `pysparkplug` will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Changelog](http://keepachangelog.com/).

## 0.4.0 (2024-10-24)

### Added
- Pysparkplug now supports Python 3.13

### Fixed
- `EdgeNode.disconnect` now correctly sends an NDEATH payload.

### Deprecated
- Pysparkplug no longer supports Python 3.8, which has reached its end of life.

## 0.3.2 (2024-05-06)

### Fixed
Expand Down
56 changes: 0 additions & 56 deletions Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
services:
cicd:
build: .
volumes:
- ./:/root/pysparkplug
command: ["exit", "0"]
environment:
- GH_TOKEN
- TWINE_USERNAME
- TWINE_PASSWORD
emqx:
image: emqx/emqx:5.0.9
ports:
Expand Down
Loading

0 comments on commit 3c7316c

Please sign in to comment.