Skip to content

Commit

Permalink
.github: Move pre-commit checks to local self-hosted runners
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrxyz committed Oct 22, 2024
1 parent 37f80be commit 1424516
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/autopush.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ env:
jobs:
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
runs-on:
group: mala-lab-pre-commit
if: github.event.sender.login == 'cbrxyz'
steps:
- name: Check out code from GitHub
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ jobs:
name: Run tests and build docs
needs: avoid-duplicate-ci
if: needs.avoid-duplicate-ci.outputs.should_skip != 'true'
runs-on: self-hosted
runs-on:
group: mala-lab-main
steps:
- name: Configure catkin workspace folder structure
run: |
Expand Down Expand Up @@ -111,7 +112,8 @@ jobs:

deploy-docs:
name: Deploy docs from master
runs-on: self-hosted
runs-on:
group: mala-lab-main
needs: super-ci
# https://github.com/actions/runner/issues/491#issuecomment-850884422
if: |
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: Run pre-commit

# yamllint disable-line rule:truthy
on: [push, workflow_dispatch]

# Cancels this run if a new one referring to the same object and same workflow
# is requested
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# The version of caching we are using. This can be upgraded if we
# significantly change CI to the point where old caches become irrelevant.
CACHE_VERSION: 0
# Default Python version. Noetic defaults to 3.8.
DEFAULT_PYTHON: 3.8
# Location of the pre-commit cache. This is set by pre-commit, not us!
PRE_COMMIT_CACHE: ~/.cache/pre-commit

jobs:
pre-commit:
name: Run pre-commit
runs-on:
group: mala-lab-pre-commit
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
with:
submodules: recursive
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache: "pip"
- name: Install pre-commit hooks
run: |
python --version
pip install "$(cat requirements.txt | grep pre-commit)"
- name: Generate pre-commit cache key
id: pre-commit_cache_key
run: >
echo "::set-output
name=key::${{ env.CACHE_VERSION }}-${{ env.DEFAULT_PYTHON }}-${{
hashFiles('.pre-commit-config.yaml') }}"
- name: Restore base pre-commit environment
id: cache-pre-commmit
uses: actions/[email protected]
with:
path: ${{ env.PRE_COMMIT_CACHE }}
key: >
${{ runner.os
}}-pre-commit-${{ steps.pre-commit_cache_key.outputs.key }}
- name: Install pre-commit dependencies if no cache
if: steps.cache-precommit.outputs.cache-hit != 'true'
run: |
pre-commit install-hooks
- name: Run pre-commit
run: |
pre-commit run --all-files --show-diff-on-failure

0 comments on commit 1424516

Please sign in to comment.