-
Notifications
You must be signed in to change notification settings - Fork 16
Add pre-commit auto-update workflow #853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
070e4d2
Add pre-commit auto-update workflow
forsyth2 e1a6079
Sync QA tool versions into pyproject.toml and conda/dev.yml
forsyth2 a0c5ba0
Bump flake8-isort to 6.1.2 to fix isort 6.x conflict
forsyth2 2b3a28b
Address Copilot comments
forsyth2 0afa8d0
Address review comments
forsyth2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| 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 | ||
|
|
||
| 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/zppy.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 }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| exclude: "docs|node_modules|migrations|.git|.tox" | ||
| fail_fast: true | ||
|
|
||
| # (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 | ||
|
|
@@ -29,14 +30,15 @@ repos: | |
| hooks: | ||
| - id: flake8 | ||
| args: ["--config=.flake8.cfg"] | ||
| additional_dependencies: [flake8-isort==6.1.1] | ||
| additional_dependencies: [flake8-isort==6.1.2] | ||
|
|
||
| # Can run individually with `pre-commit run mypy --all-files` | ||
| - repo: https://github.com/pre-commit/mirrors-mypy | ||
| rev: v1.18.2 | ||
| hooks: | ||
| - id: mypy | ||
| args: ["--config=pyproject.toml"] | ||
| additional_dependencies: [types-PyYAML] | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to work fine for |
||
|
|
||
| # https://pre-commit.ci/#configuration | ||
| ci: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use the latest version if we can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be worth adding dependebot to update them.