Skip to content

Commit

Permalink
separate ci jobs + add linter config (#5)
Browse files Browse the repository at this point in the history
* separate ci jobs + add linter config
  • Loading branch information
yuseferi committed Jun 8, 2023
1 parent 28f8269 commit 5825e5e
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 31 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,24 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Build
on:
workflow_run:
workflows: [Quality check]
types: [completed]

push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
- name: Build
run: go mod download; go build -v ./...
57 changes: 26 additions & 31 deletions .github/workflows/ci.yml
@@ -1,52 +1,47 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Check & Build
name: Quality check
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
qa:
name: Quality check
lint:
name: Linter
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v4

- name: Linter
uses: golangci/golangci-lint-action@v3
with:
version: v1.53.2

- name: Tests
run: go mod download; go test -cover -coverprofile=./unit-cover.txt -race ./...

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./unit-cover.txt
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
- name: Build
run: go mod download; go build -v ./...
tests:
name: Tests
needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
- name: Run tests
run: go mod download; go test -cover -coverprofile=./unit-cover.txt -race ./...
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./unit-cover.txt
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
47 changes: 47 additions & 0 deletions .golangci.yaml
@@ -0,0 +1,47 @@
run:
deadline: 5m
issues-exit-code: 1
skip-dirs:
- docs
- mocks
- scripts

output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true

linters-settings:
dupl:
threshold: 250
lll:
line-length: 160
goconst:
min-len: 2
min-occurrences: 3
errcheck:
exclude-functions:
- (io.Closer).Close
cyclop:
max-complexity: 10
funlen:
lines: 50

linters:
disable-all: true
enable:
- dupl
- errcheck
- goconst
- gosec
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
- funlen
- cyclop
- lll
- forbidigo

2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -2,6 +2,8 @@
[![codecov](https://codecov.io/github/yuseferi/zax/branch/codecov-integration/graph/badge.svg?token=64IHXT3ROF)](https://codecov.io/github/yuseferi/zax)
[![CodeQL](https://github.com/yuseferi/zax/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/yuseferi/zax/actions/workflows/github-code-scanning/codeql)
[![Check & Build](https://github.com/yuseferi/zax/actions/workflows/ci.yml/badge.svg)](https://github.com/yuseferi/zax/actions/workflows/ci.yml)
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/yuseferi/zax)

Basically this adds context to [Zap Logger](https://github.com/uber-go/zap), and make it easier to for the Gophers to do not generate logger boiler plates.
Passing logger as a parameter to function increase parameters functionalities and worse than couple lots of methods with a explicit dependency.
Expand Down

0 comments on commit 5825e5e

Please sign in to comment.