Skip to content

Commit

Permalink
add ci task for error check linters (#1327)
Browse files Browse the repository at this point in the history
Adds a CI task to ensure SDK implementation checks for errors
  • Loading branch information
skotambkar committed Jul 29, 2021
1 parent 17a3908 commit 4b1cbb9
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: golangci-lint
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
golangci:
name: lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.16.x]
os: [ubuntu-latest] # other options: macos-latest, windows-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version
version: latest
# the following causes golangci-init to do nothing, so all it does is install golang and golangci
args: --version
# Show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
- name: run ci linter
run: make ci-lint
27 changes: 27 additions & 0 deletions .golangci.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[run]
concurrency = 4
timeout = "1m"
issues-exit-code = 0
modules-download-mode = "readonly"
allow-parallel-runners = true
skip-dirs = ["internal/repotools"]
skip-dirs-use-default = true

[output]
format = "github-actions"

[linters-settings.cyclop]
skip-tests = false

[linters-settings.errcheck]
check-blank = true

[linters]
disable-all = true
enable = ["errcheck"]
fast = false

[issues]
exclude-use-default = false

# Refer config definitions at https://golangci-lint.run/usage/configuration/#config-file
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,27 @@ ci-test-generate-validate:
if [ "$$gitstatus" != "" ] && [ "$$gitstatus" != "skipping validation" ]; then echo "$$gitstatus"; exit 1; fi
git update-index --no-assume-unchanged go.mod go.sum

ci-lint: ci-lint-.

ci-lint-%:
@# Run golangci-lint command that uses the pattern to define the root path that the
@# module check will start from. Strips off the "ci-lint-" and
@# replaces all "_" with "/".
@#
@# e.g. ci-lint-internal_protocoltest
cd ./internal/repotools/cmd/eachmodule \
&& go run . -p $(subst _,/,$(subst ci-lint-,,$@)) \
-fail-fast=false \
-c 1 \
-skip="internal/repotools" \
"golangci-lint run"

ci-lint-install:
@# Installs golangci-lint at GoPATH.
@# This should be used to run golangci-lint locally.
@#
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

#######################
# Integration Testing #
#######################
Expand Down

0 comments on commit 4b1cbb9

Please sign in to comment.