Skip to content
/ git-template Public template

Language-agnostic Git template repository to kickstart your projects!

License

Notifications You must be signed in to change notification settings

ShahradR/git-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-template

GitHub workflow semantic-release License: MIT-0 Commitizen friendly Contributor Covenant

Language-agnostic Git template repository to kickstart your projects!

How to use this template

Create a new repository from the template

To use this template for your new project, click "Use this template" near the top of the page, and select a name for your repository to create it in your own account or organization.

Creating a repository from this template

Clone your new repository locally

Once your new repository has been created, clone the repository to your local computer using the git clone command.

git clone https://github.com/<owner name>/<repository name>

Configure pre-commit

This template is configured to run Git hooks using pre-commit, a "framework for managing and maintaining multi-language pre-commit hooks." Linters and common checks are ran against your commits, catching errors and making sure your code is up to snuff before sharing it with the world!

After pre-commit is installed (consider using a Python virtual environment), run the following command to configure the pre-commit hooks for your repository:

pre-commit install && pre-commit install --hook-type commit-msg

The pre-commit hooks supplied with this project will cover most situations, but you might wish to add more to the list depending on your requirements. Below are several examples of .pre-commit-config.yaml files used for different use cases—use this to tailor your hooks based on your project's needs!

Java

This version of the configuration file adds Java support by:

Prettier

asciicast

Checkstyle

asciicast

---
default_stages: [commit]
exclude: vale/styles/*
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.3.0
    hooks:
      - id: check-yaml
      - id: end-of-file-fixer
      - id: trailing-whitespace
      - id: check-case-conflict
      - id: detect-private-key
      - id: mixed-line-ending
        args: [--fix=no]
      - id: check-added-large-files
        args: [--maxkb=10240]

  - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
    rev: v4.0.0
    hooks:
      - id: commitlint
        stages: [commit-msg]
        additional_dependencies: ["@commitlint/config-conventional"]

  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v2.2.1
    hooks:
      - id: prettier
        name: Prettier
+       args:
+         - --plugin=prettier-plugin-java
+       additional_dependencies:
+         - [email protected]

  - repo: local
    hooks:
      - id: dockerfile-provides-entrypoint
        name: Vale
        language: docker_image
        entry: jdkato/vale:latest

+ - repo: https://github.com/gherynos/pre-commit-java
+   rev: v0.1.0
+   hooks:
+     - id: checkstyle
+       name: Checkstyle
JavaScript/TypeScript

This version of the file introduces pre-commit/mirrors-eslint to run ESLint, a tool to "find and fix problems in your JavaScript code."

You'll need a valid ESLint configuration file to run this hook—see Configuring ESLint for details on how to set up your environment.

asciicast

The pre-commit configuration has been adapted to lint both JavaScript and TypeScript code. The ESLint plugins required to run the hook must be listed under additional_dependencies—this particular example was taken from the ShahradR/action-taskcat project, but you might need to customize the dependency list to fit your needs.

---
default_stages: [commit]
exclude: vale/styles/*
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.3.0
    hooks:
      - id: check-yaml
      - id: end-of-file-fixer
      - id: trailing-whitespace
      - id: check-case-conflict
      - id: detect-private-key
      - id: mixed-line-ending
        args: [--fix=no]
      - id: check-added-large-files
        args: [--maxkb=10240]

  - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
    rev: v4.0.0
    hooks:
      - id: commitlint
        stages: [commit-msg]
        additional_dependencies: ["@commitlint/config-conventional"]

  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v2.2.1
    hooks:
      - id: prettier
        name: Prettier

  - repo: local
    hooks:
      - id: dockerfile-provides-entrypoint
        name: Vale
        language: docker_image
        entry: jdkato/vale:latest

+ - repo: https://github.com/pre-commit/mirrors-eslint
+   rev: v7.9.0
+   hooks:
+     - id: eslint
+       name: ESLint
+       files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
+       types: [file]
+       additional_dependencies:
+         - [email protected]
+         - [email protected]
+         - [email protected]
+         - [email protected]
+         - [email protected]
+         - [email protected]
+         - [email protected]
+         - [email protected]
+         - [email protected]
+         - [email protected]
+         - "@typescript-eslint/[email protected]"
+         - "@typescript-eslint/[email protected]"
AWS CloudFormation templates

This version of the file adds the following pre-commit checks:

  • CloudFormation Linter to "validate CloudFormation yaml/json templates against the CloudFormation Resource Specification"
  • Stelligent cfn_nag to "look for patterns in CloudFormation templates that may indicate insecure infrastructure"

CloudFormation Linter

asciicast

Stelligent cfn_nag

asciicast

This configuration expects the templates to reside under the templates/ directory, at the root of the repository.

---
default_stages: [commit]
exclude: vale/styles/*
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.3.0
    hooks:
      - id: check-yaml
      - id: end-of-file-fixer
      - id: trailing-whitespace
      - id: check-case-conflict
      - id: detect-private-key
      - id: mixed-line-ending
        args: [--fix=no]
      - id: check-added-large-files
        args: [--maxkb=10240]

  - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
    rev: v4.0.0
    hooks:
      - id: commitlint
        stages: [commit-msg]
        additional_dependencies: ["@commitlint/config-conventional"]

  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v2.2.1
    hooks:
      - id: prettier
        name: Prettier

  - repo: local
    hooks:
      - id: dockerfile-provides-entrypoint
        name: Vale
        language: docker_image
        entry: jdkato/vale:latest

+ - repo: https://github.com/aws-cloudformation/cfn-python-lint
+   rev: v0.35.1
+   hooks:
+     - id: cfn-python-lint
+       files: templates/.*\.(json|yml|yaml)$
+
+ - repo: local
+   hooks:
+     - id: dockerfile-provides-entrypoint
+       name: cfn_nag
+       language: docker_image
+       entry: stelligent/cfn_nag:latest
+       files: templates/.*\.(json|yml|yaml)$
+       args: ["--fail-on-warnings"]
Docker containers

This version of the file adds the Haskell Dockerfile Linter "a smarter Dockerfile linter that helps you build best practice Docker images" as a pre-commit hook.

asciicast

---
default_stages: [commit]
exclude: vale/styles/*
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.3.0
    hooks:
      - id: check-yaml
      - id: end-of-file-fixer
      - id: trailing-whitespace
      - id: check-case-conflict
      - id: detect-private-key
      - id: mixed-line-ending
        args: [--fix=no]
      - id: check-added-large-files
        args: [--maxkb=10240]

  - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
    rev: v4.0.0
    hooks:
      - id: commitlint
        stages: [commit-msg]
        additional_dependencies: ["@commitlint/config-conventional"]

  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v2.2.1
    hooks:
      - id: prettier
        name: Prettier

  - repo: local
    hooks:
      - id: dockerfile-provides-entrypoint
        name: Vale
        language: docker_image
        entry: jdkato/vale:latest

+ - repo: local
+   hooks:
+     - id: dockerfile-provides-entrypoint
+       name: hadolint
+       language: docker_image
+       entry: --entrypoint hadolint hadolint/hadolint:latest-debian
+       files: Dockerfile
OpenAPI/Swagger specifications

This version of the file adds speccy as a pre-commit hook, to "enforce quality rules on your OpenAPI 3.0.x specifications."

asciicast

This configuration expects the OpenAPI specification file to reside under the specs/ directory, at the root of the repository.

---
default_stages: [commit]
exclude: vale/styles/*
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.3.0
    hooks:
      - id: check-yaml
      - id: end-of-file-fixer
      - id: trailing-whitespace
      - id: check-case-conflict
      - id: detect-private-key
      - id: mixed-line-ending
        args: [--fix=no]
      - id: check-added-large-files
        args: [--maxkb=10240]

  - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
    rev: v4.0.0
    hooks:
      - id: commitlint
        stages: [commit-msg]
        additional_dependencies: ["@commitlint/config-conventional"]

  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v2.2.1
    hooks:
      - id: prettier
        name: Prettier

  - repo: local
    hooks:
      - id: dockerfile-provides-entrypoint
        name: Vale
        language: docker_image
        entry: jdkato/vale:latest

+  - repo: local
+    hooks:
+      - id: dockerfile-provides-entrypoint
+        name: Speccy
+        language: docker_image
+        entry: wework/speccy:latest lint
+        files: 'specs/.*\.(yml|json|yaml)$'

Configure your continuous integration pipeline

TODO: Configuration steps for GitHub Actions will change once workflow templates are implemented. See ShahradR/git-template#15 for more details.

Update your LICENSE file

This repository is licensed under MIT No Attribution (MIT-0)—you are free to use this template for your project without the need to worry about attribution.

Update the LICENSE file with a license appropriate for your project! Visit https://choosealicense.com/ to see common open-source licenses.

Update the README file

Once everything has been set up, delete this file and replace it with a README tailored to your project!

Update the Code of Conduct contact information

Update the [INSERT CONTACT METHOD] string in the project's Code of Conduct to include an e-mail address owned by a member of your community to help mediate any disputes.