Skip to content

Commit

Permalink
Merge pull request #244 from thegridelectric/dev
Browse files Browse the repository at this point in the history
1.0.0: New ShNode, DataChannel, Report
  • Loading branch information
jessicamillar authored Oct 7, 2024
2 parents 4969671 + f18257b commit 20ab1ed
Show file tree
Hide file tree
Showing 65 changed files with 3,003 additions and 3,261 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pip==24.0
nox==2024.4.15
nox-poetry==1.0.3
poetry==1.8.2
poetry==1.8.3
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fetch-depth: 2

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

Expand Down Expand Up @@ -57,14 +57,14 @@ jobs:
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/gh-action-pypi-publish@v1.8.14
uses: pypa/gh-action-pypi-publish@v1.10.2
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/gh-action-pypi-publish@v1.8.14
uses: pypa/gh-action-pypi-publish@v1.10.2
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
Expand Down
53 changes: 36 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ jobs:
fail-fast: false
matrix:
include:
- { python: "3.11", os: "ubuntu-latest", session: "pre-commit" }
- { python: "3.12", os: "ubuntu-latest", session: "pre-commit" }
- { python: "3.11", os: "ubuntu-latest", session: "tests" }
- { python: "3.12", os: "ubuntu-latest", session: "tests", coverage: true }
# mosuqitto github action only supported on ubuntu
# - { python: "3.11", os: "macos-latest", session: "tests" }
# - { python: "3.11", os: "windows-latest", session: "tests" }
- { python: "3.10", os: "ubuntu-latest", session: "tests" }
- { python: "3.11", os: "ubuntu-latest", session: "xdoctest" }
- { python: "3.11", os: "ubuntu-latest", session: "docs-build" }
# - { python: "3.12", os: "macos-latest", session: "tests" }
# - { python: "3.12", os: "windows-latest", session: "tests" }
- { python: "3.12", os: "ubuntu-latest", session: "xdoctest" }
- { python: "3.12", os: "ubuntu-latest", session: "docs-build" }

# - { python: "3.11", os: "ubuntu-latest", session: "mypy" }
# - { python: "3.12", os: "ubuntu-latest", session: "mypy" }

env:
NOXSESSION: ${{ matrix.session }}
Expand All @@ -45,7 +45,7 @@ jobs:
uses: actions/checkout@v4

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

Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
container-name: "local-mqtt"

- name: Wait for Mosquitto
uses: iFaxity/wait-on-action@v1.1.0
uses: iFaxity/wait-on-action@v1.2.1
with:
resource: tcp:localhost:1883
timeout: 5000
Expand Down Expand Up @@ -151,7 +151,24 @@ jobs:
restore-keys: |
${{ steps.pre-commit-cache.outputs.result }}-
- name: Run Nox
- name: Run Tests with coverage
if: matrix.session == 'tests' && matrix.coverage == true
env:
GWPROACTOR_TEST_CA_CERT_PATH: ${{ github.workspace }}/tests/.ci-ca/ca.crt
GWPROACTOR_TEST_CA_KEY_PATH: ${{ github.workspace }}/tests/.ci-ca/private/ca_key.pem
run: |
nox --python=${{ matrix.python }}
- name: Run Tests without coverage
if: matrix.session == 'tests' && matrix.coverage != true
env:
GWPROACTOR_TEST_CA_CERT_PATH: ${{ github.workspace }}/tests/.ci-ca/ca.crt
GWPROACTOR_TEST_CA_KEY_PATH: ${{ github.workspace }}/tests/.ci-ca/private/ca_key.pem
run: |
nox --python=${{ matrix.python }} -- --no-coverage
- name: Run non-test session
if: matrix.session != 'tests'
env:
GWPROACTOR_TEST_CA_CERT_PATH: ${{ github.workspace }}/tests/.ci-ca/ca.crt
GWPROACTOR_TEST_CA_KEY_PATH: ${{ github.workspace }}/tests/.ci-ca/private/ca_key.pem
Expand All @@ -164,15 +181,17 @@ jobs:
docker logs local-mqtt
- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/upload-artifact@v3"
if: always() && matrix.session == 'tests' && matrix.coverage == true
uses: "actions/upload-artifact@v4.4.0"
with:
name: coverage-data
path: ".coverage.*"
if-no-files-found: error
include-hidden-files: true

- name: Upload documentation
if: matrix.session == 'docs-build'
uses: actions/upload-artifact@v3
uses: "actions/upload-artifact@v4.4.0"
with:
name: docs
path: docs/_build
Expand All @@ -185,9 +204,9 @@ jobs:
uses: actions/checkout@v4

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

- name: Upgrade pip
run: |
Expand All @@ -206,7 +225,7 @@ jobs:
nox --version
- name: Download coverage data
uses: actions/download-artifact@v3
uses: "actions/download-artifact@v4.1.8"
with:
name: coverage-data

Expand All @@ -219,4 +238,4 @@ jobs:
nox --session=coverage -- xml
- name: Upload coverage report
uses: codecov/codecov-action@v4.3.1
uses: codecov/codecov-action@v4.5.0
53 changes: 5 additions & 48 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
repos:
- repo: local
hooks:
# - id: bandit
# name: bandit
# entry: bandit
# language: system
# types: [python]
# require_serial: true
# args: ["-c", "bandit.yml"]
- id: black
name: black
entry: black
language: system
types: [python]
require_serial: true
- id: check-added-large-files
name: Check for added large files
entry: check-added-large-files
Expand All @@ -28,46 +15,16 @@ repos:
entry: check-yaml
language: system
types: [yaml]
- id: darglint
name: darglint
entry: darglint
language: system
types: [python]
stages: [manual]
- id: end-of-file-fixer
name: Fix End of Files
entry: end-of-file-fixer
language: system
types: [text]
stages: [commit, push, manual]
# - id: flake8
# name: flake8
# entry: flake8
# language: system
# types: [python]
# require_serial: true
# args: [--darglint-ignore-regex, .*]
- id: isort
name: isort
entry: isort
require_serial: true
language: system
types_or: [cython, pyi, python]
args: ["--filter-files"]
- id: pyupgrade
name: pyupgrade
description: Automatically upgrade syntax for newer versions.
entry: pyupgrade
language: system
types: [python]
args: [--py37-plus]
- id: trailing-whitespace
name: Trim Trailing Whitespace
entry: trailing-whitespace-fixer
language: system
types: [text]
stages: [commit, push, manual]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.2
hooks:
- id: prettier
- id: ruff
- id: ruff-format
10 changes: 5 additions & 5 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
furo==2024.1.29
furo==2024.8.6
sphinx==7.3.7
sphinx-click==5.1.0
myst_parser==3.0.1
sphinx-click==6.0.0
myst_parser==4.0.0
sphinxcontrib-mermaid==0.9.2
pytest==8.2.0
pytest-asyncio==0.23.6
pytest==8.3.3
pytest-asyncio==0.24.0
59 changes: 20 additions & 39 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nox sessions."""
# ruff: noqa: S101

import os
import shlex
Expand All @@ -9,10 +10,8 @@

import nox


try:
from nox_poetry import Session
from nox_poetry import session
from nox_poetry import Session, session
except ImportError:
message = f"""\
Nox failed to import the 'nox-poetry' package.
Expand All @@ -24,14 +23,12 @@


package = "gwproactor"
python_versions = ["3.11", "3.10"]
python_versions = ["3.12", "3.11"]
nox.needs_version = ">= 2021.6.6"
nox.options.sessions = (
"pre-commit",
# "safety",
"mypy",
"tests",
"typeguard",
"xdoctest",
"docs-build",
)
Expand Down Expand Up @@ -97,7 +94,8 @@ def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
text = hook.read_text()

if not any(
Path("A") == Path("a") and bindir.lower() in text.lower() or bindir in text
(Path("A") == Path("a") and bindir.lower() in text.lower())
or bindir in text
for bindir in bindirs
):
continue
Expand All @@ -121,14 +119,7 @@ def precommit(session: Session) -> None:
"--show-diff-on-failure",
]
session.install(
# "bandit",
"black",
"darglint",
# "flake8",
# "flake8-bugbear",
# "flake8-docstrings",
# "flake8-rst-docstrings",
"isort",
"ruff",
"pep8-naming",
"pre-commit",
"pre-commit-hooks",
Expand All @@ -139,16 +130,6 @@ def precommit(session: Session) -> None:
activate_virtualenv_in_precommit_hooks(session)


# Safety produces a warnign in red that we are using the free version with old and limited data,
# so disabling.
# @session(python=python_versions[0])
# def safety(session: Session) -> None:
# """Scan dependencies for insecure packages."""
# requirements = session.poetry.export_requirements()
# session.install("safety")
# session.run("safety", "check", "--full-report", f"--file={requirements}")


@session(python=python_versions)
def mypy(session: Session) -> None:
"""Type-check using mypy."""
Expand All @@ -164,12 +145,20 @@ def mypy(session: Session) -> None:
def tests(session: Session) -> None:
"""Run the test suite."""
session.install(".[tests]")
session.install("coverage[toml]", "pytest", "pygments")
try:
session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs)
finally:
if session.interactive:
session.notify("coverage", posargs=[])
session.install("pytest", "pygments")
if not session.posargs or (
session.posargs and session.posargs[0] != "--no-coverage"
):
session.install("coverage[toml]")
try:
session.run(
"coverage", "run", "--parallel", "-m", "pytest", *session.posargs
)
finally:
if session.interactive:
session.notify("coverage", posargs=[])
else:
session.run("pytest", *session.posargs[1:])


@session(python=python_versions[0])
Expand All @@ -185,14 +174,6 @@ def coverage(session: Session) -> None:
session.run("coverage", *args)


@session(python=python_versions[0])
def typeguard(session: Session) -> None:
"""Runtime type checking using Typeguard."""
session.install(".")
session.install("pytest", "typeguard", "pygments")
session.run("pytest", f"--typeguard-packages={package}", *session.posargs)


@session(python=python_versions)
def xdoctest(session: Session) -> None:
"""Run examples with xdoctest."""
Expand Down
Loading

0 comments on commit 20ab1ed

Please sign in to comment.