Skip to content

Commit d3a38b2

Browse files
authored
feat: add github actions for linter checks and pre-commit configuration (#12)
1 parent a35fd71 commit d3a38b2

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
10+
jobs:
11+
static-checks:
12+
name: Static Checks
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Configure python
17+
uses: actions/[email protected]
18+
with:
19+
python-version: '3.9'
20+
- name: Configure Go
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: 1.17
24+
- name: Get golangci-lint
25+
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v${GOLANGCI_LINT_VERSION}
26+
env:
27+
GOLANGCI_LINT_VERSION: "1.44.2"
28+
- name: Run pre-commit
29+
uses: pre-commit/[email protected]

.pre-commit-config.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
default_stages: [commit, push]
2+
minimum_pre_commit_version: "1.20.0"
3+
repos:
4+
- repo: https://github.com/dnephin/pre-commit-golang
5+
rev: v0.3.5
6+
hooks:
7+
- id: go-fmt
8+
name: Run go fmt against the code
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v3.4.0
11+
hooks:
12+
- id: trailing-whitespace
13+
- id: end-of-file-fixer
14+
- id: check-merge-conflict
15+
- id: mixed-line-ending
16+
- repo: https://github.com/thlorenz/doctoc.git
17+
rev: v2.0.0
18+
hooks:
19+
- id: doctoc
20+
name: Add TOC for md files
21+
files: ^README\.md$|^CONTRIBUTING\.md$
22+
args:
23+
- "--maxlevel"
24+
- "3"
25+
- repo: local
26+
hooks:
27+
- id: golangci-lint
28+
language: golang
29+
name: Run golangci against the code
30+
entry: golangci-lint run
31+
types: [go]
32+
pass_filenames: false

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4+
5+
- [github-flow-manager](#github-flow-manager)
6+
- [Help](#help)
7+
- [Example](#example)
8+
- [Pre commit](#pre-commit)
9+
- [Expressions](#expressions)
10+
- [Available variables](#available-variables)
11+
- [Examples](#examples)
12+
- [How to build](#how-to-build)
13+
14+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
15+
116
# github-flow-manager
217
## Help
318
```
@@ -29,6 +44,14 @@ GITHUB_TOKEN=xxx github-flow-manager octocat Hello-World test master "StatusSucc
2944
GITHUB_TOKEN=xxx github-flow-manager octocat Hello-World test master "StatusSuccess == false" "pipeline-1-name-to-be-checked,pipeline-2-name-to-be-checked" --verbose --dry-run
3045
```
3146

47+
## Pre commit
48+
49+
This repo leverage pre commit to lint, secure, document the IaaC codebase. The pre-commit configuration require the following dependencies:
50+
- [pre-commit](https://pre-commit.com/#install)
51+
- [golangci-lint](https://golangci-lint.run/usage/install/#local-installation)
52+
53+
**One first repo download, to install the pre-commit hooks run**: `pre-commit install`, to run the hooks at will run: `pre-commit run -a`
54+
3255
# Expressions
3356
### Available variables
3457
- `SHA`
@@ -67,7 +90,7 @@ Tag your changes
6790
git tag -a v1.0.X -m "fix"
6891
```
6992

70-
Release
93+
Release
7194
Note: you should generate your Personal Access Token with `write packages` scope enabled
7295
```
7396
GITHUB_TOKEN=<PERSONAL_ACCESS_TOKEN> goreleaser release

0 commit comments

Comments
 (0)