Skip to content

Commit

Permalink
Updates Sunpy core with package template
Browse files Browse the repository at this point in the history
  • Loading branch information
CyclingNinja committed Mar 12, 2024
1 parent 7d3cc09 commit 6fbd314
Show file tree
Hide file tree
Showing 18 changed files with 294 additions and 57 deletions.
31 changes: 24 additions & 7 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
[run]
omit =
sunpy/cython_version*
sunpy/conftest.py
sunpy/*setup_package*
sunpy/extern/*
sunpy/version*
sunpy/data/sample.py
sunpy/data/_sample.py
sunpy/data/test/_generate_asdf_test.py
*/sunpy/cython_version*
*/sunpy/conftest.py
*/sunpy/*setup_package*
*/sunpy/extern/*
*/sunpy/version*
*/sunpy/data/sample.py
*/sunpy/data/_sample.py

[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
31 changes: 31 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"template": "https://github.com/sunpy/package-template",
"commit": "d91a5d5e80dfa4402924cc0abfe104db30e239f9",
"checkout": null,
"context": {
"cookiecutter": {
"package_name": "sunpy",
"module_name": "sunpy",
"short_description": "SunPy core package: Python for Solar Physics",
"author_name": "The SunPy Community",
"author_email": "sunpy@googlegroups.com",
"project_url": "https://sunpy.org",
"license": "BSD 2-Clause",
"minimum_python_version": "3.9",
"use_compiled_extensions": "y",
"enable_dynamic_dev_versions": "y",
"include_example_code": "n",
"include_cruft_update_github_workflow": "y",
"_sphinx_theme": "alabaster",
"_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
}
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,20 @@ jobs:
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.10'
- 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
Expand Down Expand Up @@ -173,7 +185,7 @@ 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.yml@main
with:
upload_to_anaconda: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
Expand All @@ -188,6 +200,7 @@ jobs:
- cp3{9,10,11,12}-manylinux*_x86_64
- cp3{9,10,11,12}-macosx_x86_64
- cp3{9,10,11,12}-macosx_arm64
- cp3{9,10,11,12}-win_amd64
secrets:
pypi_token: ${{ secrets.pypi_token }}
anaconda_token: ${{ secrets.anaconda_token }}
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/sub_package_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 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
matrix:
include:
- add-paths: .
body: apply the changes to this repo.
branch: cruft/update
commit-message: "Automatic package template update"
title: Updates from the package template
- add-paths: .cruft.json
body: reject these changes for this repo.
branch: cruft/reject
commit-message: "Reject this package template update"
title: Reject new updates from package template

steps:
- uses: actions/checkout@v4

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

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

- 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
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 update --skip-apply-ask --refresh-private-variables
git restore --staged .
- name: Create pull request
if: steps.check.outputs.has_changes == '1'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: ${{ matrix.add-paths }}
commit-message: ${{ matrix.commit-message }}
branch: ${{ matrix.branch }}
delete-branch: true
branch-suffix: timestamp
title: ${{ matrix.title }}
body: |
This is an autogenerated PR, which will ${{ matrix.body }}.
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template
87 changes: 64 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
sunpy/_version.py
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
Expand All @@ -36,15 +43,17 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
junit/
cover/

# Translations
*.mo
Expand All @@ -54,6 +63,7 @@ junit/
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
Expand All @@ -66,18 +76,46 @@ instance/
docs/_build/
# sphinx gallery execution times
docs/sg_execution_times.rst
# automodapi
docs/api

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version
# IPython
profile_default/
ipython_config.py

# celery beat schedule file
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py
Expand All @@ -91,13 +129,6 @@ ENV/
env.bak/
venv.bak/

# Pipenv
Pipfile

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

Expand All @@ -107,16 +138,29 @@ Pipfile
# mypy
.mypy_cache/

### https://raw.github.com/github/gitignore/master/Global/OSX.gitignore
# Pyre type checker
.pyre/

# IDE
# PyCharm
.idea

# Spyder project settings
.spyderproject
.spyproject

### VScode: https://raw.githubusercontent.com/github/gitignore/master/Global/VisualStudioCode.gitignore
.vscode/*
.vs/*

### https://raw.github.com/github/gitignore/master/Global/OSX.gitignore
.DS_Store
.AppleDouble
.LSOverride

# Icon must ends with two \r.
Icon


# Thumbnails
._*

Expand All @@ -125,7 +169,6 @@ Icon
.Trashes

### Linux: https://raw.githubusercontent.com/github/gitignore/master/Global/Linux.gitignore

*~

# temporary files which can be created if a process still has a handle open of a deleted file
Expand All @@ -140,7 +183,8 @@ 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
.DS_Store
Expand Down Expand Up @@ -196,10 +240,6 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

### VScode: https://raw.githubusercontent.com/github/gitignore/master/Global/VisualStudioCode.gitignore
.vscode/*
.vs/*

### Extra Python Items and SunPy Specific
.hypothesis
.pytest_cache
Expand All @@ -221,9 +261,11 @@ docs/guide/data_types/figure.png
october_M1_flares.csv
aia_map.fits
docs/tutorial/figure.png

### Pycharm
.idea
docs/whatsnew/latest_changelog.txt
examples/**/*.csv
figure_test_images*
tags
baseline

# Release script
.github_cache
Expand All @@ -239,7 +281,6 @@ package.json

# Log files generated by 'vagrant up'
*.log

# asv stuff
asv_env
asv_results
Expand Down
3 changes: 2 additions & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ skip =
default_section = THIRDPARTY
include_trailing_comma = true
known_astropy = astropy, asdf
known_sunpy = sunpy
known_first_party = sunpy
length_sort = false
length_sort_sections = stdlib
line_length = 110
multi_line_output = 3
no_lines_before = LOCALFOLDER
sections = STDLIB, THIRDPARTY, ASTROPY, FIRSTPARTY, LOCALFOLDER
sections = STDLIB, THIRDPARTY, ASTROPY, SUNPY, FIRSTPARTY, LOCALFOLDER
Loading

0 comments on commit 6fbd314

Please sign in to comment.