Skip to content

Commit

Permalink
chore: maintain the go version in CI, add pre-commit (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
viney-shih authored Jun 18, 2022
1 parent 50decc5 commit 2f19fd8
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 4 deletions.
126 changes: 126 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
repos:
# ==========================================================================
# Golang Pre-Commit Hooks | https://github.com/tekwizely/pre-commit-golang
#
# Visit the project home page to learn more about the available Hooks,
# including useful arguments you might want to pass into them.
#
# File-Based Hooks:
# Run against matching staged files individually.
#
# Module-Based Hooks:
# Run against module root folders containing matching staged files.
#
# Package-Based Hooks:
# Run against folders containing one or more staged files.
#
# Repo-Based Hooks:
# Run against the entire repo.
# The hooks only run once (if any matching files are staged),
# and are NOT provided the list of staged files,
#
# My-Cmd-* Hooks
# Allow you to invoke custom tools in varous contexts.
# Can be useful if your favorite tool(s) are not built-in (yet)
#
# Hook Suffixes
# Hooks have suffixes in their name that indicate their targets:
#
# +-----------+--------------+
# | Suffix | Target |
# |-----------+--------------+
# | <none> | Files |
# | -mod | Module |
# | -pkg | Package |
# | -repo | Repo Root |
# | -repo-mod | All Modules |
# | -repo-pkg | All Packages |
# +-----------+--------------+
#
# ! Multiple Hook Invocations
# ! Due to OS command-line-length limits, Pre-Commit can invoke a hook
# ! multiple times if a large number of files are staged.
# ! For file and repo-based hooks, this isn't an issue, but for module
# ! and package-based hooks, there is a potential for the hook to run
# ! against the same module or package multiple times, duplicating any
# ! errors or warnings.
#
# Useful Hook Parameters:
# - id: hook-id
# args: [arg1, arg2, ..., '--'] # Pass options ('--' is optional)
# always_run: true # Run even if no matching files staged
# alias: hook-alias # Create an alias
#
# Passing Options To Hooks:
# If your options contain a reference to an existing file, then you will
# need to use a trailing '--' argument to separate the hook options from
# the modified-file list that Pre-Commit passes into the hook.
# NOTE: For repo-based hooks, '--' is not needed.
#
# Always Run:
# By default, hooks ONLY run when matching file types are staged.
# When configured to "always_run", a hook is executed as if EVERY matching
# file were staged.
#
# Aliases:
# Consider adding aliases to longer-named hooks for easier CLI usage.
# ==========================================================================
- repo: https://github.com/tekwizely/pre-commit-golang
rev: master
hooks:
#
# Go Build
#
- id: go-build-mod
# - id: go-build-pkg
- id: go-build-repo-mod
# - id: go-build-repo-pkg
#
# Go Mod Tidy
#
- id: go-mod-tidy
- id: go-mod-tidy-repo
#
# Go Test
#
- id: go-test-mod
# - id: go-test-pkg
- id: go-test-repo-mod
# - id: go-test-repo-pkg
#
# Go Vet
#
# - id: go-vet
- id: go-vet-mod
# - id: go-vet-pkg
- id: go-vet-repo-mod
# - id: go-vet-repo-pkg
#
# Revive
#
- id: go-revive
- id: go-revive-mod
- id: go-revive-repo-mod
#
# StaticCheck
#
- id: go-staticcheck-mod
# - id: go-staticcheck-pkg
- id: go-staticcheck-repo-mod
# - id: go-staticcheck-repo-pkg
#
# Formatters
#
- id: go-fmt
args: [-w]
- id: go-fmt-repo
args: [-w]
- id: go-imports # replaces go-fmt
args: [-w]
- id: go-imports-repo # replaces go-fmt-repo
args: [-w]
#
# Style Checkers
#
- id: go-lint
#
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: go

go:
- "1.14"
- "1.15"
- "1.16"
- "1.17"
- "1.18"
- master

before_install:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/viney-shih/go-lock)](https://goreportcard.com/report/github.com/viney-shih/go-lock)
[![Codecov](https://codecov.io/gh/viney-shih/go-lock/branch/master/graph/badge.svg)](https://codecov.io/gh/viney-shih/go-lock)
[![Coverage Status](https://coveralls.io/repos/github/viney-shih/go-lock/badge.svg?branch=master)](https://coveralls.io/github/viney-shih/go-lock?branch=master)
[![License](http://img.shields.io/badge/License-Apache_2-red.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
[![Sourcegraph](https://sourcegraph.com/github.com/viney-shih/go-lock/-/badge.svg)](https://sourcegraph.com/github.com/viney-shih/go-lock?badge)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go#utilities)
[![License](http://img.shields.io/badge/License-Apache_2-red.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fviney-shih%2Fgo-lock.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fviney-shih%2Fgo-lock?ref=badge_shield)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go#utilities)

<p align="center">
<img src="assets/logo.png" title="go-lock" />
Expand Down

0 comments on commit 2f19fd8

Please sign in to comment.