Skip to content

Commit

Permalink
CI: update ci/cd (#17)
Browse files Browse the repository at this point in the history
* misc updates to CI
* update cd

Signed-off-by: nstarman <[email protected]>
  • Loading branch information
nstarman authored Feb 9, 2024
1 parent 8fc6611 commit a562b5f
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 133 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
groups:
actions:
patterns:
- "*"
32 changes: 20 additions & 12 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,32 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2

- name: Build sdist and wheel
run: pipx run build
test-publish:
needs: [dist]
name: Publish to TestPyPI
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

- uses: actions/upload-artifact@v4
steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- name: Check products
run: pipx run twine check dist/*
- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release' && github.event.action == 'published'
with:
# Remember to tell (test-)pypi about this repo before publishing
# Remove this line to publish to PyPI
repository-url: https://test.pypi.org/legacy/

publish:
needs: [dist]
needs: [test-publish]
name: Publish to PyPI
environment: pypi
permissions:
Expand All @@ -49,12 +62,7 @@ jobs:
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
name: Packages
path: dist

- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release' && github.event.action == 'published'
with:
# Remember to tell (test-)pypi about this repo before publishing
# Remove this line to publish to PyPI
repository-url: https://test.pypi.org/legacy/
80 changes: 47 additions & 33 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@ ci:
autofix_commit_msg: "style: pre-commit fixes"
autoupdate_schedule: "monthly"

default_stages: [pre-commit, pre-push]

repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: "24.1.1"
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.14.1
hooks:
- id: black-jupyter
- id: commitizen
- id: commitizen-branch
stages: [push]

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
- repo: meta
hooks:
- id: blacken-docs
additional_dependencies: [black==23.*]
- id: check-useless-excludes

- repo: https://github.com/scientific-python/cookie
rev: 2024.01.24
hooks:
- id: sp-repo-review

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
Expand All @@ -39,38 +46,57 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8"
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.4
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.2.0"
hooks:
# Run the linter
- id: ruff
types_or: [python, pyi, jupyter]
args: ["--fix", "--show-fixes"]
# Run the formatter
- id: ruff-format
types_or: [python, pyi, jupyter]

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.*]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.8.0"
hooks:
- id: mypy
files: src
args: []
additional_dependencies:
- numpy
- pytest

# - repo: https://github.com/codespell-project/codespell
# rev: "v2.2.6"
# hooks:
# - id: codespell
- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
hooks:
- id: codespell
args: ["--toml pyproject.toml"]
additional_dependencies:
- tomli

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.9.0.6"
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.16
hooks:
- id: shellcheck
- id: validate-pyproject

- repo: local
hooks:
Expand All @@ -79,15 +105,3 @@ repos:
language: pygrep
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
exclude: .pre-commit-config.yaml

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.16
hooks:
- id: validate-pyproject

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.4
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs
146 changes: 62 additions & 84 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,38 @@ build-backend = "hatchling.build"
[project]
name = "array-api-jax-compat"
authors = [
{ name = "Nathaniel Starkman", email = "[email protected]" },
{ name = "Nathaniel Starkman", email = "[email protected]" },
]
description = "Array-API JAX compatibility"
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Development Status :: 1 - Planning",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Typing :: Typed",
"Development Status :: 1 - Planning",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Typing :: Typed",
]
dynamic = ["version"]
dependencies = [
"jax",
"jaxlib",
"numpy",
"plum-dispatch",
"quax>=0.0.3",
]
dependencies = ["jax", "jaxlib", "plum-dispatch", "quax>=0.0.3"]

[project.optional-dependencies]
test = [
"pytest >=6",
"pytest-cov >=3",
]
dev = [
"pytest >=6",
"pytest-cov >=3",
]
test = ["pytest >=6", "pytest-cov >=3"]
dev = ["pytest >=6", "pytest-cov >=3"]
docs = [
"sphinx>=7.0",
"myst_parser>=0.13",
"sphinx_copybutton",
"sphinx_autodoc_typehints",
"furo>=2023.08.17",
"sphinx>=7.0",
"myst_parser>=0.13",
"sphinx_copybutton",
"sphinx_autodoc_typehints",
"furo>=2023.08.17",
]

[project.urls]
Expand All @@ -73,23 +61,22 @@ minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = [
"error",
# jaxtyping
"ignore:ast\\.Str is deprecated and will be removed in Python 3.14:DeprecationWarning",
"error",
# jaxtyping
"ignore:ast\\.Str is deprecated and will be removed in Python 3.14:DeprecationWarning",
]
log_cli_level = "INFO"
testpaths = [
"tests",
]
testpaths = ["tests"]

[tool.codespell]
ignore-words-list = """
fro,
"""


[tool.coverage]
run.source = ["array_api_jax_compat"]
port.exclude_lines = [
'pragma: no cover',
'\.\.\.',
'if typing.TYPE_CHECKING:',
]
port.exclude_lines = ['pragma: no cover', '\.\.\.', 'if typing.TYPE_CHECKING:']

[tool.mypy]
files = ["src"]
Expand All @@ -101,24 +88,15 @@ warn_unreachable = true
disallow_untyped_defs = false
disallow_incomplete_defs = false
warn_return_any = false
plugins = [
"numpy.typing.mypy_plugin",
]

[[tool.mypy.overrides]]
module = "array_api_jax_compat.*"
disallow_untyped_defs = true
disallow_incomplete_defs = true

[[tool.mypy.overrides]]
module = [
"jax.*",
"jaxtyping.*",
"plum.*",
"quax.*",
]
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "array_api_jax_compat.*"
disallow_untyped_defs = true
disallow_incomplete_defs = true

[[tool.mypy.overrides]]
module = ["jax.*", "jaxtyping.*", "plum.*", "quax.*"]
ignore_missing_imports = true


[tool.ruff]
Expand All @@ -127,22 +105,22 @@ src = ["src"]
[tool.ruff.lint]
extend-select = ["ALL"]
ignore = [
"A001", # Variable is shadowing a Python builtin
"A002", # Argument is shadowing a Python builtin
"ANN101", # Missing type annotation for self in method
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed # TODO
"ARG001", # Unused function argument
"COM812", # Missing trailing comma
"D103", # Missing docstring in public function # TODO
"D203", # one-blank-line-before-class
"D213", # Multi-line docstring summary should start at the second line
"ERA001", # Found commented-out code
"F811", # Redefinition of unused variable <- plum
"FIX002", # Line contains TODO, consider resolving the issue
"PD011", # Pandas
"PYI041", # Use `float` instead of `int | float`
"TD002", # Missing author in TODO; try: `# TODO(<author_name>): .
"TD003", # Missing issue link on the line following this TODO
"A001", # Variable is shadowing a Python builtin
"A002", # Argument is shadowing a Python builtin
"ANN101", # Missing type annotation for self in method
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed # TODO
"ARG001", # Unused function argument
"COM812", # Missing trailing comma
"D103", # Missing docstring in public function # TODO
"D203", # one-blank-line-before-class
"D213", # Multi-line docstring summary should start at the second line
"ERA001", # Found commented-out code
"F811", # Redefinition of unused variable <- plum
"FIX002", # Line contains TODO, consider resolving the issue
"PD011", # Pandas
"PYI041", # Use `float` instead of `int | float`
"TD002", # Missing author in TODO; try: `# TODO(<author_name>): .
"TD003", # Missing issue link on the line following this TODO
]

[tool.ruff.lint.per-file-ignores]
Expand All @@ -159,11 +137,11 @@ ignore-paths = [".*/_version.py"]
reports.output-format = "colorized"
similarities.ignore-imports = "yes"
messages_control.disable = [
"design",
"fixme",
"line-too-long",
"missing-function-docstring", # TODO: reinstate.
"missing-module-docstring",
"redefined-builtin",
"wrong-import-position",
"design",
"fixme",
"line-too-long",
"missing-function-docstring", # TODO: reinstate.
"missing-module-docstring",
"redefined-builtin",
"wrong-import-position",
]
Loading

0 comments on commit a562b5f

Please sign in to comment.