Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added golint pipeline #93

Merged
merged 12 commits into from
Feb 1, 2024
59 changes: 59 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: golangci-lint
on:
push:
branches:
- master
- main
pull_request:
types: [opened, edited, synchronize, reopened]

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read

# cancel the in-progress workflow when PR is refreshed.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true


jobs:
golangci:
name: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
working-directory:
- echo-sql
- gin-mongo
- gin-redis
- graphql-sql
- mux-sql
- S3-Keploy
- sse-svelte
- users-profile

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.54

# Optional: working directory, useful for monorepos
working-directory: ${{matrix.working-directory}}

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
install-mode: "goinstall"
57 changes: 57 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This is the configuration for golangci-lint for the restic project.
#
# A sample config with all settings is here:
# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml

linters:
# only enable the linters listed below
disable-all: true
enable:
# make sure all errors returned by functions are handled
- errcheck

# find unused code
- deadcode

# show how code can be simplified
- gosimple

# # make sure code is formatted
- gofmt

# examine code and report suspicious constructs, such as Printf calls whose
# arguments do not align with the format string
- govet

# make sure names and comments are used according to the conventions
- revive

# detect when assignments to existing variables are not used
- ineffassign

# run static analysis and find errors
- staticcheck

# find unused variables, functions, structs, types, etc.
- unused

# find unused struct fields
- structcheck

# find unused global variables
- varcheck

# parse and typecheck code
- typecheck

issues:
# don't use the default exclude rules, this hides (among others) ignored
# errors from Close() calls
exclude-use-default: false

# list of things to not warn about
exclude:
# revive: do not warn about missing comments for exported stuff
- exported (function|method|var|type|const) .* should have comment or be unexported
# revive: ignore constants in all caps
- don't use ALL_CAPS in Go names; use CamelCase