Skip to content

Commit

Permalink
ci(pre-commit): add a pre-commit job to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
iainsproat committed Nov 24, 2023
1 parent 62ee1a4 commit 1ce61bd
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
version: 2.1

orbs:
python: circleci/[email protected]
codecov: codecov/[email protected]
codecov: codecov/[email protected]

jobs:
pre-commit:
parameters:
config_file:
default: ./.pre-commit-config.yaml
description: Optional, path to pre-commit config file.
type: string
cache_prefix:
default: ''
description: |
Optional cache prefix to be used on CircleCI. Can be used for cache busting or to ensure multiple jobs use different caches.
type: string
docker:
- image: speckle/pre-commit-runner:latest
resource_class: medium
steps:
- checkout
- restore_cache:
keys:
- cache-pre-commit-<<parameters.cache_prefix>>-{{ checksum "<<parameters.config_file>>" }}
- run:
name: Install pre-commit hooks
command: pre-commit install-hooks --config <<parameters.config_file>>
- save_cache:
key: cache-pre-commit-<<parameters.cache_prefix>>-{{ checksum "<<parameters.config_file>>" }}
paths:
- ~/.cache/pre-commit
- run:
name: Run pre-commit
command: pre-commit run --all-files
- run:
command: git --no-pager diff
name: git diff
when: on_fail

test:
machine:
image: ubuntu-2204:2023.02.1
Expand Down Expand Up @@ -52,6 +85,10 @@ jobs:
workflows:
main:
jobs:
- pre-commit:
filters:
tags:
only: /.*/
- test:
matrix:
parameters:
Expand All @@ -62,6 +99,7 @@ workflows:
- deploy:
context: pypi
requires:
- pre-commit
- test
filters:
tags:
Expand Down

0 comments on commit 1ce61bd

Please sign in to comment.