Skip to content
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
46 changes: 46 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: 2.1

workflows:
version: 2
verify:
jobs:
- pre-commit:
filters:
tags: &filter-all-tags # run for all tags
only: /.*/

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
working_directory: &workingdir /tmp/ci
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 --config <<parameters.config_file>>
- run:
command: git --no-pager diff
name: git diff
when: on_fail
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
default_stages:
- 'commit'

repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v2.7.1'
hooks:
- id: prettier

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.3.0'
hooks:
- id: check-yaml
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-vcs-permalinks
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/syntaqx/git-hooks
rev: 'v0.0.17'
hooks:
- id: forbid-binary

- repo: https://github.com/pre-commit/pre-commit
rev: 'v2.20.0'
hooks:
- id: validate_manifest

ci:
autoupdate_schedule: quarterly
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"trailingComma": "none",
"tabWidth": 2,
"semi": false,
"endOfLine": "auto",
"bracketSpacing": true,
"vueIndentScriptAndStyle": false,
"htmlWhitespaceSensitivity": "ignore",
"printWidth": 88,
"singleQuote": true
}
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Speckle Repo Management Templates
# Speckle Pre-Commit Hooks

[![Twitter Follow](https://img.shields.io/twitter/follow/SpeckleSystems?style=social)](https://twitter.com/SpeckleSystems) [![Community forum users](https://img.shields.io/discourse/users?server=https%3A%2F%2Fdiscourse.speckle.works&style=flat-square&logo=discourse&logoColor=white)](https://discourse.speckle.works) [![website](https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square)](https://speckle.systems) [![docs](https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&logo=read-the-docs&logoColor=white)](https://speckle.guide/dev/)

Expand All @@ -17,6 +17,7 @@ Comprehensive developer and user documentation for Speckle can be found in our:
## Usage

1. Add the following to your `.pre-commit-config.yaml` file:

```
- repo: https://github.com/specklesystems/pre-commit
rev: '0.1.0'
Expand All @@ -27,11 +28,14 @@ Comprehensive developer and user documentation for Speckle can be found in our:
## Developing & Debugging

1. install:
- `git`
- `pre-commit`

- `git`
- `pre-commit`

1. Git clone this repository. Detailed steps on how to do that can be found on [GitHub's documentation](https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls).
1. In a terminal, `cd` into a directory containing code that you wish to try the pre-commit hook on. e.g. Speckle's `speckle-server` repository.
1. Run the following command to run a pre-commit hook directly from this repository. Replace `<pre-commit hook to run>` with the name of the hook you wish to run:

```shell
pre-commit try-repo ./path/to/cloned/specklesystems/pre-commit <pre-commit hook to run>
```
Expand Down