Skip to content
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

chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.9.6 #11

Merged
merged 4 commits into from
Feb 12, 2025
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
75 changes: 75 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: pre-commit

on:
# Caches have a certain level of isolation, see https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
# We run on push to main to have all caches in the main branch so that they can be reused for PRs.
push:
branches:
- main
merge_group:
pull_request:
# Default is [opened, reopened, synchronize]. Since we want to run pre-commit on "ready to review",
# we add that one. Since lists are overwritten, not merged, we add all four.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
# for documentation of the default behaviour
types:
- opened
- reopened
- synchronize
- ready_for_review

# Cancel a previous job if the same workflow is triggers on the same PR or commit.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
pre-commit:
runs-on:
labels:
- ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ secrets.ANACONDA_BOT_PRE_COMMIT }}

- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ runner.arch }}-${{ hashFiles('.pre-commit-config.yaml', '.tflint.hcl') }}

- name: Install pre-commit hooks
# Ensure all hooks are installed so that the following pre-commit run step only measures
# the time for the actual pre-commit run.
run: make install-hooks

# Adapted from https://github.com/pre-commit/action/blob/efd3bcfec120bd343786e46318186153b7bc8c68/action.yml#L19
- name: Run pre-commit
run: |
# /usr/bin/time -v measure the time and memory usage
/usr/bin/time -v make pre-commit

############################
# Checkout + commit + push when the previous pre-commit run step failed, as that indicates
# auto-fixes / formatting updates, but not outside pull-requests to avoid pushing commits without
# review to the main branch and also not for draft PRs to avoid pushing commits while the PR is
# still being worked on.
# Don't run pre-commit a second time after the commit, as that would mark the commit which triggered
# the workflow as green, which technically is not correct. A succeeding workflow run after commit + push
# will mark the PR as green, if everything is fine.

- name: Checkout the branch we're running on to enable a commit to it
if: ${{ failure() && github.event_name == 'pull_request' && !github.event.pull_request.draft }}
run: |
git fetch origin refs/heads/${{ github.head_ref }}:refs/remotes/origin/${{ github.head_ref }}
git checkout ${{ github.head_ref }}

- name: Commit linted files
if: ${{ failure() && github.event_name == 'pull_request' && !github.event.pull_request.draft }}
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4
with:
message: "chore(pre-commit): linting"
author_name: Anaconda Bot
author_email: [email protected]

############################
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ repos:
args: [--autofix]
- id: check-yaml
args: [--allow-multiple-documents]
exclude: "conda.recipe/meta.yaml"
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.9.6
hooks:
# lint & attempt to correct failures (e.g. pyupgrade)
- id: ruff
Expand Down