Skip to content

Commit

Permalink
Registers package with the sunpy packaging (#115)
Browse files Browse the repository at this point in the history
Co-authored-by: Nabil Freij <[email protected]>
  • Loading branch information
CyclingNinja and nabobalis authored Nov 11, 2024
1 parent 080bea4 commit b6ce64f
Show file tree
Hide file tree
Showing 46 changed files with 803 additions and 464 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
14 changes: 14 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[codespell]
skip = *.asdf,*.fits,*.fts,*.header,*.json,*.xsh,*cache*,*egg*,*extern*,.git,.idea,.tox,_build,*truncated,*.svg,.asv_env,.history,radiospectra/net/sources/tests/*.html
ignore-words-list =
alog,
nd,
nin,
observ,
ot,
te,
upto,
afile,
precessed,
precess,
technik
30 changes: 30 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[run]
omit =
radiospectra/conftest.py
radiospectra/*setup_package*
radiospectra/extern/*
radiospectra/version*
*/radiospectra/conftest.py
*/radiospectra/*setup_package*
*/radiospectra/extern/*
*/radiospectra/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
32 changes: 32 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"template": "https://github.com/sunpy/package-template",
"commit": "51fb616094a4d7577c8898445aa50effb89afa31",
"checkout": null,
"context": {
"cookiecutter": {
"package_name": "radiospectra",
"module_name": "radiospectra",
"short_description": "Provide support for some type of radio spectra in solar physics.",
"author_name": "The SunPy Community",
"author_email": "[email protected]",
"project_url": "https://sunpy.org",
"license": "BSD 2-Clause",
"minimum_python_version": "3.10",
"use_compiled_extensions": "n",
"enable_dynamic_dev_versions": "y",
"include_example_code": "n",
"include_cruft_update_github_workflow": "y",
"use_extended_ruff_linting": "n",
"_sphinx_theme": "sunpy",
"_parent_project": "",
"_install_requires": "",
"_copy_without_render": [
"docs/_templates",
"docs/_static",
".github/workflows/sub_package_update.yml"
],
"_template": "https://github.com/sunpy/package-template"
}
},
"directory": null
}
27 changes: 27 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[flake8]
ignore =
# missing-whitespace-around-operator
E225
# missing-whitespace-around-arithmetic-operator
E226
# line-too-long
E501
# unused-import
F401
# undefined-local-with-import-star
F403
# redefined-while-unused
F811
# Line break occurred before a binary operator
W503,
# Line break occurred after a binary operator
W504
max-line-length = 110
exclude =
.git
__pycache__
docs/conf.py
build
radiospectra/__init__.py
rst-directives =
plot
55 changes: 45 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,38 @@ jobs:
toxdeps: tox-pypi-filter
envs: |
- linux: py312
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

sdist_verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install -U --user build
- run: python -m build . --sdist
- run: python -m pip install -U --user twine
- run: python -m twine check dist/*

test:
needs: [core]
needs: [core, sdist_verify]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
submodules: false
coverage: codecov
toxdeps: tox-pypi-filter
posargs: -n auto
envs: |
- macos: py311
- windows: py310
- windows: py311
- macos: py310
- linux: py310-oldestdeps
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

docs:
needs: [test]
needs: [core]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
default_python: '3.12'
Expand All @@ -56,6 +73,23 @@ jobs:
envs: |
- linux: build_docs
cron:
if: |
github.event_name == 'workflow_dispatch' || (
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
with:
default_python: '3.12'
submodules: false
coverage: codecov
toxdeps: tox-pypi-filter
envs: |
- linux: py311-devdeps
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

online:
if: "!startsWith(github.event.ref, 'refs/tags/v')"
needs: [test]
Expand All @@ -69,9 +103,10 @@ jobs:
- linux: py312-devdeps
publish:
# Build wheels when pushing to any branch except main
# publish.yml will only publish if tagged ^v.*
# Build wheels on PRs only when labelled. Releases will only be published if tagged ^v.*
# see https://github-actions-workflows.openastronomy.org/en/latest/publish.html#upload-to-pypi
if: |
github.event_name != 'pull_request' ||
(
github.event_name != 'pull_request' && (
github.ref_name != 'main' ||
Expand All @@ -81,12 +116,12 @@ jobs:
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'Run publish')
)
needs: [test]
needs: [test, docs]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@main
with:
python-version: "3.12"
test_extras: 'dev'
test_command: 'pytest -p no:warnings --doctest-rst -m "not mpl_image_compare" --pyargs radiospectra'
python-version: '3.12'
test_extras: 'tests'
test_command: 'pytest -p no:warnings --doctest-rst --pyargs radiospectra'
submodules: false
secrets:
pypi_token: ${{ secrets.pypi_token }}
93 changes: 93 additions & 0 deletions .github/workflows/sub_package_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 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:
# 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
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4

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

- name: Install Cruft
run: python -m pip install git+https://github.com/Cadair/cruft@patch-p1

- name: Check if update is available
continue-on-error: false
id: check
run: |
CHANGES=0
if [ -f .cruft.json ]; then
if ! cruft check; then
CHANGES=1
fi
else
echo "No .cruft.json file"
fi
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
- name: Run update if available
id: cruft_update
if: steps.check.outputs.has_changes == '1'
run: |
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
cruft_output=$(cruft update --skip-apply-ask --refresh-private-variables)
echo $cruft_output
git restore --staged .
if [[ "$cruft_output" == *"Failed to cleanly apply the update, there may be merge conflicts."* ]]; then
echo merge_conflicts=1 >> $GITHUB_OUTPUT
else
echo merge_conflicts=0 >> $GITHUB_OUTPUT
fi
- name: Check if only .cruft.json is modified
id: cruft_json
if: steps.check.outputs.has_changes == '1'
run: |
git status --porcelain=1
if [[ "$(git status --porcelain=1)" == " M .cruft.json" ]]; then
echo "Only .cruft.json is modified. Exiting workflow early."
echo "has_changes=0" >> "$GITHUB_OUTPUT"
else
echo "has_changes=1" >> "$GITHUB_OUTPUT"
fi
- name: Create pull request
if: steps.cruft_json.outputs.has_changes == '1'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: "."
commit-message: "Automatic package template update"
branch: "cruft/update"
delete-branch: true
draft: ${{ steps.cruft_update.outputs.merge_conflicts == '1' }}
title: "Updates from the package template"
body: |
This is an autogenerated PR, which will applies the latest changes from the [SunPy Package Template](https://github.com/sunpy/package-template).
If this pull request has been opened as a draft there are conflicts which need fixing.
**To run the CI on this pull request you will need to close it and reopen it.**
Loading

0 comments on commit b6ce64f

Please sign in to comment.