From df37fc5e7ff75d28946f66f442dc171a7e0696ba Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Tue, 27 Aug 2024 14:40:56 +0200 Subject: [PATCH] install golangci-lint manually in nix --- .githooks/go-lint | 2 +- .github/workflows/seth-lint.yml | 58 +++++--------------------- seth/.golangci.yml | 6 ++- seth/examples_wasp/client_wasp_test.go | 2 +- seth/shell.nix | 6 ++- shell.nix | 2 +- 6 files changed, 24 insertions(+), 52 deletions(-) diff --git a/.githooks/go-lint b/.githooks/go-lint index f2f2c4879..131c80c48 100755 --- a/.githooks/go-lint +++ b/.githooks/go-lint @@ -7,7 +7,7 @@ find "./" -type f -name 'go.mod' -print0 | while IFS= read -r -d $'\0' file; do # Run linter and capture exit status set +e - golangci-lint run + golangci-lint run -v linting_result=$? set -e diff --git a/.github/workflows/seth-lint.yml b/.github/workflows/seth-lint.yml index 32f8d866c..a9712b1d3 100644 --- a/.github/workflows/seth-lint.yml +++ b/.github/workflows/seth-lint.yml @@ -4,14 +4,14 @@ on: permissions: contents: read jobs: - tools: - name: Get tool-versions + golangci: + defaults: + run: + working-directory: seth + name: lint runs-on: ubuntu-latest - outputs: - golangci-lint-version: ${{ steps.tool-versions.outputs.golangci-lint_version }} - should_run: ${{ steps.changes.outputs.src }} steps: - - name: Check out Code + - name: Checkout repo uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Check for changes in Seth project uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 @@ -20,47 +20,11 @@ jobs: filters: | src: - 'seth/**' - - name: Parse tool-versions file + - uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26 if: steps.changes.outputs.src == 'true' - uses: smartcontractkit/tool-versions-to-env-action@aabd5efbaf28005284e846c5cf3a02f2cba2f4c2 # v1.0.8 - id: tool-versions - - golangci: - name: Linting Seth - if: needs.tools.outputs.should_run == 'true' - runs-on: ubuntu-latest - needs: [tools] - steps: - - name: Check out Code - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - - name: Install Go - uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/setup-go@e29366cdecfe6befff9ab8c3cfe4825218505d58 # v2.3.16 - with: - test_download_vendor_packages_command: cd seth && go mod download - go_mod_path: seth/go.mod - cache_key_id: ctf-go-seth - cache_restore_only: 'false' - - name: golangci-lint ${{ needs.tools.outputs.golangci-lint-version }} - uses: golangci/golangci-lint-action@9d1e0624a798bb64f6c3cea93db47765312263dc # v5.1.0 with: - version: v${{ needs.tools.outputs.golangci-lint-version }} - args: --out-format checkstyle:golangci-lint-report.xml - skip-cache: true - working-directory: seth - - name: Print lint report artifact - if: always() - working-directory: seth - shell: bash + nix_path: nixpkgs=channel:nixos-unstable + - name: Lint + if: steps.changes.outputs.src == 'true' run: | - if test -f golangci-lint-report.xml; then - cat golangci-lint-report.xml - else - echo "No golangci-lint-report.xml file found" - fi - - - name: Store lint report artifact - if: always() - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 - with: - name: golangci-lint-report-seth - path: seth/golangci-lint-report.xml + nix develop -c make lint diff --git a/seth/.golangci.yml b/seth/.golangci.yml index 356d679d9..40c1198ce 100644 --- a/seth/.golangci.yml +++ b/seth/.golangci.yml @@ -79,4 +79,8 @@ linters-settings: - name: confusing-results - name: bool-literal-in-expr - name: atomic - +issues: + exclude-dirs: + - contracts/* + - examples/* + - examples_wasp/* diff --git a/seth/examples_wasp/client_wasp_test.go b/seth/examples_wasp/client_wasp_test.go index f71bca8d9..e8bcd824b 100644 --- a/seth/examples_wasp/client_wasp_test.go +++ b/seth/examples_wasp/client_wasp_test.go @@ -24,7 +24,7 @@ func NewExampleHTTPGun(client *seth.Client) *ExampleGun { } } -func (m *ExampleGun) Call(l *wasp.Generator) *wasp.Response { +func (m *ExampleGun) Call(_ *wasp.Generator) *wasp.Response { _, err := m.client.Decode( TestEnv.DebugContract.AddCounter(m.client.NewTXKeyOpts(m.client.AnySyncedKey()), big.NewInt(0), big.NewInt(1)), ) diff --git a/seth/shell.nix b/seth/shell.nix index f484a8708..d8e0d77bd 100644 --- a/seth/shell.nix +++ b/seth/shell.nix @@ -8,7 +8,6 @@ pkgs.mkShell { go gopls delve - golangci-lint gotools jq ]; @@ -17,5 +16,10 @@ pkgs.mkShell { shellHook = '' solc-select install 0.8.19 solc-select use 0.8.19 + # setup go bin for nix + export GOBIN=$HOME/.nix-go/bin + mkdir -p $GOBIN + export PATH=$GOBIN:$PATH + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2 ''; } diff --git a/shell.nix b/shell.nix index 038c714b5..6fee5c9e3 100644 --- a/shell.nix +++ b/shell.nix @@ -33,7 +33,6 @@ mkShell' { gotools gopls delve - golangci-lint github-cli jq dasel @@ -70,5 +69,6 @@ mkShell' { export PATH=$GOBIN:$PATH # install gotestloghelper go install github.com/smartcontractkit/chainlink-testing-framework/tools/gotestloghelper@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2 ''; }