Skip to content

Commit

Permalink
Merge pull request #5 from ACCESS-NRI/infra
Browse files Browse the repository at this point in the history
CI infrastructure:
  - Automated tests
  - CI Environments
  - Mypy, Black, Ruff
  - Covecov
  • Loading branch information
charles-turner-1 authored Jan 9, 2025
2 parents 6625b67 + 3686a4c commit a2d6a5e
Show file tree
Hide file tree
Showing 17 changed files with 3,364 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/access_py_telemetry/_version.py export-subst
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on: [pull_request, push, workflow_dispatch]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]

test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- name: Checkout source
uses: actions/[email protected]

- name: Setup conda environment
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
environment-file: ci/environment-${{ matrix.python-version }}.yml
activate-environment: access-py-telemetry-test
auto-activate-base: false

- name: Install source
shell: bash -l {0}
run: python -m pip install .

- name: List installed packages
shell: bash -l {0}
run: conda list

- name: Run tests
shell: bash -l {0}
run: coverage run -m --source=access_py_telemetry pytest tests

- name: Generate coverage report
shell: bash -l {0}
run: coverage xml

- name: Upload code coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.codecov_token }}
files: ./coverage.xml
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.8.1'
hooks:
- id: ruff
args: ['--fix']

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
language_version: python3
# Mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.13.0'
hooks:
- id: mypy
name: mypy
additional_dependencies: [types-PyYAML==6.0.12.20240808, types-requests==2.32.0.20241016
,annotated-types==0.7.0,pydantic,pydantic_core,httpx,ipython]
files: ^src/
args: [--strict]
22 changes: 22 additions & 0 deletions ci/environment-3.10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: access-py-telemetry-test
channels:
- conda-forge
- accessnri
- defaults
dependencies:
- python==3.10
- jsonschema
- pooch
- pre-commit
- ipython>=7.0.0
- pydantic>=2.0.0
- pyyaml>=6.0.0
- httpx>=0.28.0
- pytest
- pip
- coverage
- mypy
- ruff
- pip:
- codecov
- pytest-asyncio==0.25.0
22 changes: 22 additions & 0 deletions ci/environment-3.11.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: access-py-telemetry-test
channels:
- conda-forge
- accessnri
- defaults
dependencies:
- python==3.11
- jsonschema
- pooch
- pre-commit
- ipython>=7.0.0
- pydantic>=2.0.0
- pyyaml>=6.0.0
- httpx>=0.28.0
- pytest
- pip
- coverage
- mypy
- ruff
- pip:
- codecov
- pytest-asyncio==0.25.0
22 changes: 22 additions & 0 deletions ci/environment-3.12.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: access-py-telemetry-test
channels:
- conda-forge
- accessnri
- defaults
dependencies:
- python==3.12
- jsonschema
- pooch
- pre-commit
- ipython>=7.0.0
- pydantic>=2.0.0
- pyyaml>=6.0.0
- httpx>=0.28.0
- pytest
- pip
- coverage
- mypy
- ruff
- pip:
- codecov
- pytest-asyncio==0.25.0
22 changes: 22 additions & 0 deletions ci/environment-3.13.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: access-py-telemetry-test
channels:
- conda-forge
- accessnri
- defaults
dependencies:
- python==3.13
- jsonschema
- pooch
- pre-commit
- ipython>=7.0.0
- pydantic>=2.0.0
- pyyaml>=6.0.0
- httpx>=0.28.0
- pytest
- pip
- coverage
- mypy
- ruff
- pip:
- codecov
- pytest-asyncio==0.25.0
9 changes: 0 additions & 9 deletions mypy.ini

This file was deleted.

84 changes: 77 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
requires = [
"setuptools >= 61.0.0",
"versioneer[toml]==0.29",
]

[project]
name = "access_py_telemetry"
version = "0.1.0"
description = "Contains ipython extensions to automatically add telemetry to registered function calls from Ipython kernels"
readme = "README.md"
requires-python = ">=3.10"
authors = [
{ name = "ACCESS-NRI" },
]
maintainers = [
{ name = "ACCESS-NRI" },
]
classifiers = [

"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
license = {text = "Apache Software License 2.0"}
dependencies = [
Expand All @@ -24,12 +30,14 @@ dependencies = [
"httpx>=0.28.0",
]

dynamic = ["version"]

[project.optional-dependencies]
dev = [
"coverage", # testing
"mypy", # linting
"pytest", # testing
"ruff" # linting
"ruff", # linting
]

[project.scripts]
Expand All @@ -48,16 +56,78 @@ package-dir = {"" = "src"}
"*" = ["*.*"]




# Mypy
# ----

[tool.mypy]
files = "."
files = "src"
exclude = [
"src/access_py_telemetry/_version.py",
]

# Use strict defaults
strict = true
warn_unreachable = true
warn_unused_ignores = true
warn_no_return = true

[tool.versioneer]
VCS = "git"
style = "pep440"
versionfile_source = "src/access_py_telemetry/_version.py"
versionfile_build = "access_py_telemetry/_version.py"
tag_prefix = "v"
parentdir_prefix = "access-py-telemetry"

[tool.coverage.run]
omit = [
"*/_version.py",
"*/data/__init__.py",
]

[tool.ruff]
target-version = "py310"
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]
# E402: module level import not at top of file
# E501: line too long - let black worry about that
ignore = [
"E402",
"E501",
]
select = [
# Pyflakes
"F",
# Pycodestyle
"E",
"W",
# isort
"I",
# Pyupgrade
"UP",
]

[tool.ruff.mccabe]
max-complexity = 18

[tool.ruff.isort]
known-first-party = ["access_py_telemetry"]
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from setuptools import setup

import versioneer

setup(
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
)
4 changes: 4 additions & 0 deletions src/access_py_telemetry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from IPython.core.getipython import get_ipython
from IPython.core.interactiveshell import InteractiveShell

from . import _version
from .ast import capture_registered_calls
from .api import SessionID, ENDPOINTS # noqa
from .registry import REGISTRIES, RegisterWarning
Expand All @@ -34,3 +35,6 @@ def load_ipython_extension(ipython: InteractiveShell) -> None:
ip = get_ipython() # type: ignore
if ip:
load_ipython_extension(ip)


__version__ = _version.get_versions()["version"] # type: ignore
Loading

0 comments on commit a2d6a5e

Please sign in to comment.