Skip to content

Commit

Permalink
feat(ci): add basic cicid (#4)
Browse files Browse the repository at this point in the history
* feat(ci): add basic cicid
  • Loading branch information
WildEgor committed Jun 28, 2024
1 parent 6daccee commit 85deb34
Show file tree
Hide file tree
Showing 15 changed files with 524 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
18 changes: 18 additions & 0 deletions .github/linters/.ecrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Verbose": false,
"Debug": true,
"IgnoreDefaults": false,
"SpacesAftertabs": false,
"NoColor": false,
"Exclude": ["testfiles", "README.md", "doc.go", "docs.go", "\\.tpl"],
"AllowedContentTypes": [],
"PassedFiles": [],
"Disable": {
"EndOfLine": false,
"Indentation": false,
"InsertFinalNewline": false,
"TrimTrailingWhitespace": false,
"IndentSize": false,
"MaxLineLength": false
}
}
131 changes: 131 additions & 0 deletions .github/linters/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
# configure golangci-lint
# based on https://github.com/github/super-linter/blob/main/TEMPLATES/.golangci.yml
linters:
# see https://golangci-lint.run/usage/linters/
enable:
- gosec
- unconvert
- goconst
- goimports
- gocritic
- govet
- revive
- gofmt
- gci
- gosimple
- ineffassign
- gocheckcompilerdirectives
- sloglint
- unconvert
- whitespace
linters-settings:
errcheck:
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: true
# List of functions to exclude from checking, where each entry is a single function to exclude.
# See https://github.com/kisielk/errcheck#excluding-functions for details.
exclude-functions:
- io.Copy
- fmt.Printf
- bytes.Buffer.Write
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
revive:
# disable all rules by default in case new linters will be added
# enable this flag from time to time to see if we should fix/add more here
enable-all-rules: false
# see https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
rules:
- name: exported
disabled: false
arguments:
- disableStutteringCheck
- name: import-alias-naming
disabled: false
arguments: ['^[a-z][a-zA-Z0-9]{0,}$']
- name: context-as-argument
disabled: false
- name: import-shadowing
disabled: false
- name: var-declaration
disabled: false
- name: use-any
disabled: false
- name: cognitive-complexity
disabled: false
arguments: [30]
- name: cyclomatic
disabled: false
arguments: [30]
- name: line-length-limit
disabled: false
arguments: [180]
- name: comment-spacings
disabled: false
- name: increment-decrement
disabled: false
- name: unhandled-error
disabled: false
arguments:
- 'fmt.Printf'
- 'io.Copy'
- 'bytes.Buffer.Write'
- name: var-naming
disabled: false

- name: add-constant
disabled: true
- name: bare-return
disabled: true
- name: flag-parameter
disabled: true
- name: function-length
disabled: true
- name: unused-receiver
disabled: true
- name: max-public-structs
disabled: true
- name: unchecked-type-assertion
disabled: true
- name: function-result-limit
disabled: true
- name: confusing-naming
disabled: true
- name: get-return
disabled: true
- name: nested-structs
disabled: true
- name: argument-limit
disabled: true
gci:
custom-order: true
sections:
- standard
- default
- prefix(github.com/WildEgor/e-shop-fiber-microservice-boilerplate)
staticcheck:
checks:
- all

issues:
exclude-dirs:
- api
- vendor
- generated
exclude-files:
- .goreleaser.yml
exclude-rules:
- path: _test\.go
linters:
- dupl
- gosec
- goconst
- staticcheck
include:
# based on the
# https://www.pixelstech.net/article/1650069870-golangci-lint-to-enable-comment-check-for-exported-functions
- EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
- EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
10 changes: 10 additions & 0 deletions .github/linters/.hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
##########################
## Hadolint config file ##
##########################

failure-threshold: warning

ignored:
# Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
- DL3008
11 changes: 11 additions & 0 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"threshold": 5,
"reporters": [
"consoleFull"
],
"ignore": [
"**/*_test.go",
"**/testing/mock.go"
],
"absolute": true
}
39 changes: 39 additions & 0 deletions .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
###########################
###########################
## Markdown Linter rules ##
###########################
###########################

# Linter rules doc:
# - https://github.com/DavidAnson/markdownlint
#
# Note:
# To comment out a single error:
# <!-- markdownlint-disable -->
# any violations you want
# <!-- markdownlint-restore -->
#

###############
# Rules by id #
###############
MD004: false # Unordered list style
MD007:
indent: 2 # Unordered list indentation
MD010:
code_blocks: false # Ignore no-hard-tabs in cde blocks because that's how formatting for golang works
MD013:
line_length: 120 # Line length 80 is far too short
MD024:
siblings_only: true # Allow the same headers for different sections
MD026:
punctuation: ".,;:!。,;:" # List of not allowed
MD029: false # Ordered list item prefix
MD033: false # Allow inline HTML
MD036: false # Emphasis used instead of a heading

#################
# Rules by tags #
#################
blank_lines: false # Error on blank lines
59 changes: 59 additions & 0 deletions .github/linters/.yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
###########################################
# These are the rules used for #
# linting all the yaml files in the stack #
# NOTE: #
# You can disable line with: #
# # yamllint disable-line #
###########################################
rules:
braces:
level: warning
min-spaces-inside: 0
max-spaces-inside: 1
min-spaces-inside-empty: 1
max-spaces-inside-empty: 5
brackets:
level: warning
min-spaces-inside: 0
max-spaces-inside: 1
min-spaces-inside-empty: 1
max-spaces-inside-empty: 5
colons:
level: warning
max-spaces-before: 0
max-spaces-after: 1
commas:
level: warning
max-spaces-before: 0
min-spaces-after: 1
max-spaces-after: 1
comments: disable
comments-indentation: disable
document-end: disable
document-start:
level: warning
present: true
empty-lines:
level: warning
max: 2
max-start: 0
max-end: 0
hyphens:
level: warning
max-spaces-after: 1
indentation:
level: warning
spaces: consistent
indent-sequences: true
check-multi-line-strings: false
key-duplicates: enable
line-length:
level: warning
max: 120
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
63 changes: 63 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
name: "Lint"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

on:
push:
branches: [ main, develop ]
pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Check out code
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter@v6
env:
VALIDATE_ALL_CODEBASE: ${{ github.event_name != 'pull_request' }}
DEFAULT_BRANCH: develop
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILTER_REGEX_EXCLUDE: '.*(assets/.*|\.goreleaser\.yml)'
# go validator works pretty bad in super-linter, we'll use the original one
VALIDATE_GO: false
# do not validate SQL - linters are pretty useless in case of this library,
# and the functionality is tested using integration tests
VALIDATE_SQL: false
VALIDATE_SQLFLUFF: false
VALIDATE_CHECKOV: false
VALIDATE_YAML: false

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod

- name: Lint Golang
uses: golangci/golangci-lint-action@v6
with:
only-new-issues: ${{ github.event_name == 'pull_request' }}
args: >
--config=./.github/linters/.golangci.yml
codespell:
name: Check spelling
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v4
- uses: codespell-project/actions-codespell@v2
with:
exclude_file: go.mod,go.sum,assets/dist/script.js
Loading

0 comments on commit 85deb34

Please sign in to comment.