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