diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..28ca811 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -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 \ No newline at end of file diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..b5b4f36 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -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 \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..cf46821 --- /dev/null +++ b/.github/workflows/test.yaml @@ -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 \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..b027a6e --- /dev/null +++ b/.golangci.yml @@ -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 \ No newline at end of file