- adds a pre-commit config
- includes prettier formatting configuration
- fixes title in README
- adds a CircleCI config
- sets default pre-commit stage to commit
This commit is contained in:
Iain Sproat 2022-08-25 13:04:22 +01:00 коммит произвёл GitHub
Родитель daf2624a5c
Коммит 4d00b7d5b6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 97 добавлений и 3 удалений

46
.circleci/config.yml Normal file
Просмотреть файл

@ -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
.pre-commit-config.yaml Normal file
Просмотреть файл

@ -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
.prettierrc Normal file
Просмотреть файл

@ -0,0 +1,11 @@
{
"trailingComma": "none",
"tabWidth": 2,
"semi": false,
"endOfLine": "auto",
"bracketSpacing": true,
"vueIndentScriptAndStyle": false,
"htmlWhitespaceSensitivity": "ignore",
"printWidth": 88,
"singleQuote": true
}

Просмотреть файл

@ -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 `<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>
```