Skip to content

Commit

Permalink
add ci pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
sarvalabs-manish committed Dec 20, 2023
1 parent 55c04aa commit 7edc38a
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Continuous Integration
on:
push:
branches:
- main
- develop

pull_request:
branches:
- main
- develop
types:
- opened
- synchronize
- ready_for_review
paths:
- "**.go"
- "**.mod"
- "**.sum"

workflow_call: {}
workflow_dispatch: {}

permissions:
contents: read

jobs:
lint:
name: Lint
uses: ./.github/workflows/lint.yaml

test:
name: Test
needs: lint
uses: ./.github/workflows/test.yaml
30 changes: 30 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint
on:
workflow_dispatch: {}
workflow_call: {}

permissions:
contents: read

jobs:
golangci:
name: GolangCI Lint
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Go 1.18
uses: actions/setup-go@v4
with:
go-version: '1.18'
cache: false

- name: Run Golang CI Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.52.2
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
25 changes: 25 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test
on:
workflow_dispatch: {}
workflow_call: {}

permissions:
contents: read

jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Go 1.18
uses: actions/setup-go@v4
with:
go-version: '1.18'
cache: false

- name: Run Golang Tests
run: go test ./... -v -race
67 changes: 67 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
run:
tests: true
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
# exit code when at least one issue was found, default is 1
issues-exit-code: 1

linters:
disable-all: true
enable:
- dogsled
- dupl
- depguard
- errname
- errorlint
- forcetypeassert
- exportloopref
- goconst
- gocritic
- gofumpt
- gosec
- gosimple
- govet
- importas
- ineffassign
- lll
- makezero
- misspell
- nakedret
- nolintlint
- predeclared
- prealloc
- staticcheck
- stylecheck
- tparallel
- thelper
- typecheck
- unconvert
- unused
- whitespace
- wsl

issues:
exclude-rules:
- text: "Use of weak random number generator"
linters:
- gosec

max-issues-per-linter: 10000
max-same-issues: 10000

linters-settings:
dogsled:
max-blank-identifiers: 3
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
nolintlint:
allow-unused: false # to be set to false once all issues are addressed, any exceptions needed to be added above
allow-leading-space: true
require-explanation: false # nice to have as true
require-specific: false
depguard:
Main:
allow:
- $github.com/sarvalabs/*
- github.com/pkg/errors

0 comments on commit 7edc38a

Please sign in to comment.