Skip to content

Commit eb284ab

Browse files
mne-botlarsoner
andauthored
MAINT: Update prek versions and refactor scheduled run (#14104)
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
1 parent c5789cd commit eb284ab

3 files changed

Lines changed: 40 additions & 15 deletions

File tree

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: SPEC0
1+
name: Scheduled updates
22

33
on: # yamllint disable-line rule:truthy
44
schedule:
@@ -12,12 +12,24 @@ on: # yamllint disable-line rule:truthy
1212
type: boolean
1313

1414
jobs:
15-
update_versions:
15+
update:
1616
permissions:
1717
contents: write
1818
pull-requests: write
19-
name: Update dependency versions
19+
name: ${{ matrix.name }}
2020
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- id: spec_zero
26+
name: Update dependency specifiers
27+
title: 'MAINT: Update dependency specifiers'
28+
body: '*Adjustments may need to be made to shims in `mne/fixes.py` and elsewhere in this or another PR. `make -C tools/dev dep` is a good starting point for finding potential updates.*'
29+
- id: prek_auto_update
30+
name: Update pre-commit hooks
31+
title: 'MAINT: Update pre-commit hook versions'
32+
body: '*Created by `prek auto-update`. The updated hooks were then run over the whole repo, so any reformatting they now do is included here.*'
2133
env:
2234
GH_TOKEN: ${{ secrets.MNE_BOT_TOKEN }}
2335
GITHUB_TOKEN: ${{ secrets.MNE_BOT_TOKEN }}
@@ -28,6 +40,8 @@ jobs:
2840
- uses: actions/checkout@v7.0.1
2941
with:
3042
persist-credentials: true
43+
- name: Get commit message
44+
run: echo "COMMIT_MESSAGE=$(git show -s --format=%s ${{ github.sha }})" | tee -a ${GITHUB_ENV}
3145
- name: Triage SSH
3246
run: |
3347
if [[ "${{ inputs.ssh }}" == "true" ]] || [[ "$COMMIT_MESSAGE" == *"[actions ssh]"* ]]; then
@@ -49,10 +63,13 @@ jobs:
4963
- name: Install dependencies
5064
run: uv pip install -e . packaging requests tomlkit prek
5165
- name: Update tracked dependencies
66+
if: matrix.id == 'spec_zero'
5267
run: python ./tools/dev/spec_zero_update_versions.py
5368
- name: Sync updated dependencies to README
69+
if: matrix.id == 'spec_zero'
5470
run: python tools/sync_dependencies.py
5571
- name: Create lockfile for old CI
72+
if: matrix.id == 'spec_zero'
5673
# uv pip compile requires setting the python version explicitly in the command :(
5774
run: |
5875
uv pip compile pyproject.toml \
@@ -61,7 +78,9 @@ jobs:
6178
--resolution lowest-direct \
6279
--format pylock.toml --output-file tools/pylock.ci-old.toml
6380
python tools/github_actions_check_old_lockfile.py
64-
- run: prek auto-update
81+
- name: Update pre-commit hook versions
82+
if: matrix.id == 'prek_auto_update'
83+
run: prek auto-update
6584
- name: check if files changed
6685
run: |
6786
git diff && git status --porcelain
@@ -72,17 +91,23 @@ jobs:
7291
- uses: j178/prek-action@v2.0.6
7392
if: steps.status.outputs.dirty == 'true'
7493
- name: Create PR
94+
env:
95+
BRANCH: ${{ matrix.id }}
96+
TITLE: ${{ matrix.title }}
97+
BODY: ${{ matrix.body }}
98+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
7599
run: |
76100
set -xeo pipefail
77101
git diff
78102
git config --global user.email "50266005+mne-bot@users.noreply.github.com"
79103
git config --global user.name "mne[bot]"
80-
git checkout -b spec_zero
81-
if [ -f doc/changes/dev/dependency.rst ]; then
82-
git add doc/changes/dev/dependency.rst # one new file, others changed
83-
fi
84-
git commit -am "mne[bot]: Update dependency specifiers"
85-
git push origin spec_zero
86-
PR_NUM=$(gh pr create --base main --head spec_zero --title "MAINT: Update dependency specifiers" --body "Created by spec_zero [GitHub action](https://github.com/mne-tools/mne-python/actions/runs/${{ github.run_id }}). <br> <br> *Adjustments may need to be made to shims in \`mne/fixes.py\` and elswhere in this or another PR. \`make -C tools/dev dep\` is a good starting point for finding potential updates.*")
104+
git checkout -b "$BRANCH"
105+
git add -A # doc/changes/dev/dependency.rst is a new file, the others are changed
106+
git commit -m "mne[bot]: ${TITLE#MAINT: }"
107+
git push origin "$BRANCH"
108+
printf '%s\n\n%s\n' \
109+
"Created by the \`$BRANCH\` job of this [GitHub Action run]($RUN_URL)." \
110+
"$BODY" > "$RUNNER_TEMP/pr_body.md"
111+
PR_NUM=$(gh pr create --base main --head "$BRANCH" --title "$TITLE" --body-file "$RUNNER_TEMP/pr_body.md")
87112
echo "Opened https://github.com/mne-tools/mne-python/pull/${PR_NUM}" >> $GITHUB_STEP_SUMMARY
88113
if: steps.status.outputs.dirty == 'true' && (success() || failure())

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
# Ruff mne
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: v0.15.22
4+
rev: v0.16.0
55
hooks:
66
- id: ruff-check
77
name: ruff lint mne
@@ -24,7 +24,7 @@ repos:
2424
# ty (type checking); deps installed by pre-commit(.ci), see [tool.ty] in
2525
# pyproject.toml for the checked modules and silenced rules
2626
- repo: https://github.com/astral-sh/ty-pre-commit
27-
rev: v0.0.62
27+
rev: v0.0.63
2828
hooks:
2929
- id: ty
3030
additional_dependencies:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ name = "mne"
134134
readme = {content-type = "text/x-rst", file = "README.rst"}
135135
requires-python = ">= 3.10"
136136
# ↑↑↑↑↑↑↑↑↑↑↑ when this changes, bump the `--python-version` in the `uv pip compile ...`
137-
# command in `.github/workflows/spec_zero.yaml` (astral-sh/uv/#16333), and also the
138-
# `python` version for the `kind: old` matrix entry in `.github/workflows/tests.yaml`
137+
# command in `.github/workflows/scheduled_updates.yml` (astral-sh/uv/#16333), and also
138+
# the `python` version for the `kind: old` matrix entry in `.github/workflows/tests.yml`
139139
scripts = {mne = "mne.commands.utils:main"}
140140

141141
[project.optional-dependencies]

0 commit comments

Comments
 (0)