项目作者: NTT-DATA-Cloud-Transformation

项目描述 :
Flux7 Centralized repository for git hooks
高级语言: Shell
项目地址: git://github.com/NTT-DATA-Cloud-Transformation/central-repo-git-hooks.git
创建时间: 2019-07-09T18:19:35Z
项目社区:https://github.com/NTT-DATA-Cloud-Transformation/central-repo-git-hooks

开源协议:MIT License

下载


central-repo-git-hooks

This is Flux7 Centralized repository for git pre-commit hooks.

What is git-hooks

Git hooks are scripts that Git executes automaticaly on occurance of events like commit, push, and receive.

pre-commit tool

Pre-Requisites

  • You need to have the pre-commit package manager installed.

How to use pre-commit

  1. create a direcotry for your project repository and and initiliaze the git using git init command.
  2. $ git init
  3. Initialized empty Git repository in /home/kishor_flux7/mywork/testing/.git/
  4. create .pre-commit-config.yaml file .
  5. $ vi .pre-commit-config.yaml
  6. Add the reference to use this repo and the rev as the brach or git tag , and under hooks list add the hooks you wish to call.
  7. $ cat .pre-commit-config.yaml
  8. - repo: https://github.com/NTT-DATA-Cloud-Transformation/central-repo-git-hooks
  9. rev: master
  10. hooks:
  11. - id: terraform-fmt
  12. Run the pre-commit install command to initialize the pre-commit.
  13. $ pre-commit install
  14. pre-commit installed at .git/hooks/pre-commit
  15. Run the following command to test if the pre-commit hook executes.
  16. $ pre-commit run -a
  17. Terraform fmt........................................(no files to check)Skipped

Hooks available

Following are the available hooks -

  1. - id: check-readme
  2. description: Validate for readme file presence
  3. - id: validate-author-email
  4. description: Validate the author flux7 email address
  5. - id: terraform-fmt
  6. description: Runs `terraform fmt` on all Terraform files
  7. - id: security-check
  8. description: 'Scans Terraform, AWS CloudFormation and Kubernetes configuration files.'
  9. - id: packer-validate
  10. description: Runs `packer validate` on all staged packer files
  11. - id: cfn-lint
  12. description: Runs cfn-lint on CloudFormation Templates
  13. - id: flake8-lint
  14. description: '`flake8` is a command-line utility for enforcing style consistency across Python projects.'
  15. - id: check-prtemplate
  16. description: Validate for PR template file presence
  17. # The below hooks are only required or used by a PR build and not required to be used by developers
  18. - id: prbuild-cfn-lint
  19. description: Runs cfn-lint on CloudFormation Templates when a pr build is invoked

Developer - How to trigger hooks validation

The pre-commit hooks from this central-repo-git-hooks repo can be triggered to run against any repository.

How this repo can be used as a part of the Server based PR Builds?

Makefile : The makefile is developed as a part of this repository for the flexibility to use the pre-commit hooks as a part of server based pr builds on multiple repositories. For eg At Flux7, this make file is used by a centralized CI System which runs the code linting as a check on all the repositories irrespective of the language used by the code repository and this “Code-Linter” CI check could be possibly used to block merges to master.