Skip to content

Commit

Permalink
Registers NdCube with the SunPy template
Browse files Browse the repository at this point in the history
  • Loading branch information
CyclingNinja committed Apr 15, 2024
1 parent d1db721 commit 6ee0b2d
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 45 deletions.
5 changes: 5 additions & 0 deletions .codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ coverage:
project:
default:
threshold: 0.2%

codecov:
require_ci_to_pass: false
notify:
wait_for_ci: true
13 changes: 13 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[codespell]
skip = *.asdf,*.fits,*.fts,*.header,*.json,*.xsh,*cache*,*egg*,*extern*,.git,.idea,.tox,_build,*truncated,*.svg,.asv_env,.history
ignore-words-list =
alog,
nd,
nin,
observ,
ot,
te,
upto,
afile,
precessed,
precess
30 changes: 30 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[run]
omit =
ndcube/conftest.py
ndcube/*setup_package*
ndcube/extern/*
ndcube/version*
*/ndcube/conftest.py
*/ndcube/*setup_package*
*/ndcube/extern/*
*/ndcube/version*

[report]
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain about packages we have installed
except ImportError
# Don't complain if tests don't hit assertions
raise AssertionError
raise NotImplementedError
# Don't complain about script hooks
def main(.*):
# Ignore branches that don't pertain to this version of Python
pragma: py{ignore_python_version}
# Don't complain about IPython completion helper
def _ipython_key_completions_
# typing.TYPE_CHECKING is False at runtime
if TYPE_CHECKING:
# Ignore typing overloads
@overload
8 changes: 4 additions & 4 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "/home/sam/Code/OpenAstronomy/../OpenAstronomy/packaging-guide",
"commit": "79c7c63fa9f20c7873063e08516778e99dd39318",
"template": "https://github.com/sunpy/package-template",
"commit": "6d6729b22066ef890e70c37438da70cac33e03b4",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -9,7 +9,7 @@
"short_description": "A package for multi-dimensional contiguous and non-contiguous coordinate aware arrays.",
"author_name": "The SunPy Community",
"author_email": "[email protected]",
"project_url": "https://docs.sunpy.org/projects/ndcube/",
"project_url": "https://docs.sunpy.org/projects/ndcube",
"license": "BSD 2-Clause",
"minimum_python_version": "3.9",
"use_compiled_extensions": "n",
Expand All @@ -24,7 +24,7 @@
"docs/_static",
".github/workflows/sub_package_update.yml"
],
"_template": "/home/sam/Code/OpenAstronomy/../OpenAstronomy/packaging-guide"
"_template": "https://github.com/sunpy/package-template"
}
},
"directory": null
Expand Down
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ exclude =
__pycache__
docs/conf.py
build
ndcube/__init__.py,
ndcube/__init__.py
rst-directives =
plot
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ jobs:
submodules: false
pytest: false
toxdeps: tox-pypi-filter
libraries: |
apt:
- graphviz
envs: |
- linux: build_docs
posargs: ''
Expand Down
51 changes: 28 additions & 23 deletions .github/workflows/sub_package_update.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
"""
This template is taken from the cruft example code, for further information please see:
https://cruft.github.io/cruft/#automating-updates-with-github-actions
"""
# This template is taken from the cruft example code, for further information please see:
# https://cruft.github.io/cruft/#automating-updates-with-github-actions
name: Automatic Update from package template
permissions:
contents: write
pull-requests: write

on:
pull_request:
branches:
main
# Allow manual runs through the web UI
workflow_dispatch:
schedule:
# ┌───────── minute (0 - 59)
# │ ┌───────── hour (0 - 23)
# │ │ ┌───────── day of the month (1 - 31)
# │ │ │ ┌───────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────── day of the week (0 - 6 or SUN-SAT)
- cron: '0 7 * * 1' # Every Monday at 7am UTC

jobs:
update:
runs-on: ubuntu-latest
Expand All @@ -19,25 +24,25 @@ jobs:
matrix:
include:
- add-paths: .
body: Use this to merge the changes to the repo
body: apply the changes to this repo.
branch: cruft/update
commit-message: "Automate package template update"
title: Incoming updates from package template
commit-message: "Automatic package template update"
title: Updates from the package template
- add-paths: .cruft.json
body: Use this to reject changes in the repo
body: reject these changes for this repo.
branch: cruft/reject
commit-message: "Chore: reject this cruft update"
commit-message: "Reject this package template update"
title: Reject new updates from package template

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"

- name: Install Cruft
run: pip3 install cruft
run: python -m pip install cruft

- name: Check if update is available
continue-on-error: false
Expand All @@ -57,15 +62,15 @@ jobs:
- name: Run update if available
if: steps.check.outputs.has_changes == '1'
run: |
git config --global user.email "gromit@cruft.com"
git config --global user.name "Gromit"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
cruft update --skip-apply-ask --refresh-private-variables
git restore --staged
git restore --staged .
- name: Create pull request
if: steps.check.output.has_changes == '1'
uses: peter-evans/create-pull-request@v4
if: steps.check.outputs.has_changes == '1'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: ${{ matrix.add-paths }}
Expand All @@ -75,5 +80,5 @@ jobs:
branch-suffix: timestamp
title: ${{ matrix.title }}
body: |
This is an autogenerated PR. ${{ matrix.body }}
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template
This is an autogenerated PR, which will ${{ matrix.body }}.
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ instance/

# Sphinx documentation
docs/_build/
# automodapi
docs/api

# PyBuilder
.pybuilder/
Expand Down Expand Up @@ -180,7 +182,7 @@ Icon
# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### MacOS: https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore
# pytype static type analyzer
.pytype/

# General
Expand Down Expand Up @@ -237,8 +239,6 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

### Extra Python Items and SunPy Specific

### Extra Python Items and ndcube Specific
.hypothesis
.pytest_cache
Expand Down
16 changes: 16 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[settings]
balanced_wrapping = true
skip =
docs/conf.py
ndcube/__init__.py
default_section = THIRDPARTY
include_trailing_comma = true
known_astropy = astropy, asdf
known_sunpy = sunpy
known_first_party = ndcube
length_sort = false
length_sort_sections = stdlib
line_length = 110
multi_line_output = 3
no_lines_before = LOCALFOLDER
sections = STDLIB, THIRDPARTY, ASTROPY, SUNPY, FIRSTPARTY, LOCALFOLDER
10 changes: 7 additions & 3 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ extend-ignore = [
# Part of configuration, not a package.
"setup.py" = ["INP001"]
"conftest.py" = ["INP001"]
# Implicit-namespace-package. The examples are not a package.
"docs/*.py" = ["INP001"]
"docs/conf.py" = [
"E402" # Module imports not at top of file
]
"docs/*.py" = [
"INP001", # Implicit-namespace-package. The examples are not a package.
]
"__init__.py" = ["E402", "F401", "F403"]
"test_*.py" = ["B011", "D", "E402", "PGH001", "S101"]
# Need to import clients to register them, but don't use them in file
"ndcube/net/__init__.py" = ["F811"]

[pydocstyle]
[lint.pydocstyle]
convention = "numpy"
2 changes: 1 addition & 1 deletion licenses/TEMPLATE_LICENSE.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This project is based upon the OpenAstronomy package template
(https://github.com/open-astronomy/package-template/) which is licenced under the terms
(https://github.com/OpenAstronomy/package-template/) which is licensed under the terms
of the following licence.

---
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ build-backend = "setuptools.build_meta"
[project]
name = "ndcube"
description = "A package for multi-dimensional contiguous and non-contiguous coordinate aware arrays."
readme = "README.rst"
requires-python = ">=3.9"
readme = { file = "README.rst", content-type = "text/x-rst" }
license = { file = "licenses/LICENSE.rst", content-type = "text/plain" }
authors = [
{ name = "The SunPy Community", email = "[email protected]" },
Expand All @@ -19,18 +19,18 @@ dynamic = ["version"]

[project.optional-dependencies]
tests = [
"pytest",
"pytest-doctestplus",
"pytest-cov",
"pytest",
"pytest-doctestplus",
"pytest-cov"
]
docs = [
"sphinx",
"sphinx-automodapi",
"sphinx",
"sphinx-automodapi",
"tomli; python_version <\"3.11\"",
]

[project.urls]
repository = "https://docs.sunpy.org/projects/ndcube/"
repository = "https://docs.sunpy.org/projects/ndcube"

[tool.setuptools]
zip-safe = false
Expand Down
27 changes: 27 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[pytest]
minversion = 7.0
testpaths =
ndcube
docs
norecursedirs =
.tox
build
docs/_build
docs/generated
*.egg-info
examples
ndcube/_dev
.history
ndcube/extern
doctest_plus = enabled
doctest_optionflags = NORMALIZE_WHITESPACE FLOAT_CMP ELLIPSIS
text_file_format = rst
addopts = --doctest-rst -p no:unraisableexception -p no:threadexception
filterwarnings =
# Turn all warnings into errors so they do not pass silently.
error
# Do not fail on pytest config issues (i.e. missing plugins) but do show them
always::pytest.PytestConfigWarning
# A list of warnings to ignore follows. If you add to this list, you MUST
# add a comment or ideally a link to an issue that explains why the warning
# is being ignored
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env python
from setuptools import setup

setup()
22 changes: 19 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[tox]
min_version = 4.0
requires =
tox-pypi-filter>=0.14
envlist =
py{39,310,311}{,-devdeps,-online,-figure,-conda,-oldestdeps}
build_docs
py{310,311,312}
py312-devdeps
py310-oldestdeps
codestyle
build_docs

[testenv]
pypi_filter = https://raw.githubusercontent.com/sunpy/sunpy/main/.test_package_pins.txt
Expand All @@ -15,10 +19,22 @@ allowlist_externals=
changedir = .tmp/{envname}
description =
run tests
oldestdeps: with the oldest supported version of key dependencies
devdeps: with the latest developer version of key dependencies
online: that require remote data (as well as the offline ones)
figure: runs the figure test suite.
setenv =

pass_env =
# A variable to tell tests we are on a CI system
CI
# Custom compiler locations (such as ccache)
CC
# Location of locales (needed by sphinx on some systems)
LOCALE_ARCHIVE
# If the user has set a LC override we should follow it
LC_ALL

set_env =
MPLBACKEND = agg
COLUMNS = 180
PYTEST_COMMAND = pytest -vvv -s -raR --pyargs ndcube --cov-report=xml --cov=ndcube --cov-config={toxinidir}/setup.cfg {toxinidir}/docs
Expand Down

0 comments on commit 6ee0b2d

Please sign in to comment.