Skip to content

chore(deps): update actions/checkout action to v4.2.2 #268

chore(deps): update actions/checkout action to v4.2.2

chore(deps): update actions/checkout action to v4.2.2 #268

Workflow file for this run

name: '[Tools] 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:
# 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: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ secrets.ANACONDA_BOT_PRE_COMMIT }}
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: '3.12'
- name: install pre-commit
run: pip install pre-commit
- uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
with:
path: |
~/.cache/pre-commit
key: pre-commit|${{ runner.arch }}-${{ env.ANACONDA_RUNNER_VERSION }}-${{ hashFiles('.pre-commit-config.yaml') }}
- 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: 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' }}
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' }}
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4
with:
message: 'chore(pre-commit): linting'
author_name: Anaconda Bot
author_email: [email protected]
############################