From 1c5b30b90104c979f2dcfe683015f6ed5ef609d3 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Tue, 20 Aug 2024 20:46:26 -0500 Subject: [PATCH 1/3] .golangci.yml: update rules --- .golangci.yml | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index fa06d088..824bcbe7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,6 +16,9 @@ linters: - whitespace - depguard - containedctx + - fatcontext + - mirror + - loggercheck linters-settings: exhaustive: default-signifies-exhaustive: true @@ -31,8 +34,21 @@ linters-settings: # - G304 # - G404 govet: - # report about shadowed variables - check-shadowing: true + enable: + - shadow + settings: + printf: + # Additionally check custom logger + funcs: + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Debugf + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Infof + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Warnf + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Errorf + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Panicf + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Fatalf + - (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).AssumptionViolationf + - (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Tracef + - (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Criticalf errorlint: # Allow formatting of errors without %w errorf: false @@ -111,6 +127,21 @@ linters-settings: desc: Use gopkg.in/guregu/null.v4 instead - pkg: "gopkg.in/guregu/null.v3" desc: Use gopkg.in/guregu/null.v4 instead + - pkg: github.com/go-gorm/gorm + desc: Use github.com/jmoiron/sqlx directly instead + loggercheck: + # Check that *w logging functions have even number of args (i.e., well formed key-value pairs). + rules: + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Debugw + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Infow + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Warnw + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Errorw + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Panicw + - (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Fatalw + - (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).AssumptionViolationw + - (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Tracew + - (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Criticalw + - (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).With issues: exclude-rules: - path: test From 814cf5788cb62681928ddebe7a393363f8a42033 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Wed, 21 Aug 2024 07:20:59 -0500 Subject: [PATCH 2/3] make nix-flake-update --- flake.lock | 58 +++++++++++------------------------------------------- 1 file changed, 12 insertions(+), 46 deletions(-) diff --git a/flake.lock b/flake.lock index a85f3d77..83b94c04 100644 --- a/flake.lock +++ b/flake.lock @@ -5,29 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -38,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1708807242, - "narHash": "sha256-sRTRkhMD4delO/hPxxi+XwLqPn8BuUq6nnj4JqLwOu0=", + "lastModified": 1723991338, + "narHash": "sha256-Grh5PF0+gootJfOJFenTTxDTYPidA3V28dqJ/WV7iis=", "owner": "nixos", "repo": "nixpkgs", - "rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a", + "rev": "8a3354191c0d7144db9756a74755672387b702ba", "type": "github" }, "original": { @@ -54,11 +36,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1706487304, - "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", + "lastModified": 1718428119, + "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", + "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5", "type": "github" }, "original": { @@ -77,15 +59,14 @@ }, "rust-overlay": { "inputs": { - "flake-utils": "flake-utils_2", "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1708913568, - "narHash": "sha256-76PGANC2ADf0h7fe0w2nWpfdGN+bemFs2rvW2EdU/ZY=", + "lastModified": 1724206841, + "narHash": "sha256-L8dKaX4T3k+TR2fEHCfGbH4UXdspovz/pj87iai9qmc=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "cbdf3e5bb205ff2ca165fe661fbd6d885cbd0106", + "rev": "45e98fbd62c32e5927e952d2833fa1ba4fb35a61", "type": "github" }, "original": { @@ -108,21 +89,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", From 83d5fbb72b29fecb174c96d4cfc111281644c04d Mon Sep 17 00:00:00 2001 From: Kristijan Rebernisak Date: Wed, 21 Aug 2024 14:32:23 +0200 Subject: [PATCH 3/3] Update golangci-lint Go dep to 1.22 --- shell.nix | 106 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 51 deletions(-) diff --git a/shell.nix b/shell.nix index ff471f28..5a18c699 100644 --- a/shell.nix +++ b/shell.nix @@ -1,7 +1,10 @@ -{ stdenv, pkgs, lib, scriptDir }: - -with pkgs; -let +{ + stdenv, + pkgs, + lib, + scriptDir, +}: +with pkgs; let go = pkgs.go_1_21; mkShell' = mkShell.override { @@ -9,50 +12,51 @@ let stdenv = pkgs.clangStdenv; }; in -mkShell' { - nativeBuildInputs = [ - stdenv.cc.cc.lib - (rust-bin.stable.latest.default.override { extensions = [ "rust-src" ]; }) - nodejs-18_x - (yarn.override { nodejs = nodejs-18_x; }) - nodePackages.typescript - nodePackages.typescript-language-server - nodePackages.npm - python3 - - python311Packages.ledgerwallet - go - - gopls - delve - (golangci-lint.override { buildGoModule = buildGo121Module; }) - gotools - - kubectl - kubernetes-helm - - postgresql_15 # psql - - ] ++ lib.optionals stdenv.isLinux [ - # ledger specific packages - libudev-zero - libusb1 - ]; - - LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.zlib stdenv.cc.cc.lib ]; # lib64 - - GOROOT = "${go}/share/go"; - CGO_ENABLED = 0; - HELM_REPOSITORY_CONFIG = "${scriptDir}/.helm-repositories.yaml"; - - shellHook = '' - # Update helm repositories - helm repo update > /dev/null - # setup go bin for nix - export GOBIN=$HOME/.nix-go/bin - mkdir -p $GOBIN - export PATH=$GOBIN:$PATH - # install gotestloghelper - go install github.com/smartcontractkit/chainlink-testing-framework/tools/gotestloghelper@latest - ''; -} + mkShell' { + nativeBuildInputs = + [ + stdenv.cc.cc.lib + (rust-bin.stable.latest.default.override {extensions = ["rust-src"];}) + nodejs-18_x + (yarn.override {nodejs = nodejs-18_x;}) + nodePackages.typescript + nodePackages.typescript-language-server + nodePackages.npm + python3 + + python311Packages.ledgerwallet + go + + gopls + delve + (golangci-lint.override {buildGoModule = buildGo122Module;}) + gotools + + kubectl + kubernetes-helm + + postgresql_15 # psql + ] + ++ lib.optionals stdenv.isLinux [ + # ledger specific packages + libudev-zero + libusb1 + ]; + + LD_LIBRARY_PATH = lib.makeLibraryPath [pkgs.zlib stdenv.cc.cc.lib]; # lib64 + + GOROOT = "${go}/share/go"; + CGO_ENABLED = 0; + HELM_REPOSITORY_CONFIG = "${scriptDir}/.helm-repositories.yaml"; + + shellHook = '' + # Update helm repositories + helm repo update > /dev/null + # setup go bin for nix + export GOBIN=$HOME/.nix-go/bin + mkdir -p $GOBIN + export PATH=$GOBIN:$PATH + # install gotestloghelper + go install github.com/smartcontractkit/chainlink-testing-framework/tools/gotestloghelper@latest + ''; + }