From aeeec837c0f8b63cd03962a05ec41167b2b6d875 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Fri, 6 Dec 2024 18:47:29 +0000 Subject: [PATCH] Updates from package template (#264) Co-authored-by: Nabil Freij --- .cruft.json | 8 +- .github/workflows/ci.yml | 15 ++-- .github/workflows/label_sync.yml | 23 ++++++ .pre-commit-config.yaml | 2 +- .ruff.toml | 20 ++--- docs/changelog.rst | 10 --- docs/conf.py | 2 +- docs/index.rst | 5 +- docs/whatsnew/changelog.rst | 10 +++ docs/whatsnew/index.rst | 12 +++ pyproject.toml | 135 +++++++++++++++---------------- 11 files changed, 134 insertions(+), 108 deletions(-) create mode 100644 .github/workflows/label_sync.yml delete mode 100644 docs/changelog.rst create mode 100644 docs/whatsnew/changelog.rst create mode 100644 docs/whatsnew/index.rst diff --git a/.cruft.json b/.cruft.json index 20406915..21440a8e 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/sunpy/package-template", - "commit": "51fb616094a4d7577c8898445aa50effb89afa31", + "commit": "3737aa309d2a695ada046c7868c5683213003f3d", "checkout": null, "context": { "cookiecutter": { @@ -10,6 +10,12 @@ "author_name": "The SunPy Community", "author_email": "sunpy@googlegroups.com", "project_url": "https://sunpy.org", + "github_repo": "sunpy/radiospectra", + "sourcecode_url": "https://github.com/sunpy/radiospectra", + "download_url": "https://pypi.org/project/sunraster", + "documentation_url": "https://docs.sunpy.org/projects/radiospectra", + "changelog_url": "https://docs.sunpy.org/projects/radiospectra/en/stable/whatsnew/changelog.html", + "issue_tracker_url": "https://github.com/sunpy/radiospectra/issues/", "license": "BSD 2-Clause", "minimum_python_version": "3.10", "use_compiled_extensions": "n", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce7dc6f8..397edd86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,4 @@ +# Main CI Workflow name: CI on: @@ -21,7 +22,7 @@ concurrency: jobs: core: - uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main + uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1 with: submodules: false coverage: codecov @@ -45,8 +46,8 @@ jobs: - run: python -m twine check dist/* test: - needs: [core] - uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main + needs: [core, sdist_verify] + uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1 with: submodules: false coverage: codecov @@ -61,7 +62,7 @@ jobs: docs: needs: [core] - uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main + uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1 with: default_python: '3.12' submodules: false @@ -80,7 +81,7 @@ jobs: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Run cron CI') ) - uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main + uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1 with: default_python: '3.12' submodules: false @@ -118,8 +119,8 @@ jobs: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Run publish') ) - needs: [test] - uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@main + needs: [test, docs] + uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1 with: python-version: "3.12" test_extras: 'dev' diff --git a/.github/workflows/label_sync.yml b/.github/workflows/label_sync.yml new file mode 100644 index 00000000..7f217758 --- /dev/null +++ b/.github/workflows/label_sync.yml @@ -0,0 +1,23 @@ +name: Label Sync +on: + 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 0 * * *' # run every day at midnight UTC + +# Give permissions to write issue labels +permissions: + issues: write + +jobs: + label_sync: + runs-on: ubuntu-latest + name: Label Sync + steps: + - uses: srealmoreno/label-sync-action@850ba5cef2b25e56c6c420c4feed0319294682fd + with: + config-file: https://raw.githubusercontent.com/sunpy/.github/main/labels.yml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 24a9a61b..43ffc3e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: # This should be before any formatting hooks like isort - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.7.2" + rev: "v0.8.1" hooks: - id: ruff args: ["--fix"] diff --git a/.ruff.toml b/.ruff.toml index 666d3b3c..1a9141cf 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -16,26 +16,22 @@ select = [ "PT", ] extend-ignore = [ - # pycodestyle + # pycodestyle (E, W) "E501", # ignore line length will use a formatter instead - "E712", # Avoid equality comparisons to True; use if {cond}: for truth checks - "E721", # type comparison Use is and is not for type comparisons, or isinstance() for isinstance checks - # upgrades + # pyupgrade (UP) "UP038", # Use | in isinstance - not compatible with models and is slower # pytest (PT) "PT001", # Always use pytest.fixture() - "PT004", # Fixtures which don't return anything should have leading _ - "PT011", # except(ValueRaises) is too broad "PT023", # Always use () on pytest decorators - # flake8-pie + # flake8-pie (PIE) "PIE808", # Disallow passing 0 as the first argument to range - # flake8-use-pathlib + # flake8-use-pathlib (PTH) "PTH123", # open() should be replaced by Path.open() - # Ruff + # Ruff (RUF) "RUF003", # Ignore ambiguous quote marks, doesn't allow ' in comments - "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` - "RUF013", # PEP 484 prohibits implicit `Optional` - "RUF015", # Prefer `next(iter(...))` over single element slice + "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` + "RUF013", # PEP 484 prohibits implicit `Optional` + "RUF015", # Prefer `next(iter(...))` over single element slice ] [lint.per-file-ignores] diff --git a/docs/changelog.rst b/docs/changelog.rst deleted file mode 100644 index 60b9fef9..00000000 --- a/docs/changelog.rst +++ /dev/null @@ -1,10 +0,0 @@ -.. _changelog: - -********* -Changelog -********* - -.. changelog:: - :towncrier: ../ - :towncrier-skip-if-empty: - :changelog_file: ../CHANGELOG.rst diff --git a/docs/conf.py b/docs/conf.py index bff4b00b..c3e92565 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -43,10 +43,10 @@ "sphinx.ext.viewcode", "sphinx.ext.napoleon", "sphinx.ext.doctest", - "sphinx_changelog", "sphinx.ext.mathjax", "sphinx_automodapi.automodapi", "sphinx_automodapi.smart_resolver", + "sphinx_changelog", ] # Set automodapi to generate files inside the generated directory diff --git a/docs/index.rst b/docs/index.rst index 5ecd9c00..c6095b01 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -25,9 +25,6 @@ It will describe the different data classes, as well as how to install ``sunrast Contents ======== -* :ref:`genindex` -* :ref:`modindex` - .. toctree:: :maxdepth: 2 :caption: Contents: @@ -35,4 +32,4 @@ Contents installation data_types/index api - changelog + whatsnew/index diff --git a/docs/whatsnew/changelog.rst b/docs/whatsnew/changelog.rst new file mode 100644 index 00000000..a3678c42 --- /dev/null +++ b/docs/whatsnew/changelog.rst @@ -0,0 +1,10 @@ +.. _changelog: + +************** +Full Changelog +************** + +.. changelog:: + :towncrier: ../../ + :towncrier-skip-if-empty: + :changelog_file: ../../CHANGELOG.rst diff --git a/docs/whatsnew/index.rst b/docs/whatsnew/index.rst new file mode 100644 index 00000000..93b82744 --- /dev/null +++ b/docs/whatsnew/index.rst @@ -0,0 +1,12 @@ +.. _whatsnew: + +*************** +Release History +*************** + +This page documents the releases for sunraster + +.. toctree:: + :maxdepth: 1 + + changelog diff --git a/pyproject.toml b/pyproject.toml index 3a3f0896..dc1cd393 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,7 @@ tests = [ docs = [ "sphinx", "sphinx-automodapi", + "sphinx-changelog", "sunpy-sphinx-theme", "packaging", "sphinx-changelog", @@ -44,7 +45,12 @@ docs = [ ] [project.urls] -repository = "https://sunpy.org" +Homepage = "https://sunpy.org" +"Source Code" = "https://github.com/sunpy/radiospectra" +Download = "https://pypi.org/project/sunraster" +Documentation = "https://docs.sunpy.org/projects/radiospectra" +Changelog = "https://docs.sunpy.org/projects/radiospectra/en/stable/whatsnew/changelog.html" +"Issue Tracker" = "https://github.com/sunpy/radiospectra/issues/" [tool.setuptools] zip-safe = false @@ -57,77 +63,62 @@ exclude = ["sunraster._dev*"] [tool.setuptools_scm] write_to = "sunraster/_version.py" -[ tool.gilesbot ] - [ tool.gilesbot.pull_requests ] - enabled = true +[tool.gilesbot] + [tool.gilesbot.pull_requests] + enabled = true + + [tool.gilesbot.towncrier_changelog] + enabled = true + verify_pr_number = true + changelog_skip_label = "No Changelog Entry Needed" + help_url = "https://github.com/sunpy/radiospectra/blob/main/changelog/README.rst" + + changelog_missing_long = "There isn't a changelog file in this pull request. Please add a changelog file to the `changelog/` directory following the instructions in the changelog [README](https://github.com/sunpy/radiospectra/blob/main/changelog/README.rst)." + + type_incorrect_long = "The changelog file you added is not one of the allowed types. Please use one of the types described in the changelog [README](https://github.com/sunpy/radiospectra/blob/main/changelog/README.rst)" - [ tool.gilesbot.towncrier_changelog ] - enabled = true - verify_pr_number = true - changelog_skip_label = "No Changelog Entry Needed" - help_url = "https://github.com/sunpy/sunraster/blob/main/changelog/README.rst" - changelog_missing_long = "There isn't a changelog file in this pull request. Please add a changelog file to the `changelog/` directory following the instructions in the changelog [README](https://github.com/sunpy/sunraster/blob/main/changelog/README.rst)." - type_incorrect_long = "The changelog file you added is not one of the allowed types. Please use one of the types described in the changelog [README](https://github.com/sunpy/sunraster/blob/main/changelog/README.rst)" - number_incorrect_long = "The number in the changelog file you added does not match the number of this pull request. Please rename the file." + number_incorrect_long = "The number in the changelog file you added does not match the number of this pull request. Please rename the file." +# TODO: This should be in towncrier.toml but Giles currently only works looks in +# pyproject.toml we should move this back when it's fixed. [tool.towncrier] - package = "sunraster" - filename = "CHANGELOG.rst" - directory = "changelog/" - issue_format = "`#{issue} `__" - - [[tool.towncrier.type]] - directory = "breaking" - name = "Breaking Changes" - showcontent = true - - [[tool.towncrier.type]] - directory = "deprecation" - name = "Deprecations" - showcontent = true - - [[tool.towncrier.type]] - directory = "removal" - name = "Removals" - showcontent = true - - [[tool.towncrier.type]] - directory = "feature" - name = "New Features" - showcontent = true - - [[tool.towncrier.type]] - directory = "bugfix" - name = "Bug Fixes" - showcontent = true - - [[tool.towncrier.type]] - directory = "doc" - name = "Documentation" - showcontent = true - - [[tool.towncrier.type]] - directory = "trivial" - name = "Internal Changes" - showcontent = true - -[tool.black] -line-length = 120 -include = '\.pyi?$' -exclude = ''' -( - /( - \.eggs - | \.git - | \.mypy_cache - | \.tox - | \.venv - | _build - | buck-out - | build - | dist - | docs - | .history - )/ -) -''' + package = "sunraster" + filename = "CHANGELOG.rst" + directory = "changelog/" + issue_format = "`#{issue} `__" + title_format = "{version} ({project_date})" + + [[tool.towncrier.type]] + directory = "breaking" + name = "Breaking Changes" + showcontent = true + + [[tool.towncrier.type]] + directory = "deprecation" + name = "Deprecations" + showcontent = true + + [[tool.towncrier.type]] + directory = "removal" + name = "Removals" + showcontent = true + + [[tool.towncrier.type]] + directory = "feature" + name = "New Features" + showcontent = true + + [[tool.towncrier.type]] + directory = "bugfix" + name = "Bug Fixes" + showcontent = true + + [[tool.towncrier.type]] + directory = "doc" + name = "Documentation" + showcontent = true + + [[tool.towncrier.type]] + directory = "trivial" + name = "Internal Changes" + showcontent = true