From b2176a175d4412f17d9af3b6b7c6addb99f8e86f Mon Sep 17 00:00:00 2001 From: Stas Date: Mon, 13 Jan 2020 19:56:56 +0300 Subject: [PATCH] Use golangci lint action (#549) * Use action insted download binary file * Update ci * Add config option * Use pre-built docker image for golangci-lint-action * Remove pre build docker action * Update action name * Remove env * Update ci file * Add working directory * Change GITHUB_WORKSPACE * Update ci file * Fix ci * Comment golangci-lint-action * Update working-directory * Fix path * Update ci-build.yml * Update path * Revert changes * Update .golangci.yml * Add new path for triggers ci * Separate steps * Add working-directory * Add test pwd and ls * Fix working directory * Update script for linting in Dockerfile * Move .golangci.yml to dir backend * Delete unnecessary word * Remove multiline string * Reformat multiline strings to single * Update disable-all option --- .github/workflows/ci-build.yml | 2 +- .github/workflows/ci-test-backend.yml | 26 +++++++++++--------------- Dockerfile | 5 +---- backend/.golangci.yml | 22 ++++++++++++++++++++++ 4 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 backend/.golangci.yml diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index fa842678..924debe2 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: build docker image run: docker build --build-arg SKIP_BACKEND_TEST=true --build-arg SKIP_FRONTEND_TEST=true --build-arg CI=github . diff --git a/.github/workflows/ci-test-backend.yml b/.github/workflows/ci-test-backend.yml index 983864a6..04d0aef8 100644 --- a/.github/workflows/ci-test-backend.yml +++ b/.github/workflows/ci-test-backend.yml @@ -8,18 +8,20 @@ on: - '.github/workflows/ci-test-backend.yml' - 'backend/**' - '!backend/scripts/**' + - '.golangci.yml' pull_request: paths: - '.github/workflows/ci-test-backend.yml' - 'backend/**' - '!backend/scripts/**' + - '.golangci.yml' jobs: backend: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: debug if needed run: | @@ -51,21 +53,15 @@ jobs: go get -u github.com/mattn/goveralls - name: run backend linters - run: | - cd backend - $GITHUB_WORKSPACE/golangci-lint run --out-format=tab --disable-all --tests=false --enable=unconvert \ - --enable=megacheck --enable=structcheck --enable=gas --enable=gocyclo --enable=dupl --enable=misspell \ - --enable=unparam --enable=varcheck --enable=deadcode --enable=typecheck \ - --enable=ineffassign --enable=varcheck ./... ; - cd _example/memory_store - $GITHUB_WORKSPACE/golangci-lint run --out-format=tab --disable-all --tests=false --enable=unconvert \ - --enable=megacheck --enable=structcheck --enable=gas --enable=gocyclo --enable=dupl --enable=misspell \ - --enable=unparam --enable=varcheck --enable=deadcode --enable=typecheck \ - --enable=ineffassign --enable=varcheck ./... ; + run: $GITHUB_WORKSPACE/golangci-lint run --config .golangci.yml ./... + working-directory: backend + + - name: run linters for examples + run: $GITHUB_WORKSPACE/golangci-lint run --config ${GITHUB_WORKSPACE}/backend/.golangci.yml ./... + working-directory: backend/_example/memory_store - name: submit coverage - run: | - cd backend - $(go env GOPATH)/bin/goveralls -service="github" -coverprofile=$GITHUB_WORKSPACE/profile.cov + run: $(go env GOPATH)/bin/goveralls -service="github" -coverprofile=$GITHUB_WORKSPACE/profile.cov + working-directory: backend env: COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile index 0bdf7a1c..91781287 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,10 +22,7 @@ RUN \ if [ -z "$SKIP_BACKEND_TEST" ] ; then \ go test -p 1 -timeout="${BACKEND_TEST_TIMEOUT:-300s}" -covermode=count -coverprofile=/profile.cov_tmp ./... && \ cat /profile.cov_tmp | grep -v "_mock.go" > /profile.cov ; \ - golangci-lint run --out-format=tab --disable-all --tests=false --enable=unconvert \ - --enable=megacheck --enable=structcheck --enable=gas --enable=gocyclo --enable=dupl --enable=misspell \ - --enable=unparam --enable=varcheck --enable=deadcode --enable=typecheck \ - --enable=ineffassign --enable=varcheck ./... ; \ + golangci-lint run --config .golangci.yml ./... ; \ else echo "skip backend tests and linter" ; fi # if DRONE presented use DRONE_* git env to make version diff --git a/backend/.golangci.yml b/backend/.golangci.yml new file mode 100644 index 00000000..c1a09b35 --- /dev/null +++ b/backend/.golangci.yml @@ -0,0 +1,22 @@ +run: + tests: false + output: + format: tab + skip-dirs: + - vendor +linters: + enable: + - unconvert + - megacheck + - structcheck + - gas + - gocyclo + - dupl + - misspell + - unparam + - varcheck + - deadcode + - typecheck + - ineffassign + - varcheck + disable-all: true