Skip to content

Commit eba37a7

Browse files
authored
Merge pull request #782 from Cadair/cruft-manual-update
2 parents 46c0a98 + 77607fc commit eba37a7

File tree

7 files changed

+95
-34
lines changed

7 files changed

+95
-34
lines changed

.cruft.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/sunpy/package-template",
3-
"commit": "7b0225e0a206b7b6249752991334dea7e9ffcfd4",
3+
"commit": "75f84c4adf1753af67967930c3335bc73bca9bf5",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -16,7 +16,8 @@
1616
"enable_dynamic_dev_versions": "y",
1717
"include_example_code": "n",
1818
"include_cruft_update_github_workflow": "y",
19-
"_sphinx_theme": "alabaster",
19+
"use_extended_ruff_linting": "n",
20+
"_sphinx_theme": "sunpy",
2021
"_parent_project": "",
2122
"_install_requires": "",
2223
"_copy_without_render": [

.github/workflows/label_sync.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Label Sync
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
# ┌───────── minute (0 - 59)
6+
# │ ┌───────── hour (0 - 23)
7+
# │ │ ┌───────── day of the month (1 - 31)
8+
# │ │ │ ┌───────── month (1 - 12 or JAN-DEC)
9+
# │ │ │ │ ┌───────── day of the week (0 - 6 or SUN-SAT)
10+
- cron: '0 0 * * *' # run every day at midnight UTC
11+
12+
# Give permissions to write issue labels
13+
permissions:
14+
issues: write
15+
16+
jobs:
17+
label_sync:
18+
runs-on: ubuntu-latest
19+
name: Label Sync
20+
steps:
21+
- uses: srealmoreno/label-sync-action@850ba5cef2b25e56c6c420c4feed0319294682fd
22+
with:
23+
config-file: https://raw.githubusercontent.com/sunpy/.github/main/labels.yml

.github/workflows/sub_package_update.yml

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ jobs:
2121
runs-on: ubuntu-latest
2222
strategy:
2323
fail-fast: true
24-
matrix:
25-
include:
26-
- add-paths: .
27-
body: apply the changes to this repo.
28-
branch: cruft/update
29-
commit-message: "Automatic package template update"
30-
title: Updates from the package template
31-
3224
steps:
3325
- uses: actions/checkout@v4
3426

@@ -55,25 +47,47 @@ jobs:
5547
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
5648
5749
- name: Run update if available
50+
id: cruft_update
5851
if: steps.check.outputs.has_changes == '1'
5952
run: |
6053
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
6154
git config --global user.name "${{ github.actor }}"
6255
63-
cruft update --skip-apply-ask --refresh-private-variables
56+
cruft_output=$(cruft update --skip-apply-ask --refresh-private-variables)
57+
echo $cruft_output
6458
git restore --staged .
6559
66-
- name: Create pull request
60+
if [[ "$cruft_output" == *"Failed to cleanly apply the update, there may be merge conflicts."* ]]; then
61+
echo merge_conflicts=1 >> $GITHUB_OUTPUT
62+
else
63+
echo merge_conflicts=0 >> $GITHUB_OUTPUT
64+
fi
65+
66+
- name: Check if only .cruft.json is modified
67+
id: cruft_json
6768
if: steps.check.outputs.has_changes == '1'
69+
run: |
70+
git status --porcelain=1
71+
if [[ "$(git status --porcelain=1)" == " M .cruft.json" ]]; then
72+
echo "Only .cruft.json is modified. Exiting workflow early."
73+
echo "has_changes=0" >> "$GITHUB_OUTPUT"
74+
else
75+
echo "has_changes=1" >> "$GITHUB_OUTPUT"
76+
fi
77+
78+
- name: Create pull request
79+
if: steps.cruft_json.outputs.has_changes == '1'
6880
uses: peter-evans/create-pull-request@v7
6981
with:
7082
token: ${{ secrets.GITHUB_TOKEN }}
71-
add-paths: ${{ matrix.add-paths }}
72-
commit-message: ${{ matrix.commit-message }}
73-
branch: ${{ matrix.branch }}
83+
add-paths: "."
84+
commit-message: "Automatic package template update"
85+
branch: "cruft/update"
7486
delete-branch: true
75-
branch-suffix: timestamp
76-
title: ${{ matrix.title }}
87+
draft: ${{ steps.cruft_update.outputs.merge_conflicts == '1' }}
88+
title: "Updates from the package template"
7789
body: |
78-
This is an autogenerated PR, which will ${{ matrix.body }}.
79-
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template
90+
This is an autogenerated PR, which will applies the latest changes from the [SunPy Package Template](https://github.com/sunpy/package-template).
91+
If this pull request has been opened as a draft there are conflicts which need fixing.
92+
93+
**To run the CI on this pull request you will need to close it and reopen it.**

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
# This should be before any formatting hooks like isort
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: "v0.6.9"
4+
rev: "v0.7.2"
55
hooks:
66
- id: ruff
77
args: ["--fix"]

.ruff.toml

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
target-version = "py310"
2-
line-length = 110
2+
line-length = 120
33
exclude = [
44
".git,",
55
"__pycache__",
@@ -19,27 +19,50 @@ extend-ignore = [
1919
"E712",
2020
"E721",
2121
# pycodestyle (E, W)
22-
"E501", # LineTooLong # TODO! fix
22+
"E501", # ignore line length will use a formatter instead
23+
# pyupgrade (UP)
24+
"UP038", # Use | in isinstance - not compatible with models and is slower
2325
# pytest (PT)
2426
"PT001", # Always use pytest.fixture()
2527
"PT004", # Fixtures which don't return anything should have leading _
26-
"PT007", # Parametrize should be lists of tuples # TODO! fix
27-
"PT011", # Too broad exception assert # TODO! fix
2828
"PT023", # Always use () on pytest decorators
29+
# flake8-pie (PIE)
30+
"PIE808", # Disallow passing 0 as the first argument to range
31+
# flake8-use-pathlib (PTH)
32+
"PTH123", # open() should be replaced by Path.open()
33+
# Ruff (RUF)
34+
"RUF003", # Ignore ambiguous quote marks, doesn't allow ' in comments
35+
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
36+
"RUF013", # PEP 484 prohibits implicit `Optional`
37+
"RUF015", # Prefer `next(iter(...))` over single element slice
2938
]
3039

3140
[lint.per-file-ignores]
32-
# Part of configuration, not a package.
33-
"setup.py" = ["INP001"]
34-
"conftest.py" = ["INP001"]
41+
"setup.py" = [
42+
"INP001", # File is part of an implicit namespace package.
43+
]
44+
"conftest.py" = [
45+
"INP001", # File is part of an implicit namespace package.
46+
]
3547
"docs/conf.py" = [
36-
"E402" # Module imports not at top of file
48+
"E402" # Module imports not at top of file
3749
]
3850
"docs/*.py" = [
39-
"INP001", # Implicit-namespace-package. The examples are not a package.
51+
"INP001", # File is part of an implicit namespace package.
52+
]
53+
"examples/**.py" = [
54+
"T201", # allow use of print in examples
55+
"INP001", # File is part of an implicit namespace package.
56+
]
57+
"__init__.py" = [
58+
"E402", # Module level import not at top of cell
59+
"F401", # Unused import
60+
"F403", # from {name} import * used; unable to detect undefined names
61+
"F405", # {name} may be undefined, or defined from star imports
62+
]
63+
"test_*.py" = [
64+
"E402", # Module level import not at top of cell
4065
]
41-
"__init__.py" = ["E402", "F401", "F403"]
42-
"test_*.py" = ["B011", "D", "E402", "PGH001", "S101"]
4366

4467
[lint.pydocstyle]
4568
convention = "numpy"

ndcube/_dev/scm_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Try to use setuptools_scm to get the current version; this is only used
22
# in development installations from the git repository.
3-
import os.path
3+
from pathlib import Path
44

55
try:
66
from setuptools_scm import get_version
77

8-
version = get_version(root=os.path.join('..', '..'), relative_to=__file__)
8+
version = get_version(root=Path('../..'), relative_to=__file__)
99
except ImportError:
1010
raise
1111
except Exception as e:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ tests = [
3838
docs = [
3939
"sphinx",
4040
"sphinx-automodapi",
41+
"sunpy-sphinx-theme",
4142
"packaging",
4243
"matplotlib",
4344
"mpl-animators>=1.0",
4445
"sphinx-changelog>=1.1.0",
4546
"sphinx-gallery",
4647
"sphinxext-opengraph",
47-
"sunpy-sphinx-theme",
4848
"sunpy>=5.0.0",
4949
]
5050
plotting = [

0 commit comments

Comments
 (0)