Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/pre_commit_update_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Pre-commit auto-update

on:
schedule:
# Cron syntax:
# 1. Entry: Minute when the process will be started [0-59]
# 2. Entry: Hour when the process will be started [0-23]
# 3. Entry: Day of the month when the process will be started [1-28/29/30/31]
# 4. Entry: Month of the year when the process will be started [1-12]
# 5. Entry: Weekday when the process will be started [0-6] [0 is Sunday]
- cron: '0 8 1 * *'
# Allow manual triggering of the workflow
workflow_dispatch:

permissions:
contents: write
pull-requests: write
issues: write

env:
UP_TO_DATE: false
PYTHON_VERSION: "3.14"
REVIEWERS: "forsyth2"
jobs:
auto-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Set up Conda Environment
uses: mamba-org/setup-micromamba@v3
with:
environment-name: pre_commit_dev
init-shell: bash
condarc: |
channel_priority: strict
channels:
- conda-forge
create-args: >-
python=${{ env.PYTHON_VERSION }}

- name: Install pre-commit, pre-commit-update and gh
run: |
eval "$(micromamba shell hook --shell bash)"
micromamba activate pre_commit_dev
# permissions issue with gh 2.76.0
micromamba install -y --override-channels -c conda-forge \
pre-commit pyyaml "gh !=2.76.0"
python -m pip install pre-commit-update
gh --version

- name: Apply and commit updates
run: |
eval "$(micromamba shell hook --shell bash)"
micromamba activate pre_commit_dev
git clone https://github.com/E3SM-Project/e3sm-comms.git update-pre-commit-deps
cd update-pre-commit-deps
# Configure git using GitHub Actions credentials.
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git checkout -b update-pre-commit-deps
# pre-commit-update doesn't try to include non-release versions
pre-commit-update
# Propagate the new versions to conda/dev.yml and the `qa` extra in
# pyproject.toml
python scripts/sync_pre_commit_versions.py
git add .
# The second command will fail if no changes were present, so we ignore it
git commit -m "Update pre-commit dependencies" || ( echo "UP_TO_DATE=true" >> "$GITHUB_ENV")

- name: Push Changes
if: ${{ env.UP_TO_DATE == 'false' }}
uses: ad-m/github-push-action@v1.1.0
with:
branch: update-pre-commit-deps
directory: update-pre-commit-deps
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
env:
GH_TOKEN: ${{ github.token }}

- name: Make PR and add reviewers and labels
if: ${{ env.UP_TO_DATE == 'false' }}
run: |
cd update-pre-commit-deps
gh pr create \
--title "Update pre-commit and its dependencies" \
--body "This PR was auto-generated to update pre-commit and its dependencies." \
--head update-pre-commit-deps \
--reviewer ${{ env.REVIEWERS }} \
--label DevOps
env:
GH_TOKEN: ${{ github.token }}
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ default_stages: [commit]
fail_fast: true

# make sure these always match dev.yml and qa in pyproject.toml
# (run `python scripts/sync_pre_commit_versions.py` to sync them)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
Expand Down Expand Up @@ -40,6 +41,7 @@ repos:
hooks:
- id: mypy
args: ["--config-file=pyproject.toml"]
additional_dependencies: [types-PyYAML]

# https://pre-commit.ci/#configuration
ci:
Expand Down
8 changes: 5 additions & 3 deletions conda/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ channels:
dependencies:
# Build
# =======================
- python >=3.11,<3.14
- python >=3.11,<3.15
- pip
- setuptools >= 60
# Base
Expand All @@ -34,13 +34,15 @@ dependencies:
# Quality Assurance Tools
# =======================
# Run `pre-commit autoupdate` to get the latest pinned versions of 'rev' in
# `.pre-commit.config.yaml`, then update the pinned versions here.
# Make sure to also update qa in pyproject.toml
# `.pre-commit-config.yaml`, then run
# `python scripts/sync_pre_commit_versions.py` to update the pinned versions
# here and in the `qa` extra of pyproject.toml.
- black ==25.1.0
- flake8 ==7.3.0
- isort ==6.0.1
- mypy ==1.18.2
- pre-commit ==4.3.0
- pyyaml
- types-PyYAML >=6.0.0
# Developer Tools
# =======================
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ authors = [
description = "A package for E3SM Communications supporting software"
license = {file = "LICENSE"}
readme = "README.md"
requires-python = ">=3.11,<3.14"
requires-python = ">=3.11,<3.15"
classifiers = [
# these are only for searching/browsing projects on PyPI
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
]
Expand All @@ -35,13 +36,15 @@ docs = [
]

# make sure these always match dev.yml and .pre-commit-config.yaml
# (run `python scripts/sync_pre_commit_versions.py` to sync them)
qa = [
"black==25.1.0",
"flake8==7.3.0",
"flake8-isort==6.1.1",
"isort==6.0.1",
"mypy==1.18.2",
"pre-commit==4.3.0",
"pyyaml",
"types-PyYAML >=6.0.0",
]

Expand Down Expand Up @@ -91,7 +94,7 @@ exclude = '''
'''

[tool.mypy]
python_version = 3.13
python_version = 3.14
check_untyped_defs = true
ignore_missing_imports = true
warn_unused_ignores = true
Expand Down
Loading