From 1ce61bdda868908bc666ad27b37b7e052879a43d Mon Sep 17 00:00:00 2001 From: Iain Sproat <68657+iainsproat@users.noreply.github.com> Date: Fri, 24 Nov 2023 16:37:51 +0000 Subject: [PATCH] ci(pre-commit): add a pre-commit job to CI --- .circleci/config.yml | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a465bf6f..662eb1d3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,10 +1,43 @@ version: 2.1 orbs: - python: circleci/python@2.0.3 - codecov: codecov/codecov@3.2.2 + codecov: codecov/codecov@3.3.0 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-<>-{{ checksum "<>" }} + - run: + name: Install pre-commit hooks + command: pre-commit install-hooks --config <> + - save_cache: + key: cache-pre-commit-<>-{{ checksum "<>" }} + 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 @@ -52,6 +85,10 @@ jobs: workflows: main: jobs: + - pre-commit: + filters: + tags: + only: /.*/ - test: matrix: parameters: @@ -62,6 +99,7 @@ workflows: - deploy: context: pypi requires: + - pre-commit - test filters: tags: