From 7c312ded6d1499def169a1845bef7c52cb1eae5b Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Thu, 11 May 2023 14:35:20 +0200 Subject: [PATCH 01/38] SonarQube initial setup --- .github/workflows/golangci-lint.yml | 39 ------ .github/workflows/relay.yml | 30 ----- .../unit-testing-and-static-analysis.yml | 117 ++++++++++++++++++ sonar-project.properties | 12 ++ 4 files changed, 129 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/golangci-lint.yml delete mode 100644 .github/workflows/relay.yml create mode 100644 .github/workflows/unit-testing-and-static-analysis.yml create mode 100644 sonar-project.properties diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml deleted file mode 100644 index 51afde8c1..000000000 --- a/.github/workflows/golangci-lint.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: golangci_lint - -on: - pull_request: - -jobs: - golang_lint: - name: Golang Lint - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 - id: tool-versions - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version-file: "go.mod" - check-latest: true - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v${{ steps.tool-versions.outputs.golangci-lint_version }} - - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - args: --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s - - # Optional: show only new issues if it's a pull request. The default value is `false`. - only-new-issues: true - - # Optional: if set to true then the action don't cache or restore ~/go/pkg. - # skip-pkg-cache: true - - # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. - # skip-build-cache: true diff --git a/.github/workflows/relay.yml b/.github/workflows/relay.yml deleted file mode 100644 index aab772234..000000000 --- a/.github/workflows/relay.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: relay - -on: - pull_request: - -jobs: - relay_run_unit_tests: - name: Relay Run Unit Tests - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - name: Setup go - uses: actions/setup-go@v3 - with: - go-version-file: "go.mod" - check-latest: true - - name: Check go mod tidy - run: | - go mod tidy - echo "if this fails run 'go mod tidy' to fix" - git diff --stat --exit-code - - name: Install Solana CLI - run: ./scripts/install-solana-ci.sh - - name: Build - run: go build -v ./pkg/... - - name: Test - run: go test ./pkg/... -v -tags integration - - name: Test with the race detector enabled - run: go test ./pkg/... -v -race -count=10 -timeout=15m diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml new file mode 100644 index 000000000..0e7455f6e --- /dev/null +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -0,0 +1,117 @@ +name: Unit testing and static analysis + +on: + pull_request: + +jobs: + tools: + name: Get tool-versions + runs-on: ubuntu-latest + steps: + - name: Check out Code + uses: actions/checkout@v3 + - name: Parse tool-versions file + uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 + id: tool-versions + outputs: + go-version: ${{ steps.tool-versions.outputs.golang_version }} + golangci-lint-version: ${{ steps.tool-versions.outputs.golangci-lint_version }} + golangci: + name: Golangci Linting + runs-on: ubuntu-latest + needs: [tools] + steps: + - name: Check out Code + uses: actions/checkout@v3 + - name: Install Go ${{ needs.tools.outputs.go-version }} + uses: actions/setup-go@v4 + with: + go-version: ${{ needs.tools.outputs.go-version }} + - name: golangci-lint ${{ needs.tools.outputs.golangci-lint-version }} + ## + # XXX: change this to the official action once multiple --out-format args are supported. + # See: https://github.com/golangci/golangci-lint-action/issues/612 + ## + uses: smartcontractkit/golangci-lint-action@54ab6c5f11d66a92d14c3f7cc41ea13f676644bd # feature/multiple-output-formats-backup + with: + version: v${{ needs.tools.outputs.golangci-lint-version }} # keep golangci-lint 1.51.1 for multiple --out-format + allow-extra-out-format-args: true + args: | + --out-format checkstyle:golangci-lint-report.xml + --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s + only-new-issues: true + - name: Print lint report artifact + if: always() + run: test -f golangci-lint-report.xml || true + - name: Store lint report artifact + if: always() + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + with: + name: golangci-lint-report + path: golangci-lint-report.xml + + relay_run_unit_tests: + name: Relay Run Unit Tests + runs-on: ubuntu-latest + needs: [tools] + steps: + - name: Checkout sources + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - name: Setup go ${{ needs.tools.outputs.go-version }} + uses: actions/setup-go@v4 + with: + # go-version-file: "go.mod" + check-latest: true + go-version: ${{ needs.tools.outputs.go-version }} + - name: Check go mod tidy + run: | + go mod tidy + echo "if this fails run 'go mod tidy' to fix" + git diff --stat --exit-code + - name: Install Solana CLI + run: ./scripts/install-solana-ci.sh + - name: Build + run: go build -v ./pkg/... + - name: Test + run: go test ./pkg/... -v -tags integration -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt $1 | tee $OUTPUT_FILE + - name: Upload Go test results + if: always() + uses: actions/upload-artifact@v3 + with: + name: go-test-results + path: | + ./output.txt + ./coverage.txt + - name: Test with the race detector enabled + run: go test ./pkg/... -v -race -count=10 -timeout=15m + + sonarqube: + name: SonarQube Scan + needs: [golangci, relay_run_unit_tests] + runs-on: ubuntu-latest + if: ${{ always() }} + steps: + - name: Fetch blame information + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + with: + fetch-depth: 0 # fetches all history for all tags and branches to provide more metadata for sonar reports + - name: Download all workflow run artifacts + uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 + - name: Set SonarQube Report Paths + id: sonarqube_report_paths + shell: bash + run: | + echo "sonarqube_tests_report_paths=$(find go-test-results -name output.txt | paste -sd "," -)" >> $GITHUB_OUTPUT + echo "sonarqube_coverage_report_paths=$(find go-test-results -name coverage.txt | paste -sd "," -)" >> $GITHUB_OUTPUT + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0 + with: + args: > + -Dsonar.go.tests.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_tests_report_paths }} + -Dsonar.go.coverage.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_coverage_report_paths }} + -Dsonar.go.golangci-lint.reportPaths=golangci-lint-report/golangci-lint-report.xml + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + + \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..b57b957a0 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.projectKey=smartcontractkit_chainlink-solana # required (may be found under "Project Information" in Sonar) +sonar.sources=. + +# Full exclusions from the static analysis +sonar.exclusions=**/node_modules/**/*, **/mocks/**/*, **/testdata/**/*, **/contracts/typechain/**/*, **/contracts/artifacts/**/*, **/contracts/cache/**/*, **/contracts/scripts/**/*, **/generated/**/*, **/fixtures/**/*, **/docs/**/*, **/tools/**/*, **/*.pb.go, **/*report.xml, **/*.config.ts, **/*.txt, **/*.abi, **/*.bin +# Coverage exclusions +sonar.coverage.exclusions=**/*.test.ts, **/*_test.go, **/contracts/test/**/*, **/contracts/**/tests/**/*, **/integration-tests/**/* + +# Tests' root folder, inclusions (tests to check and count) and exclusions +sonar.tests=. +sonar.test.inclusions=**/*_test.go, **/*.test.ts +sonar.test.exclusions=**/integration-tests/* \ No newline at end of file From 4b7ddd737731a14c6344bfdf6e5f701fc8de0a1c Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Thu, 11 May 2023 14:55:16 +0200 Subject: [PATCH 02/38] Add on push to workflow --- .github/workflows/unit-testing-and-static-analysis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml index 0e7455f6e..1639b4ff0 100644 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -1,6 +1,9 @@ name: Unit testing and static analysis on: + push: + branches: + - develop pull_request: jobs: From 508b53e66848f209c171adee51b7e0c4c80dda47 Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Thu, 11 May 2023 15:33:13 +0200 Subject: [PATCH 03/38] Adjust styling --- sonar-project.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index b57b957a0..1450e60ce 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,4 +1,5 @@ -sonar.projectKey=smartcontractkit_chainlink-solana # required (may be found under "Project Information" in Sonar) +# required (may be found under "Project Information" in Sonar) +sonar.projectKey=smartcontractkit_chainlink-solana sonar.sources=. # Full exclusions from the static analysis From 8c9ebcc4c337504c3ea433cfd459b5fd4d2dd3a7 Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Thu, 11 May 2023 16:00:52 +0200 Subject: [PATCH 04/38] Adjust typo --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 1450e60ce..93f25a38d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,4 +1,4 @@ -# required (may be found under "Project Information" in Sonar) +# required (may be found under "Project Information" in SonarQube) sonar.projectKey=smartcontractkit_chainlink-solana sonar.sources=. From 71126df73471f2bc0c6d88c22a78acffb79debf4 Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Thu, 11 May 2023 16:54:58 +0200 Subject: [PATCH 05/38] Remove args multiline --- .github/workflows/unit-testing-and-static-analysis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml index 1639b4ff0..65bbbc786 100644 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -39,9 +39,7 @@ jobs: with: version: v${{ needs.tools.outputs.golangci-lint-version }} # keep golangci-lint 1.51.1 for multiple --out-format allow-extra-out-format-args: true - args: | - --out-format checkstyle:golangci-lint-report.xml - --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s + args: --out-format checkstyle:golangci-lint-report.xml --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s only-new-issues: true - name: Print lint report artifact if: always() From f4988892c589f3d90d9301adf109aae8493c44b6 Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Wed, 14 Jun 2023 18:32:13 +0200 Subject: [PATCH 06/38] adjust sonar properties --- sonar-project.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 93f25a38d..73bfbd975 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,11 +3,11 @@ sonar.projectKey=smartcontractkit_chainlink-solana sonar.sources=. # Full exclusions from the static analysis -sonar.exclusions=**/node_modules/**/*, **/mocks/**/*, **/testdata/**/*, **/contracts/typechain/**/*, **/contracts/artifacts/**/*, **/contracts/cache/**/*, **/contracts/scripts/**/*, **/generated/**/*, **/fixtures/**/*, **/docs/**/*, **/tools/**/*, **/*.pb.go, **/*report.xml, **/*.config.ts, **/*.txt, **/*.abi, **/*.bin +sonar.exclusions=**/node_modules/**/*, **/contracts/artifacts/**/*, **/generated/**/*, **/docs/**/*, **/*.config.ts, **/*.config.js, **/*.txt # Coverage exclusions -sonar.coverage.exclusions=**/*.test.ts, **/*_test.go, **/contracts/test/**/*, **/contracts/**/tests/**/*, **/integration-tests/**/* +sonar.coverage.exclusions=**/*.test.ts, **/*_test.go, **/contracts/tests/**/*, **/integration-tests/**/* # Tests' root folder, inclusions (tests to check and count) and exclusions -sonar.tests=. -sonar.test.inclusions=**/*_test.go, **/*.test.ts +sonar.tests=contracts/tests, +sonar.test.inclusions=**/*_test.go, **/*.test.ts, **/*.spec.ts sonar.test.exclusions=**/integration-tests/* \ No newline at end of file From 0612f2b0c857f52fd962a977e301c0f596fd4e3a Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Mon, 19 Jun 2023 07:54:56 +0200 Subject: [PATCH 07/38] updated sonar workflow --- .github/workflows/unit-testing-and-static-analysis.yml | 8 +++++--- .tool-versions | 2 +- sonar-project.properties | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml index 65bbbc786..f4f8ecf75 100644 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -75,6 +75,8 @@ jobs: run: go build -v ./pkg/... - name: Test run: go test ./pkg/... -v -tags integration -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt $1 | tee $OUTPUT_FILE + - name: Test with the race detector enabled + run: go test ./pkg/... -v -race -count=10 -timeout=15m -coverpkg=./... -coverprofile=race_coverage.txt $1 | tee $OUTPUT_FILE - name: Upload Go test results if: always() uses: actions/upload-artifact@v3 @@ -83,8 +85,7 @@ jobs: path: | ./output.txt ./coverage.txt - - name: Test with the race detector enabled - run: go test ./pkg/... -v -race -count=10 -timeout=15m + ./race_coverage.txt sonarqube: name: SonarQube Scan @@ -104,13 +105,14 @@ jobs: run: | echo "sonarqube_tests_report_paths=$(find go-test-results -name output.txt | paste -sd "," -)" >> $GITHUB_OUTPUT echo "sonarqube_coverage_report_paths=$(find go-test-results -name coverage.txt | paste -sd "," -)" >> $GITHUB_OUTPUT + echo "sonarqube_golangci_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,")" >> $GITHUB_OUTPUT - name: SonarQube Scan uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0 with: args: > -Dsonar.go.tests.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_tests_report_paths }} -Dsonar.go.coverage.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_coverage_report_paths }} - -Dsonar.go.golangci-lint.reportPaths=golangci-lint-report/golangci-lint-report.xml + -Dsonar.go.golangci-lint.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_golangci_report_paths }} env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} diff --git a/.tool-versions b/.tool-versions index 685beb4c5..1de53f440 100644 --- a/.tool-versions +++ b/.tool-versions @@ -2,7 +2,7 @@ nodejs 16.13.2 yarn 1.22.19 rust 1.59.0 golang 1.20.1 -golangci-lint 1.51.1 +golangci-lint 1.52.1 pulumi 3.40.1 ginkgo 2.5.1 actionlint 1.6.22 diff --git a/sonar-project.properties b/sonar-project.properties index 73bfbd975..ad4c9d82e 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -8,6 +8,6 @@ sonar.exclusions=**/node_modules/**/*, **/contracts/artifacts/**/*, **/generated sonar.coverage.exclusions=**/*.test.ts, **/*_test.go, **/contracts/tests/**/*, **/integration-tests/**/* # Tests' root folder, inclusions (tests to check and count) and exclusions -sonar.tests=contracts/tests, -sonar.test.inclusions=**/*_test.go, **/*.test.ts, **/*.spec.ts +sonar.tests=. +sonar.test.inclusions=**/*_test.go, **/*.test.ts, **/contracts/tests/**/* sonar.test.exclusions=**/integration-tests/* \ No newline at end of file From 5f2b6a1028a81a69e3c481328585bfcaf2d80edd Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Mon, 19 Jun 2023 08:07:55 +0200 Subject: [PATCH 08/38] adjust for linting --- .../workflows/unit-testing-and-static-analysis.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml index f4f8ecf75..af7f38fe3 100644 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -74,9 +74,9 @@ jobs: - name: Build run: go build -v ./pkg/... - name: Test - run: go test ./pkg/... -v -tags integration -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt $1 | tee $OUTPUT_FILE + run: go test ./pkg/... -v -tags integration -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt "$1" | tee "$OUTPUT_FILE" - name: Test with the race detector enabled - run: go test ./pkg/... -v -race -count=10 -timeout=15m -coverpkg=./... -coverprofile=race_coverage.txt $1 | tee $OUTPUT_FILE + run: go test ./pkg/... -v -race -count=10 -timeout=15m -coverpkg=./... -coverprofile=race_coverage.txt "$1" | tee "$OUTPUT_FILE" - name: Upload Go test results if: always() uses: actions/upload-artifact@v3 @@ -103,9 +103,11 @@ jobs: id: sonarqube_report_paths shell: bash run: | - echo "sonarqube_tests_report_paths=$(find go-test-results -name output.txt | paste -sd "," -)" >> $GITHUB_OUTPUT - echo "sonarqube_coverage_report_paths=$(find go-test-results -name coverage.txt | paste -sd "," -)" >> $GITHUB_OUTPUT - echo "sonarqube_golangci_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,")" >> $GITHUB_OUTPUT + { + echo "sonarqube_tests_report_paths=$(find go-test-results -name output.txt | paste -sd "," -)" + echo "sonarqube_coverage_report_paths=$(find go-test-results -name coverage.txt | paste -sd "," -)" + echo "sonarqube_golangci_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,")" + } >> "$GITHUB_OUTPUT" - name: SonarQube Scan uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0 with: From ae9d438bcb931b21c18a5adaf88a4bcb3e3372f0 Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Mon, 19 Jun 2023 08:16:32 +0200 Subject: [PATCH 09/38] adjust for linting --- .github/workflows/unit-testing-and-static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml index af7f38fe3..83e120cc4 100644 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -106,7 +106,7 @@ jobs: { echo "sonarqube_tests_report_paths=$(find go-test-results -name output.txt | paste -sd "," -)" echo "sonarqube_coverage_report_paths=$(find go-test-results -name coverage.txt | paste -sd "," -)" - echo "sonarqube_golangci_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,")" + echo "sonarqube_golangci_report_paths=$(find go-test-results -name 'golangci-lint-report.xml' -printf "%p,")" } >> "$GITHUB_OUTPUT" - name: SonarQube Scan uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0 From b41789f2d576d2c50580c195be6db35b601dda0e Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Tue, 20 Jun 2023 11:50:12 +0200 Subject: [PATCH 10/38] remove unnecessary piped instruction --- .github/workflows/unit-testing-and-static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml index 83e120cc4..f4155be46 100644 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -74,7 +74,7 @@ jobs: - name: Build run: go build -v ./pkg/... - name: Test - run: go test ./pkg/... -v -tags integration -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt "$1" | tee "$OUTPUT_FILE" + run: go test ./pkg/... -v -tags integration -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt - name: Test with the race detector enabled run: go test ./pkg/... -v -race -count=10 -timeout=15m -coverpkg=./... -coverprofile=race_coverage.txt "$1" | tee "$OUTPUT_FILE" - name: Upload Go test results From 66bb9d14f9c80cf3f3f4fb38a514d9ede200a5c7 Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Thu, 22 Jun 2023 15:04:09 +0200 Subject: [PATCH 11/38] remove test.ts --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index ad4c9d82e..60246f6de 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -9,5 +9,5 @@ sonar.coverage.exclusions=**/*.test.ts, **/*_test.go, **/contracts/tests/**/*, * # Tests' root folder, inclusions (tests to check and count) and exclusions sonar.tests=. -sonar.test.inclusions=**/*_test.go, **/*.test.ts, **/contracts/tests/**/* +sonar.test.inclusions=**/*_test.go, **/contracts/tests/**/* sonar.test.exclusions=**/integration-tests/* \ No newline at end of file From ae0d8a4d870931a5b39c4c8c4077595dfb7435f4 Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Thu, 22 Jun 2023 15:07:26 +0200 Subject: [PATCH 12/38] rename golint step --- .github/workflows/unit-testing-and-static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml index f4155be46..61737892a 100644 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -20,7 +20,7 @@ jobs: go-version: ${{ steps.tool-versions.outputs.golang_version }} golangci-lint-version: ${{ steps.tool-versions.outputs.golangci-lint_version }} golangci: - name: Golangci Linting + name: Golang Lint runs-on: ubuntu-latest needs: [tools] steps: From e879e402ad6673fe37de82747fa3ff3cfb2ff1d6 Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Thu, 22 Jun 2023 15:10:02 +0200 Subject: [PATCH 13/38] remove write to output --- .github/workflows/unit-testing-and-static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml index 61737892a..7247bb5e0 100644 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -76,7 +76,7 @@ jobs: - name: Test run: go test ./pkg/... -v -tags integration -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt - name: Test with the race detector enabled - run: go test ./pkg/... -v -race -count=10 -timeout=15m -coverpkg=./... -coverprofile=race_coverage.txt "$1" | tee "$OUTPUT_FILE" + run: go test ./pkg/... -v -race -count=10 -timeout=15m -coverpkg=./... -coverprofile=race_coverage.txt - name: Upload Go test results if: always() uses: actions/upload-artifact@v3 From 893dd7b16e31e48a0092e72f2f29106c8687bc91 Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Thu, 22 Jun 2023 15:14:06 +0200 Subject: [PATCH 14/38] add wildcard --- .github/workflows/unit-testing-and-static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml index 7247bb5e0..460a8af4a 100644 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -105,7 +105,7 @@ jobs: run: | { echo "sonarqube_tests_report_paths=$(find go-test-results -name output.txt | paste -sd "," -)" - echo "sonarqube_coverage_report_paths=$(find go-test-results -name coverage.txt | paste -sd "," -)" + echo "sonarqube_coverage_report_paths=$(find go-test-results -name '*coverage.txt' | paste -sd "," -)" echo "sonarqube_golangci_report_paths=$(find go-test-results -name 'golangci-lint-report.xml' -printf "%p,")" } >> "$GITHUB_OUTPUT" - name: SonarQube Scan From 7c6b20302915d34d3e25fb3081899d7e5d4389c0 Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Thu, 22 Jun 2023 15:21:14 +0200 Subject: [PATCH 15/38] update find folder --- .github/workflows/unit-testing-and-static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml index 460a8af4a..0b5cf18f7 100644 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -106,7 +106,7 @@ jobs: { echo "sonarqube_tests_report_paths=$(find go-test-results -name output.txt | paste -sd "," -)" echo "sonarqube_coverage_report_paths=$(find go-test-results -name '*coverage.txt' | paste -sd "," -)" - echo "sonarqube_golangci_report_paths=$(find go-test-results -name 'golangci-lint-report.xml' -printf "%p,")" + echo "sonarqube_golangci_report_paths=$(find golangci-lint-report -name 'golangci-lint-report.xml' -printf "%p,")" } >> "$GITHUB_OUTPUT" - name: SonarQube Scan uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0 From b3b49ff1974407696ae14ae2cb6f63033d3c012a Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Thu, 22 Jun 2023 17:50:40 +0200 Subject: [PATCH 16/38] switch how we search for reports --- .github/workflows/unit-testing-and-static-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml index 0b5cf18f7..ab9c6a44e 100644 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ b/.github/workflows/unit-testing-and-static-analysis.yml @@ -104,9 +104,9 @@ jobs: shell: bash run: | { - echo "sonarqube_tests_report_paths=$(find go-test-results -name output.txt | paste -sd "," -)" - echo "sonarqube_coverage_report_paths=$(find go-test-results -name '*coverage.txt' | paste -sd "," -)" - echo "sonarqube_golangci_report_paths=$(find golangci-lint-report -name 'golangci-lint-report.xml' -printf "%p,")" + echo "sonarqube_tests_report_paths=$(find . -type f -name output.txt | paste -sd "," -)" + echo "sonarqube_coverage_report_paths=$(find . -type f -name '*coverage.txt' | paste -sd "," -)" + echo "sonarqube_golangci_report_paths=$(find . -type f -name 'golangci-lint-report.xml' -printf "%p,")" } >> "$GITHUB_OUTPUT" - name: SonarQube Scan uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0 From 83c50cca628ee703390af95b7b0eca6cd2486804 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Tue, 5 Sep 2023 12:21:38 +0200 Subject: [PATCH 17/38] Rebase --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 5354b62c1..eabeb68e7 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,9 @@ tests/e2e/smoke/contracts-chaos-state.json tmp-manifest-* tests-smoke-report.xml .env.test* + +# Test & linter reports +*report.xml +*report.json +*.out +*coverage* From a8f50d7aa897ae97971cbe34c1e006a31fd6de23 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Tue, 5 Sep 2023 12:44:31 +0200 Subject: [PATCH 18/38] Trying out sonar --- .github/workflows/golangci-lint.yml | 45 +++++++ .github/workflows/relay.yml | 39 ++++++ .github/workflows/sonar-scan.yml | 76 +++++++++++ .../unit-testing-and-static-analysis.yml | 122 ------------------ 4 files changed, 160 insertions(+), 122 deletions(-) create mode 100644 .github/workflows/golangci-lint.yml create mode 100644 .github/workflows/relay.yml create mode 100644 .github/workflows/sonar-scan.yml delete mode 100644 .github/workflows/unit-testing-and-static-analysis.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 000000000..17483a971 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,45 @@ +name: golangci_lint + +on: + pull_request: + +jobs: + golang_lint: + name: Golang Lint + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 + id: tool-versions + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version-file: "go.mod" + check-latest: true + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: v${{ steps.tool-versions.outputs.golangci-lint_version }} + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + args: --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s + + # Optional: show only new issues if it's a pull request. The default value is `false`. + only-new-issues: true + + # Optional: if set to true then the action don't cache or restore ~/go/pkg. + # skip-pkg-cache: true + + # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. + # skip-build-cache: true + - name: Store lint report artifact + if: always() + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + with: + name: golangci-lint-report + path: golangci-lint-report.xml \ No newline at end of file diff --git a/.github/workflows/relay.yml b/.github/workflows/relay.yml new file mode 100644 index 000000000..74c594767 --- /dev/null +++ b/.github/workflows/relay.yml @@ -0,0 +1,39 @@ +name: relay + +on: + pull_request: + +jobs: + relay_run_unit_tests: + name: Relay Run Unit Tests + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version-file: "go.mod" + check-latest: true + - name: Check go mod tidy + run: | + go mod tidy + echo "if this fails run 'go mod tidy' to fix" + git diff --stat --exit-code + - name: Install Solana CLI + run: ./scripts/install-solana-ci.sh + - name: Build + run: go build -v ./pkg/... + - name: Test + run: go test ./pkg/... -v -tags integration + - name: Test with the race detector enabled + run: go test ./pkg/... -v -race -count=10 -timeout=15m + - name: Upload Go test results + if: always() + uses: actions/upload-artifact@v3 + with: + name: go-test-results + path: | + ./output.txt + ./coverage.txt + ./race_coverage.txt \ No newline at end of file diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml new file mode 100644 index 000000000..c6f7e43ec --- /dev/null +++ b/.github/workflows/sonar-scan.yml @@ -0,0 +1,76 @@ +name: Unit testing and static analysis + +on: + push: + branches: + - develop + pull_request: + +jobs: + wait_for_workflows: + name: Wait for workflows + runs-on: ubuntu-latest + if: always() + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }} + + - name: Wait for Workflows + id: wait + uses: smartcontractkit/chainlink-github-actions/utils/wait-for-workflows@main + with: + max-timeout: "1200" + polling-interval: "30" + exclude-workflow-names: "Lint GH Workflows" + exclude-workflow-ids: "" + github-token: ${{ secrets.GITHUB_TOKEN }} + env: + DEBUG: "true" + tools: + name: Get tool-versions + runs-on: ubuntu-latest + steps: + - name: Check out Code + uses: actions/checkout@v3 + - name: Parse tool-versions file + uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 + id: tool-versions + outputs: + go-version: ${{ steps.tool-versions.outputs.golang_version }} + golangci-lint-version: ${{ steps.tool-versions.outputs.golangci-lint_version }} + + sonarqube: + name: SonarQube Scan + needs: [wait_for_workflows] + runs-on: ubuntu-latest + if: ${{ always() }} + steps: + - name: Fetch blame information + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + with: + fetch-depth: 0 # fetches all history for all tags and branches to provide more metadata for sonar reports + - name: Download all workflow run artifacts + uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 + - name: Set SonarQube Report Paths + id: sonarqube_report_paths + shell: bash + run: | + { + echo "sonarqube_tests_report_paths=$(find . -type f -name output.txt | paste -sd "," -)" + echo "sonarqube_coverage_report_paths=$(find . -type f -name '*coverage.txt' | paste -sd "," -)" + echo "sonarqube_golangci_report_paths=$(find . -type f -name 'golangci-lint-report.xml' -printf "%p,")" + } >> "$GITHUB_OUTPUT" + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0 + with: + args: > + -Dsonar.go.tests.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_tests_report_paths }} + -Dsonar.go.coverage.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_coverage_report_paths }} + -Dsonar.go.golangci-lint.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_golangci_report_paths }} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + + \ No newline at end of file diff --git a/.github/workflows/unit-testing-and-static-analysis.yml b/.github/workflows/unit-testing-and-static-analysis.yml deleted file mode 100644 index ab9c6a44e..000000000 --- a/.github/workflows/unit-testing-and-static-analysis.yml +++ /dev/null @@ -1,122 +0,0 @@ -name: Unit testing and static analysis - -on: - push: - branches: - - develop - pull_request: - -jobs: - tools: - name: Get tool-versions - runs-on: ubuntu-latest - steps: - - name: Check out Code - uses: actions/checkout@v3 - - name: Parse tool-versions file - uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 - id: tool-versions - outputs: - go-version: ${{ steps.tool-versions.outputs.golang_version }} - golangci-lint-version: ${{ steps.tool-versions.outputs.golangci-lint_version }} - golangci: - name: Golang Lint - runs-on: ubuntu-latest - needs: [tools] - steps: - - name: Check out Code - uses: actions/checkout@v3 - - name: Install Go ${{ needs.tools.outputs.go-version }} - uses: actions/setup-go@v4 - with: - go-version: ${{ needs.tools.outputs.go-version }} - - name: golangci-lint ${{ needs.tools.outputs.golangci-lint-version }} - ## - # XXX: change this to the official action once multiple --out-format args are supported. - # See: https://github.com/golangci/golangci-lint-action/issues/612 - ## - uses: smartcontractkit/golangci-lint-action@54ab6c5f11d66a92d14c3f7cc41ea13f676644bd # feature/multiple-output-formats-backup - with: - version: v${{ needs.tools.outputs.golangci-lint-version }} # keep golangci-lint 1.51.1 for multiple --out-format - allow-extra-out-format-args: true - args: --out-format checkstyle:golangci-lint-report.xml --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s - only-new-issues: true - - name: Print lint report artifact - if: always() - run: test -f golangci-lint-report.xml || true - - name: Store lint report artifact - if: always() - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 - with: - name: golangci-lint-report - path: golangci-lint-report.xml - - relay_run_unit_tests: - name: Relay Run Unit Tests - runs-on: ubuntu-latest - needs: [tools] - steps: - - name: Checkout sources - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - name: Setup go ${{ needs.tools.outputs.go-version }} - uses: actions/setup-go@v4 - with: - # go-version-file: "go.mod" - check-latest: true - go-version: ${{ needs.tools.outputs.go-version }} - - name: Check go mod tidy - run: | - go mod tidy - echo "if this fails run 'go mod tidy' to fix" - git diff --stat --exit-code - - name: Install Solana CLI - run: ./scripts/install-solana-ci.sh - - name: Build - run: go build -v ./pkg/... - - name: Test - run: go test ./pkg/... -v -tags integration -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt - - name: Test with the race detector enabled - run: go test ./pkg/... -v -race -count=10 -timeout=15m -coverpkg=./... -coverprofile=race_coverage.txt - - name: Upload Go test results - if: always() - uses: actions/upload-artifact@v3 - with: - name: go-test-results - path: | - ./output.txt - ./coverage.txt - ./race_coverage.txt - - sonarqube: - name: SonarQube Scan - needs: [golangci, relay_run_unit_tests] - runs-on: ubuntu-latest - if: ${{ always() }} - steps: - - name: Fetch blame information - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 - with: - fetch-depth: 0 # fetches all history for all tags and branches to provide more metadata for sonar reports - - name: Download all workflow run artifacts - uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 - - name: Set SonarQube Report Paths - id: sonarqube_report_paths - shell: bash - run: | - { - echo "sonarqube_tests_report_paths=$(find . -type f -name output.txt | paste -sd "," -)" - echo "sonarqube_coverage_report_paths=$(find . -type f -name '*coverage.txt' | paste -sd "," -)" - echo "sonarqube_golangci_report_paths=$(find . -type f -name 'golangci-lint-report.xml' -printf "%p,")" - } >> "$GITHUB_OUTPUT" - - name: SonarQube Scan - uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0 - with: - args: > - -Dsonar.go.tests.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_tests_report_paths }} - -Dsonar.go.coverage.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_coverage_report_paths }} - -Dsonar.go.golangci-lint.reportPaths=${{ steps.sonarqube_report_paths.outputs.sonarqube_golangci_report_paths }} - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - - \ No newline at end of file From b66ba8a02bb20e7c926ebdad8653b7d5b3caa911 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Tue, 5 Sep 2023 13:22:37 +0200 Subject: [PATCH 19/38] Removed integration tests --- .github/workflows/sonar-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index c6f7e43ec..ac4acc191 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -23,7 +23,7 @@ jobs: with: max-timeout: "1200" polling-interval: "30" - exclude-workflow-names: "Lint GH Workflows" + exclude-workflow-names: "Lint GH Workflows,e2e_tests_custom_cl" exclude-workflow-ids: "" github-token: ${{ secrets.GITHUB_TOKEN }} env: From 86b32c77640ff1829bac80fc0a2fc512dd06d11a Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Thu, 7 Sep 2023 15:12:46 +0200 Subject: [PATCH 20/38] Scan fix --- .github/workflows/sonar-scan.yml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index ac4acc191..d985f6121 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -51,8 +51,25 @@ jobs: uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 with: fetch-depth: 0 # fetches all history for all tags and branches to provide more metadata for sonar reports - - name: Download all workflow run artifacts - uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 + + - name: Download Golangci unit tests reports + uses: dawidd6/action-download-artifact@v2.27.0 + with: + workflow: relay.yml + workflow_conclusion: "" + name_is_regexp: true + name: go-test-results + if_no_artifact_found: warn + + - name: Download Golangci Relayer report + uses: dawidd6/action-download-artifact@v2.27.0 + with: + workflow: golangci-lint.yml + workflow_conclusion: "" + name_is_regexp: true + name: golangci-lint-report + if_no_artifact_found: warn + - name: Set SonarQube Report Paths id: sonarqube_report_paths shell: bash @@ -60,8 +77,9 @@ jobs: { echo "sonarqube_tests_report_paths=$(find . -type f -name output.txt | paste -sd "," -)" echo "sonarqube_coverage_report_paths=$(find . -type f -name '*coverage.txt' | paste -sd "," -)" - echo "sonarqube_golangci_report_paths=$(find . -type f -name 'golangci-lint-report.xml' -printf "%p,")" + echo "sonarqube_golangci_report_paths=$(find . -type f -name 'golangci-*-report.xml' -printf "%p,")" } >> "$GITHUB_OUTPUT" + - name: SonarQube Scan uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0 with: From 3942483954fac34adc0cfd2c457902480de6cce4 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Mon, 11 Sep 2023 08:16:20 +0200 Subject: [PATCH 21/38] Fixed naming --- .github/workflows/golangci-lint.yml | 2 +- .github/workflows/relay.yml | 2 +- .github/workflows/sonar-scan.yml | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 17483a971..e667a4366 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -42,4 +42,4 @@ jobs: uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 with: name: golangci-lint-report - path: golangci-lint-report.xml \ No newline at end of file + path: ./golangci-lint-report.xml \ No newline at end of file diff --git a/.github/workflows/relay.yml b/.github/workflows/relay.yml index 74c594767..72be3efa8 100644 --- a/.github/workflows/relay.yml +++ b/.github/workflows/relay.yml @@ -32,7 +32,7 @@ jobs: if: always() uses: actions/upload-artifact@v3 with: - name: go-test-results + name: go-relay-test-results path: | ./output.txt ./coverage.txt diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index d985f6121..81430e0e8 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -55,19 +55,19 @@ jobs: - name: Download Golangci unit tests reports uses: dawidd6/action-download-artifact@v2.27.0 with: - workflow: relay.yml + workflow: golangci-lint.yml workflow_conclusion: "" name_is_regexp: true - name: go-test-results + name: golangci-lint-report if_no_artifact_found: warn - name: Download Golangci Relayer report uses: dawidd6/action-download-artifact@v2.27.0 with: - workflow: golangci-lint.yml + workflow: relay.yml workflow_conclusion: "" name_is_regexp: true - name: golangci-lint-report + name: go-relay-test-results if_no_artifact_found: warn - name: Set SonarQube Report Paths From f0734ea248ba9bc839af308402bc516a3be3baff Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Mon, 11 Sep 2023 08:38:54 +0200 Subject: [PATCH 22/38] Changed file names --- .github/workflows/golangci-lint.yml | 14 -------------- .github/workflows/relay.yml | 6 +++--- sonar-project.properties | 3 +-- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index e667a4366..8e9f95930 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -20,23 +20,9 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version version: v${{ steps.tool-versions.outputs.golangci-lint_version }} - - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. args: --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s - - # Optional: show only new issues if it's a pull request. The default value is `false`. only-new-issues: true - - # Optional: if set to true then the action don't cache or restore ~/go/pkg. - # skip-pkg-cache: true - - # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. - # skip-build-cache: true - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 diff --git a/.github/workflows/relay.yml b/.github/workflows/relay.yml index 72be3efa8..950cee13d 100644 --- a/.github/workflows/relay.yml +++ b/.github/workflows/relay.yml @@ -25,9 +25,9 @@ jobs: - name: Build run: go build -v ./pkg/... - name: Test - run: go test ./pkg/... -v -tags integration + run: go test ./pkg/... -v -tags integration -covermode=atomic -coverpkg=./... -coverprofile=integration_coverage.txt - name: Test with the race detector enabled - run: go test ./pkg/... -v -race -count=10 -timeout=15m + run: go test ./pkg/... -v -race -count=10 -timeout=15m -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt - name: Upload Go test results if: always() uses: actions/upload-artifact@v3 @@ -36,4 +36,4 @@ jobs: path: | ./output.txt ./coverage.txt - ./race_coverage.txt \ No newline at end of file + ./integration_coverage.txt \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties index 60246f6de..d1cab62b6 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -9,5 +9,4 @@ sonar.coverage.exclusions=**/*.test.ts, **/*_test.go, **/contracts/tests/**/*, * # Tests' root folder, inclusions (tests to check and count) and exclusions sonar.tests=. -sonar.test.inclusions=**/*_test.go, **/contracts/tests/**/* -sonar.test.exclusions=**/integration-tests/* \ No newline at end of file +sonar.test.inclusions=**/*_test.go, **/contracts/tests/**/*, **/integration-tests/*, **/gauntlet/* \ No newline at end of file From 6c821074b73dd48f4c0e580c870cf0bc38c718ed Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Mon, 11 Sep 2023 09:32:31 +0200 Subject: [PATCH 23/38] Added gauntlet to ignore for sonar --- sonar-project.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index d1cab62b6..7f64da7db 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -9,4 +9,5 @@ sonar.coverage.exclusions=**/*.test.ts, **/*_test.go, **/contracts/tests/**/*, * # Tests' root folder, inclusions (tests to check and count) and exclusions sonar.tests=. -sonar.test.inclusions=**/*_test.go, **/contracts/tests/**/*, **/integration-tests/*, **/gauntlet/* \ No newline at end of file +sonar.test.inclusions=**/*_test.go, **/contracts/tests/**/* +sonar.test.exclusions=**/integration-tests/*, **/gauntlet/* \ No newline at end of file From 9e3da7f21a783de479118ff6b47f8c094c3028d9 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Mon, 11 Sep 2023 15:55:25 +0200 Subject: [PATCH 24/38] Added lint tests --- .github/workflows/golangci-lint.yml | 60 +++++++++++++++++++++++++---- .github/workflows/sonar-scan.yml | 24 ++++++++++-- Makefile | 12 ++++++ 3 files changed, 86 insertions(+), 10 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 8e9f95930..d41b1b1d4 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -4,8 +4,8 @@ on: pull_request: jobs: - golang_lint: - name: Golang Lint + golang_lint_ops: + name: Golang Lint Ops runs-on: ubuntu-latest steps: - name: Checkout sources @@ -20,12 +20,58 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v${{ steps.tool-versions.outputs.golangci-lint_version }} - args: --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s - only-new-issues: true + run: make lint-go-ops - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 with: - name: golangci-lint-report - path: ./golangci-lint-report.xml \ No newline at end of file + name: golangci-lint-ops-report + path: ./ops/golangci-lint-ops-report.xml + + golang_lint_integration_tests: + name: Golang Lint Integration Tests + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 + id: tool-versions + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version-file: "go.mod" + check-latest: true + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + run: make lint-go-integration-tests + - name: Store lint report artifact + if: always() + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + with: + name: golangci-lint-integration-tests-report + path: ./integration-tests/golangci-lint-integration-tests-report.xml + + golang_lint_relay: + name: Golang Lint Relay tests + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + - uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 + id: tool-versions + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version-file: "go.mod" + check-latest: true + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + run: make lint-go-relay + - name: Store lint report artifact + if: always() + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + with: + name: golangci-lint-relay-report + path: ./pkg/golangci-lint-relay-report.xml \ No newline at end of file diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 81430e0e8..bb1f39535 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -52,16 +52,34 @@ jobs: with: fetch-depth: 0 # fetches all history for all tags and branches to provide more metadata for sonar reports - - name: Download Golangci unit tests reports + - name: Download Golangci ops reports uses: dawidd6/action-download-artifact@v2.27.0 with: workflow: golangci-lint.yml workflow_conclusion: "" name_is_regexp: true - name: golangci-lint-report + name: golangci-lint-ops-report if_no_artifact_found: warn - - name: Download Golangci Relayer report + - name: Download Golangci integration tests reports + uses: dawidd6/action-download-artifact@v2.27.0 + with: + workflow: golangci-lint.yml + workflow_conclusion: "" + name_is_regexp: true + name: golangci-lint-integration-tests-report + if_no_artifact_found: warn + + - name: Download Golangci relay reports + uses: dawidd6/action-download-artifact@v2.27.0 + with: + workflow: golangci-lint.yml + workflow_conclusion: "" + name_is_regexp: true + name: golangci-lint-relay-report + if_no_artifact_found: warn + + - name: Download Relayer unit tests report uses: dawidd6/action-download-artifact@v2.27.0 with: workflow: relay.yml diff --git a/Makefile b/Makefile index 7ca729aa9..c19ab49ff 100644 --- a/Makefile +++ b/Makefile @@ -92,3 +92,15 @@ gomodtidy: go mod tidy cd ./integration-tests && go mod tidy cd ./ops && go mod tidy + +.PHONY: lint-go-ops +lint-go-ops: + cd ./ops && golangci-lint --color=always --out-format checkstyle:golangci-lint-ops-report.xml run + +.PHONY: lint-go-integration-tests +lint-go-integration-tests: + cd ./integration-tests && golangci-lint --color=always --out-format checkstyle:golangci-lint-integration-tests-report.xml run + +.PHONY: lint-go-relay +lint-go-relay: + cd ./pkg && golangci-lint --color=always --out-format checkstyle:golangci-lint-relay-report.xml run \ No newline at end of file From 77208545c8caa2a04baed664335b02e3efff8ba8 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Mon, 11 Sep 2023 16:02:43 +0200 Subject: [PATCH 25/38] Fixing broken yml --- .github/workflows/golangci-lint.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index d41b1b1d4..ac1c26b73 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -19,8 +19,7 @@ jobs: check-latest: true - name: golangci-lint uses: golangci/golangci-lint-action@v3 - with: - run: make lint-go-ops + run: make lint-go-ops - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 @@ -43,8 +42,7 @@ jobs: check-latest: true - name: golangci-lint uses: golangci/golangci-lint-action@v3 - with: - run: make lint-go-integration-tests + run: make lint-go-integration-tests - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 @@ -67,8 +65,7 @@ jobs: check-latest: true - name: golangci-lint uses: golangci/golangci-lint-action@v3 - with: - run: make lint-go-relay + run: make lint-go-relay - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 From 9cccd89a54a5b6879294c7bc4bcf21498868ceab Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Mon, 11 Sep 2023 16:09:03 +0200 Subject: [PATCH 26/38] fixed yml --- .github/workflows/golangci-lint.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index ac1c26b73..fd7d2df32 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -18,7 +18,6 @@ jobs: go-version-file: "go.mod" check-latest: true - name: golangci-lint - uses: golangci/golangci-lint-action@v3 run: make lint-go-ops - name: Store lint report artifact if: always() @@ -41,7 +40,6 @@ jobs: go-version-file: "go.mod" check-latest: true - name: golangci-lint - uses: golangci/golangci-lint-action@v3 run: make lint-go-integration-tests - name: Store lint report artifact if: always() @@ -64,7 +62,6 @@ jobs: go-version-file: "go.mod" check-latest: true - name: golangci-lint - uses: golangci/golangci-lint-action@v3 run: make lint-go-relay - name: Store lint report artifact if: always() From f686370a8bf7eacb8f661f56d1f2b5a78e9a4d29 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Mon, 11 Sep 2023 16:10:21 +0200 Subject: [PATCH 27/38] Rename --- .github/workflows/relay.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/relay.yml b/.github/workflows/relay.yml index 950cee13d..6d78c5747 100644 --- a/.github/workflows/relay.yml +++ b/.github/workflows/relay.yml @@ -27,7 +27,7 @@ jobs: - name: Test run: go test ./pkg/... -v -tags integration -covermode=atomic -coverpkg=./... -coverprofile=integration_coverage.txt - name: Test with the race detector enabled - run: go test ./pkg/... -v -race -count=10 -timeout=15m -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt + run: go test ./pkg/... -v -race -count=10 -timeout=15m -covermode=atomic -coverpkg=./... -coverprofile=race_coverage.txt - name: Upload Go test results if: always() uses: actions/upload-artifact@v3 From ab746bd5934ff376191b30c417ad9011ad6946fd Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Mon, 11 Sep 2023 16:13:31 +0200 Subject: [PATCH 28/38] Minor changes --- .github/workflows/relay.yml | 1 - .github/workflows/sonar-scan.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/relay.yml b/.github/workflows/relay.yml index 6d78c5747..4d483e11c 100644 --- a/.github/workflows/relay.yml +++ b/.github/workflows/relay.yml @@ -34,6 +34,5 @@ jobs: with: name: go-relay-test-results path: | - ./output.txt ./coverage.txt ./integration_coverage.txt \ No newline at end of file diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index bb1f39535..5d6dcd0c1 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -1,4 +1,4 @@ -name: Unit testing and static analysis +name: Static analysis on: push: From 1fa71cf337034693486da7ac34bac29b1ed97873 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Mon, 11 Sep 2023 16:19:40 +0200 Subject: [PATCH 29/38] Added nix to run lint tests --- .github/workflows/golangci-lint.yml | 39 +++++++++++------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index fd7d2df32..bdffc34e7 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -9,16 +9,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 - id: tool-versions - - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: Install Nix + uses: cachix/install-nix-action@29bd9290ef037a3ecbdafe83cbd2185e9dd0fa0a # v20 with: - go-version-file: "go.mod" - check-latest: true + nix_path: nixpkgs=channel:nixos-unstable - name: golangci-lint - run: make lint-go-ops + run: nix develop -c make lint-go-ops - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 @@ -31,16 +28,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 - id: tool-versions - - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: Install Nix + uses: cachix/install-nix-action@29bd9290ef037a3ecbdafe83cbd2185e9dd0fa0a # v20 with: - go-version-file: "go.mod" - check-latest: true + nix_path: nixpkgs=channel:nixos-unstable - name: golangci-lint - run: make lint-go-integration-tests + run: nix develop -c make lint-go-integration-tests - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 @@ -53,16 +47,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - uses: smartcontractkit/tool-versions-to-env-action@v1.0.8 - id: tool-versions - - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: Install Nix + uses: cachix/install-nix-action@29bd9290ef037a3ecbdafe83cbd2185e9dd0fa0a # v20 with: - go-version-file: "go.mod" - check-latest: true + nix_path: nixpkgs=channel:nixos-unstable - name: golangci-lint - run: make lint-go-relay + run: nix develop -c make lint-go-relay - name: Store lint report artifact if: always() uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 From cf6aaadc0006f20631bed0cb863fd6666a7f93cf Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Mon, 11 Sep 2023 16:26:53 +0200 Subject: [PATCH 30/38] Removed GOROOT which was not needed from shell.nix --- shell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell.nix b/shell.nix index 392180622..edbb4c3c6 100644 --- a/shell.nix +++ b/shell.nix @@ -34,7 +34,7 @@ pkgs.mkShell { RUST_BACKTRACE = "1"; # https://github.com/rust-lang/rust/issues/55979 LD_LIBRARY_PATH = lib.makeLibraryPath (with pkgs; [ stdenv.cc.cc.lib ]); - GOROOT="${pkgs.go_1_20}/share/go"; + # Avoids issues with delve CGO_CPPFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0"; From a7c2839f9b7d8169c08c507f187f6dba91c17898 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Tue, 12 Sep 2023 07:46:23 +0200 Subject: [PATCH 31/38] Fixing nix --- flake.lock | 66 +++++++++++++++++++++++++++++++++++++++++------------- flake.nix | 11 --------- shell.nix | 11 ++++----- 3 files changed, 57 insertions(+), 31 deletions(-) diff --git a/flake.lock b/flake.lock index 0e0ff110b..5aacf0d5e 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", "type": "github" }, "original": { @@ -16,12 +19,15 @@ } }, "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, "locked": { - "lastModified": 1656928814, - "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", "owner": "numtide", "repo": "flake-utils", - "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", "type": "github" }, "original": { @@ -32,11 +38,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1664871473, - "narHash": "sha256-1LzbW6G6Uz8akWiOdlIi435GAm1ct5jF5tovw/9to0o=", + "lastModified": 1694183432, + "narHash": "sha256-YyPGNapgZNNj51ylQMw9lAgvxtM2ai1HZVUu3GS8Fng=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b7a6fde153d9470afdb6aa1da51c4117f03b84ed", + "rev": "db9208ab987cdeeedf78ad9b4cf3c55f5ebd269b", "type": "github" }, "original": { @@ -48,11 +54,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1659102345, - "narHash": "sha256-Vbzlz254EMZvn28BhpN8JOi5EuKqnHZ3ujFYgFcSGvk=", + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "11b60e4f80d87794a2a4a8a256391b37c59a1ea7", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", "type": "github" }, "original": { @@ -75,11 +81,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1665024572, - "narHash": "sha256-b6Tnu74VzdMaJgKHM9iJ6fVf9svzYI+ktfzMGoDt/Og=", + "lastModified": 1694398298, + "narHash": "sha256-Hi904+2V5DJhFdEy9DcARSRrGJOlYSILHUC6CgTtuZU=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "fb4d8ee5220b76d1ffb4b4e1fedcf3cbc93ead1a", + "rev": "6c520f2e31f4bebeb29cc4563543de7187013575", "type": "github" }, "original": { @@ -87,6 +93,36 @@ "repo": "rust-overlay", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "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", diff --git a/flake.nix b/flake.nix index fe56fb1ca..339966756 100644 --- a/flake.nix +++ b/flake.nix @@ -5,24 +5,13 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; rust-overlay.url = "github:oxalica/rust-overlay"; - # saber-overlay.url = "github:saber-hq/saber-overlay"; - # saber-overlay.inputs.rust-overlay.follows = "rust-overlay"; - # naersk.url = "github:nmattia/naersk"; }; outputs = inputs@{ self, nixpkgs, rust-overlay, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; overlays = [ rust-overlay.overlays.default ]; }; - # naerskLib = pkgs.callPackage naersk { - # inherit (pkgs.rust-bin.nightly.latest) rustc cargo; - # }; in rec { - # packages.program = naerskLib.buildPackage { - # pname = "program"; - # root = ./.; - # }; - # defaultPackage = packages.program; devShell = pkgs.callPackage ./shell.nix {}; }); } diff --git a/shell.nix b/shell.nix index edbb4c3c6..6267e1425 100644 --- a/shell.nix +++ b/shell.nix @@ -7,7 +7,7 @@ pkgs.mkShell { llvm_11 stdenv.cc.cc.lib pkg-config - udev + # udev openssl # Solana @@ -26,14 +26,15 @@ pkgs.mkShell { # NodeJS + TS nodePackages.typescript nodePackages.typescript-language-server + nodePackages.npm # Keep this nodejs version in sync with the version in .tool-versions please - nodejs-16_x - (yarn.override { nodejs = nodejs-16_x; }) + nodejs-18_x + (yarn.override { nodejs = nodejs-18_x; }) python3 ]; RUST_BACKTRACE = "1"; - # https://github.com/rust-lang/rust/issues/55979 - LD_LIBRARY_PATH = lib.makeLibraryPath (with pkgs; [ stdenv.cc.cc.lib ]); + + LD_LIBRARY_PATH = lib.makeLibraryPath [pkgs.zlib stdenv.cc.cc.lib]; # lib64 # Avoids issues with delve From 28c2a004340271c2b03775801141cfa87955f283 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Tue, 12 Sep 2023 07:54:09 +0200 Subject: [PATCH 32/38] Added timeout to golangci-lint --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c19ab49ff..80e6b16f7 100644 --- a/Makefile +++ b/Makefile @@ -95,12 +95,12 @@ gomodtidy: .PHONY: lint-go-ops lint-go-ops: - cd ./ops && golangci-lint --color=always --out-format checkstyle:golangci-lint-ops-report.xml run + cd ./ops && golangci-lint --color=always --timeout 10m --out-format checkstyle:golangci-lint-ops-report.xml run .PHONY: lint-go-integration-tests lint-go-integration-tests: - cd ./integration-tests && golangci-lint --color=always --out-format checkstyle:golangci-lint-integration-tests-report.xml run + cd ./integration-tests && golangci-lint --color=always --timeout 10m --out-format checkstyle:golangci-lint-integration-tests-report.xml run .PHONY: lint-go-relay lint-go-relay: - cd ./pkg && golangci-lint --color=always --out-format checkstyle:golangci-lint-relay-report.xml run \ No newline at end of file + cd ./pkg && golangci-lint --color=always --timeout 10m --out-format checkstyle:golangci-lint-relay-report.xml run \ No newline at end of file From 0667b8c4626741e95e9cce595fb02f415cb47aa7 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Tue, 12 Sep 2023 08:15:08 +0200 Subject: [PATCH 33/38] Adding || true to ci linters --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 80e6b16f7..998e59554 100644 --- a/Makefile +++ b/Makefile @@ -95,12 +95,12 @@ gomodtidy: .PHONY: lint-go-ops lint-go-ops: - cd ./ops && golangci-lint --color=always --timeout 10m --out-format checkstyle:golangci-lint-ops-report.xml run + cd ./ops && golangci-lint --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-ops-report.xml run || true .PHONY: lint-go-integration-tests lint-go-integration-tests: - cd ./integration-tests && golangci-lint --color=always --timeout 10m --out-format checkstyle:golangci-lint-integration-tests-report.xml run + cd ./integration-tests && golangci-lint --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-integration-tests-report.xml run || true .PHONY: lint-go-relay lint-go-relay: - cd ./pkg && golangci-lint --color=always --timeout 10m --out-format checkstyle:golangci-lint-relay-report.xml run \ No newline at end of file + cd ./pkg && golangci-lint --color=always --exclude=dot-imports --timeout 10m --out-format checkstyle:golangci-lint-relay-report.xml run || true \ No newline at end of file From 2de81a340d4073a00947b27698455570597a5701 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Tue, 12 Sep 2023 08:28:06 +0200 Subject: [PATCH 34/38] Adding unused var for sonarcube confirmation --- pkg/solana/config_tracker.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/solana/config_tracker.go b/pkg/solana/config_tracker.go index 333e296ba..2ad5de54d 100644 --- a/pkg/solana/config_tracker.go +++ b/pkg/solana/config_tracker.go @@ -15,6 +15,7 @@ type ConfigTracker struct { } func (c *ConfigTracker) Notify() <-chan struct{} { + var unused_var return nil // not using websocket, config changes will be handled by polling in libocr } From 4562ffe901ddfb92923c478d452a7e654f60054a Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Tue, 12 Sep 2023 08:39:06 +0200 Subject: [PATCH 35/38] Removing unused var --- pkg/solana/config_tracker.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/solana/config_tracker.go b/pkg/solana/config_tracker.go index 2ad5de54d..333e296ba 100644 --- a/pkg/solana/config_tracker.go +++ b/pkg/solana/config_tracker.go @@ -15,7 +15,6 @@ type ConfigTracker struct { } func (c *ConfigTracker) Notify() <-chan struct{} { - var unused_var return nil // not using websocket, config changes will be handled by polling in libocr } From 0c602597d14d9ea48d096f6cd2d55ae11cadeec0 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Tue, 12 Sep 2023 09:04:50 +0200 Subject: [PATCH 36/38] Added udev --- shell.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/shell.nix b/shell.nix index 6267e1425..83369d06f 100644 --- a/shell.nix +++ b/shell.nix @@ -7,7 +7,6 @@ pkgs.mkShell { llvm_11 stdenv.cc.cc.lib pkg-config - # udev openssl # Solana @@ -31,7 +30,11 @@ pkgs.mkShell { nodejs-18_x (yarn.override { nodejs = nodejs-18_x; }) python3 - ]; + ] ++ lib.optionals stdenv.isLinux [ + # ledger specific packages + libudev-zero + libusb1 + ]; RUST_BACKTRACE = "1"; LD_LIBRARY_PATH = lib.makeLibraryPath [pkgs.zlib stdenv.cc.cc.lib]; # lib64 From 87763147f938499ba7775085978189f0ed31121b Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Tue, 12 Sep 2023 09:06:21 +0200 Subject: [PATCH 37/38] Adjusted coverage --- .github/workflows/relay.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/relay.yml b/.github/workflows/relay.yml index 4d483e11c..92bb3c762 100644 --- a/.github/workflows/relay.yml +++ b/.github/workflows/relay.yml @@ -34,5 +34,5 @@ jobs: with: name: go-relay-test-results path: | - ./coverage.txt + ./race_coverage.txt ./integration_coverage.txt \ No newline at end of file From 047672db185928f01c13fe20fda0bdb7f8bfdf43 Mon Sep 17 00:00:00 2001 From: Damjan Smickovski Date: Tue, 12 Sep 2023 09:42:49 +0200 Subject: [PATCH 38/38] Chaning name to Golang Lint for required check --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index bdffc34e7..63e057028 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -5,7 +5,7 @@ on: jobs: golang_lint_ops: - name: Golang Lint Ops + name: Golang Lint runs-on: ubuntu-latest steps: - name: Checkout sources