Skip to content

Commit 2cea20f

Browse files
Backport PR #907: Manual package template update (#908)
Co-authored-by: Stuart Mumford <stuart@cadair.com>
1 parent cb15654 commit 2cea20f

5 files changed

Lines changed: 78 additions & 11 deletions

File tree

.cruft.json

Lines changed: 2 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": "bea8060eef60df35f7df61d9db1d56b838bda01a",
3+
"commit": "164646d882aa2e972d305c54778aaaf35f707464",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -32,7 +32,7 @@
3232
".github/workflows/sub_package_update.yml"
3333
],
3434
"_template": "https://github.com/sunpy/package-template",
35-
"_commit": "bea8060eef60df35f7df61d9db1d56b838bda01a"
35+
"_commit": "164646d882aa2e972d305c54778aaaf35f707464"
3636
}
3737
},
3838
"directory": null

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
sdist_verify:
3636
runs-on: ubuntu-latest
3737
steps:
38-
- uses: actions/checkout@v5
38+
- uses: actions/checkout@v6
3939
- uses: actions/setup-python@v6
4040
with:
4141
python-version: '3.13'

.github/workflows/sub_package_update.yml

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# This template is taken from the cruft example code, for further information please see:
22
# https://cruft.github.io/cruft/#automating-updates-with-github-actions
33
name: Automatic Update from package template
4-
permissions:
5-
contents: write
6-
pull-requests: write
74

85
on:
96
# Allow manual runs through the web UI
@@ -19,14 +16,17 @@ on:
1916
jobs:
2017
update:
2118
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
pull-requests: write
2222
strategy:
2323
fail-fast: true
2424
steps:
25-
- uses: actions/checkout@v5
25+
- uses: actions/checkout@v6
2626

2727
- uses: actions/setup-python@v6
2828
with:
29-
python-version: "3.11"
29+
python-version: "3.14"
3030

3131
- name: Install Cruft
3232
run: python -m pip install git+https://github.com/Cadair/cruft@patch-p1
@@ -94,3 +94,70 @@ jobs:
9494
If this pull request has been opened as a draft there are conflicts which need fixing.
9595
9696
**To run the CI on this pull request you will need to close it and reopen it.**
97+
98+
report-fail:
99+
if: failure()
100+
needs: [update]
101+
runs-on: ubuntu-latest
102+
permissions:
103+
issues: write
104+
steps:
105+
- name: Open an issue if workflow fails
106+
uses: actions/github-script@v7
107+
with:
108+
github-token: ${{ github.token }}
109+
# This script is adapted from https://github.com/scientific-python/issue-from-pytest-log-action
110+
# Under MIT license (c) Scientific Python Developers
111+
script: |
112+
const fs = require('fs');
113+
114+
// Edit these if needed for your repo
115+
const variables = {
116+
owner: context.repo.owner,
117+
name: context.repo.repo,
118+
label: "Infrastructure",
119+
creator: "app/github-actions",
120+
title: "SunPy Package Template auto-update failed."
121+
};
122+
123+
const logs = 'The package update workflow failed.'
124+
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
125+
const issue_body = `[Workflow Run URL](${workflow_url})\n${logs}`;
126+
127+
const query_string = `repo:${variables.owner}/${variables.name} author:${variables.creator} label:${variables.label} is:open in:title ${variables.title}`;
128+
129+
// Run GraphQL query against GitHub API to find the most recent open issue used for reporting failures
130+
const query = `query {
131+
search(query: "${query_string}", type:ISSUE, first: 1) {
132+
edges {
133+
node {
134+
... on Issue {
135+
body
136+
id
137+
number
138+
}
139+
}
140+
}
141+
}
142+
}`;
143+
144+
const result = await github.graphql(query);
145+
146+
// If no issue is open, create a new issue,
147+
// else update the body of the existing issue.
148+
if (result.search.edges.length === 0) {
149+
github.rest.issues.create({
150+
owner: variables.owner,
151+
repo: variables.n ame,
152+
body: issue_body,
153+
title: variables.title,
154+
labels: [variables.label],
155+
});
156+
} else {
157+
github.rest.issues.update({
158+
owner: variables.owner,
159+
repo: variables.name,
160+
issue_number: result.search.edges[0].node.number,
161+
body: issue_body
162+
});
163+
}

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
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.13.2"
4+
rev: "v0.14.10"
55
hooks:
66
- id: ruff
77
args: ["--fix"]
88
- repo: https://github.com/PyCQA/isort
9-
rev: 6.1.0
9+
rev: 7.0.0
1010
hooks:
1111
- id: isort
1212
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|ndcube/extern)$"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ name = "ndcube"
1111
description = "A package for multi-dimensional contiguous and non-contiguous coordinate aware arrays."
1212
requires-python = ">=3.11"
1313
readme = { file = "README.rst", content-type = "text/x-rst" }
14-
license = { file = "licenses/LICENSE.rst" }
14+
license-files = ["licenses/LICENSE.rst"]
1515
authors = [
1616
{ name = "The SunPy Community", email = "sunpy@googlegroups.com" },
1717
]

0 commit comments

Comments
 (0)