diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..eee8d7a1b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,46 @@ +--- +default_stages: [pre-commit, pre-push] +fail_fast: false + +repos: + - repo: local + hooks: + # + # YAML + - id: yamllint + name: yamllint + files: .*\.(yaml|yml)$ + entry: yamllint --config-file ./.yamllint + language: system + always_run: false + pass_filenames: true + + # + # Python + - id: py-flake8 + name: py-flake8 + files: .*\.py$ + entry: flake8 --config setup.cfg + language: system + always_run: false + pass_filenames: true + + # + # POST-CHECKOUT + # optional, need to be installed with: pre-commit install -t post-checkout + - id: git-pull + name: git pull + entry: bash -c '[[ $(git branch --show-current) == "master" ]] && git pull --all || true' + language: system + stages: [post-checkout] + always_run: true + pass_filenames: false + + - id: git-branch-delete-stale + name: Delete stale committed branches + # yamllint disable-line rule:line-length + entry: bash -c '[[ $(git branch --show-current) == "master" ]] && (git fetch -p && git branch -vv | grep ":\ gone]" | awk "{ print \$1 }" | xargs git branch -D) || true' -- + language: system + stages: [post-checkout] + always_run: true + pass_filenames: false diff --git a/.yamllint b/.yamllint new file mode 100644 index 000000000..2be161b56 --- /dev/null +++ b/.yamllint @@ -0,0 +1,12 @@ +--- +extends: default + +rules: + braces: + min-spaces-inside: 1 + max-spaces-inside: 1 + comments: + min-spaces-from-content: 1 + empty-values: enable + line-length: + max: 160 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6c7988d40..d3d4b9b7c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,20 +14,20 @@ We also run the public [Github Project Board](https://github.com/vas3k/vas3k.clu ## πŸ™‹β€β™‚οΈ How to report a bug or propose a feature? -- πŸ†•Open [a new issue](https://github.com/vas3k/vas3k.club/issues/new). +- πŸ†•Open [a new issue](https://github.com/vas3k/vas3k.club/issues/new). - πŸ”¦ Please, **use a search**, to check, if there is already exied issue! -- Explain your idea or proposal in all the details: +- Explain your idea or proposal in all the details: - If it's a **new feature**: - πŸ–Ό If it's **UI/UX** related: attach a screenshot or wireframe. - Please mark this issues with prefix **"Π€ΠΈΡ‡Π°:"** - 🐞 If it's a **bug**: - - make sure you clearly describe "observed" and "expected" behaviour. It will dramatically save time for our contributors and maintainers. + - make sure you clearly describe "observed" and "expected" behaviour. It will dramatically save time for our contributors and maintainers. - **For minor fixes** please just open a PR. - *Please mark this issues with prefix **"Π‘Π°Π³:"*** ## 😎 I want to write some code! -- Open our [Issues page](https://github.com/vas3k/vas3k.club/issues) to see the most important tickets at top. +- Open our [Issues page](https://github.com/vas3k/vas3k.club/issues) to see the most important tickets at top. - Pick one issue you like and **leave a comment** inside that you're getting it. **For big changes** open an issues first or (if it's already opened) leave a comment with brief explanation what and why you're going to change. Many tickets hang open not because they cannot be done, but because they cause many logical contradictions that you may not know. It's better to clarify them in comments before sending a PR. @@ -43,7 +43,7 @@ We also run the public [Github Project Board](https://github.com/vas3k/vas3k.clu ##### 🟨 Discussion is needed -- **new feature** β€” completely new features. Usually they're too hard for newbies, leave them **for experienced contributors.** +- **new feature** β€” completely new features. Usually they're too hard for newbies, leave them **for experienced contributors.** - **idea** β€” **discussion is needed**. Those tickets look adequate, but waiting for real proposals how they will be done. Don't implement them right away. @@ -72,3 +72,20 @@ We try to keep our stack as simple and stupid as possible. Because we're not ver Basically `docker-compose up`. See [README.md](README.md) for details. +## Pre-commit hooks + +`pre-commit` can be used to run Git hooks before submitting the code to review. +These hook scripts perform simple tasks before each commit (code formatting mostly). +To activate the hooks, simply run the following command in your terminal. + +```sh +pre-commit install +``` + +If you try to commit a non-compliant (i.e. badly formatted) file, `pre-commit` will modify this file and make the commit fail. +However you need to stage the new changes **yourself** as `pre-commit` will not do that for you (this is by design; see [here](https://github.com/pre-commit/pre-commit/issues/806) or [here](https://github.com/pre-commit/pre-commit/issues/747)). +Fortunately, `pre-commit` outputs useful messages. + +The list of hooks (and their options) can be found in [`.pre-commit-config.yaml`](.pre-commit-config.yaml). +For more information, see [their website](https://pre-commit.com/). +If you want to manually run all pre-commit hooks on a repository, run `pre-commit run --all-files`. To run individual hooks use `pre-commit run `.