diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..504a408 --- /dev/null +++ b/.circleci/config.yml @@ -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-<>-{{ 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 --config <> + - run: + command: git --no-pager diff + name: git diff + when: on_fail diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d4f01c1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..1a1ea1a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,11 @@ +{ + "trailingComma": "none", + "tabWidth": 2, + "semi": false, + "endOfLine": "auto", + "bracketSpacing": true, + "vueIndentScriptAndStyle": false, + "htmlWhitespaceSensitivity": "ignore", + "printWidth": 88, + "singleQuote": true +} diff --git a/README.md b/README.md index a6fbe37..e137891 100644 --- a/README.md +++ b/README.md @@ -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/) @@ -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' @@ -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 `` with the name of the hook you wish to run: + ```shell pre-commit try-repo ./path/to/cloned/specklesystems/pre-commit ```