From 5c2f2e3cc71a71ca0c87f45b0013dd66e7a66744 Mon Sep 17 00:00:00 2001 From: Elitsa Pavlova Date: Wed, 5 Apr 2023 18:41:02 +0300 Subject: [PATCH 1/4] Deploy the orb on production on tag release The deploy on production orb registry should be triggered on tag release. So the continue step in the orb CI/CD should be triggered on branch changes as well as tag release. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fcd7aa3..d0d22de 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -47,4 +47,4 @@ workflows: context: cm-team-orb-publishing requires: - publish-dev - filters: *only_branches + filters: *tags_and_branches From dc597eb175a0752028eac61e9a31b6d0a8e20fc4 Mon Sep 17 00:00:00 2001 From: Elitsa Pavlova Date: Wed, 5 Apr 2023 19:00:33 +0300 Subject: [PATCH 2/4] Move linters config file to the orb repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the param "golang-config" is has value different than empty string, the orb lint step will keep its behaviour as before. The linters config will obtained from this param. The golang-config should specify url from which the config can be downloaded via wget. However, now by default the golangci-config param is empty string and the linters config file will be copied from the orb repo to the CricleCI job executor’s filesystem. --- src/commands/lint.yml | 23 +++++++++++---- src/conf/.golangci.yml | 56 +++++++++++++++++++++++++++++++++++++ src/jobs/build-and-test.yml | 4 +-- 3 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 src/conf/.golangci.yml diff --git a/src/commands/lint.yml b/src/commands/lint.yml index 724360a..1d94378 100644 --- a/src/commands/lint.yml +++ b/src/commands/lint.yml @@ -7,13 +7,24 @@ parameters: description: > Location for golangci config file to be used (downloaded with wget) type: string - default: - "https://raw.githubusercontent.com/Financial-Times/upp-coding-standard/\ - v1.3.2/golangci-config/.golangci.yml" + default: "" steps: - - run: - name: Download linters' config file - command: wget <> + - when: + condition: <> + steps: + - run: + name: Download linters' config file if given as parameter + command: wget -O .golangci.yml <> + - unless: + condition: <> + steps: + - run: + name: > + Copy linters' config file from orb source code into + the job executor’s filesystem + environment: + CONFIG_CONTENT: <> + command: /bin/echo "$CONFIG_CONTENT" > .golangci.yml - run: name: Run linters environment: diff --git a/src/conf/.golangci.yml b/src/conf/.golangci.yml new file mode 100644 index 0000000..4be1e83 --- /dev/null +++ b/src/conf/.golangci.yml @@ -0,0 +1,56 @@ +linters-settings: + govet: + check-shadowing: true + settings: + printf: + funcs: + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf + revive: + confidence: 0 + gocognit: + min-complexity: 20 + +linters: + disable-all: true + enable: + - bodyclose + - deadcode + - errcheck + - gocognit + - gofmt + - goimports + - gosec + - gosimple + - govet + - ineffassign + - misspell + - revive + - staticcheck + - structcheck + - stylecheck + - typecheck + - unparam + - unused + - varcheck + - whitespace + +run: + skip-dirs: + - test/testdata_etc + - pkg/golinters/goanalysis/(checker|passes) + +issues: + exclude-rules: + - text: "weak cryptographic primitive" + linters: + - gosec + +# golangci.com configuration +# https://github.com/golangci/golangci/wiki/Configuration +service: + golangci-lint-version: 1.17.x # use the fixed version to not introduce new linters unexpectedly + prepare: + - echo "here I can run custom commands, but no preparation needed for this repo" diff --git a/src/jobs/build-and-test.yml b/src/jobs/build-and-test.yml index 3cd8291..06da5c6 100644 --- a/src/jobs/build-and-test.yml +++ b/src/jobs/build-and-test.yml @@ -16,9 +16,7 @@ parameters: description: > Location for golangci config file to be used (downloaded with wget) type: string - default: - "https://raw.githubusercontent.com/Financial-Times/upp-coding-standard/\ - v1.3.2/golangci-config/.golangci.yml" + default: "" coverage-report-folder: description: Folder to temporarily store coverage results type: string From a9ce3d1171fd1bcc1536db97d9e3c3347b3a1fa6 Mon Sep 17 00:00:00 2001 From: Elitsa Pavlova Date: Wed, 5 Apr 2023 19:08:58 +0300 Subject: [PATCH 3/4] Fix yml linter errors in linters conf --- src/conf/.golangci.yml | 53 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/conf/.golangci.yml b/src/conf/.golangci.yml index 4be1e83..8954e60 100644 --- a/src/conf/.golangci.yml +++ b/src/conf/.golangci.yml @@ -4,10 +4,10 @@ linters-settings: settings: printf: funcs: - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf revive: confidence: 0 gocognit: @@ -16,26 +16,26 @@ linters-settings: linters: disable-all: true enable: - - bodyclose - - deadcode - - errcheck - - gocognit - - gofmt - - goimports - - gosec - - gosimple - - govet - - ineffassign - - misspell - - revive - - staticcheck - - structcheck - - stylecheck - - typecheck - - unparam - - unused - - varcheck - - whitespace + - bodyclose + - deadcode + - errcheck + - gocognit + - gofmt + - goimports + - gosec + - gosimple + - govet + - ineffassign + - misspell + - revive + - staticcheck + - structcheck + - stylecheck + - typecheck + - unparam + - unused + - varcheck + - whitespace run: skip-dirs: @@ -51,6 +51,7 @@ issues: # golangci.com configuration # https://github.com/golangci/golangci/wiki/Configuration service: - golangci-lint-version: 1.17.x # use the fixed version to not introduce new linters unexpectedly + # use the fixed version to not introduce new linters unexpectedly + golangci-lint-version: 1.17.x prepare: - - echo "here I can run custom commands, but no preparation needed for this repo" + - echo "here I can run custom commands" From 89534b4394b1f86a02f326ec258fd7a159ca0347 Mon Sep 17 00:00:00 2001 From: Elitsa Pavlova Date: Wed, 5 Apr 2023 19:28:43 +0300 Subject: [PATCH 4/4] Remove deprecated linters from config --- src/conf/.golangci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/conf/.golangci.yml b/src/conf/.golangci.yml index 8954e60..066a5de 100644 --- a/src/conf/.golangci.yml +++ b/src/conf/.golangci.yml @@ -17,7 +17,6 @@ linters: disable-all: true enable: - bodyclose - - deadcode - errcheck - gocognit - gofmt @@ -29,12 +28,10 @@ linters: - misspell - revive - staticcheck - - structcheck - stylecheck - typecheck - unparam - unused - - varcheck - whitespace run: