diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..27a3d33 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,122 @@ +name: ci + +on: + push: + branches: + - main + pull_request: + +jobs: + ci-lint: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + actions: read + steps: + - name: ci-lint + uses: smartcontractkit/.github/actions/ci-lint-go@9e7cc0779934cae4a9028b8588c9adb64d8ce68c # ci-lint-go@0.1.0 + with: + metrics-job-name: ci-lint + golangci-lint-version: v1.55.2 + golangci-lint-args: --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s --out-format checkstyle:golangci-lint-report.xml + gc-basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} + gc-host: ${{ secrets.GRAFANA_CLOUD_HOST }} + + ci-test: + runs-on: ubuntu-latest + steps: + - name: Checkout the repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Setup Go + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version-file: "go.mod" + cache: true + + - name: Cache dependencies + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go + + - name: Run Test Suite + run: set -o pipefail && go test ./... -coverpkg=./... -coverprofile=coverage.txt $1 | tee $OUTPUT_FILE + + - name: Run Race Test Suite + run: set -o pipefail && go test -race ./... -coverpkg=./... -coverprofile=race_coverage.txt $1 | tee $OUTPUT_FILE + + - name: Upload Go test results + if: always() + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + with: + name: go-test-results + path: | + ./output.txt + ./coverage.txt + ./race_coverage.txt + + - name: Collect Metrics + if: always() + id: collect-gha-metrics + uses: smartcontractkit/push-gha-metrics-action@v2.0.2 + with: + basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} + hostname: ${{ secrets.GRAFANA_CLOUD_HOST }} + this-job-name: ci-test + continue-on-error: true + + + sonarqube: + name: SonarQube Scan + needs: [ci-lint, ci-test] + runs-on: ubuntu-latest + if: always() + steps: + - name: Checkout the repo + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 # fetches all history for all tags and branches to provide more metadata for sonar reports + + - name: Download Golangci-lint report + if: always() + uses: dawidd6/action-download-artifact@v2.27.0 + with: + workflow_conclusion: "" + name_is_regexp: true + name: golangci-lint-report + if_no_artifact_found: warn + + - name: Download Go PKG test reports + if: always() + uses: dawidd6/action-download-artifact@v2.27.0 + with: + workflow_conclusion: "" + name_is_regexp: true + name: go-test-results + if_no_artifact_found: warn + + - name: Set SonarQube Report Paths + if: always() + id: sonarqube_report_paths + shell: bash + run: | + echo "sonarqube_coverage_report_paths=$(find -type f -name '*coverage.out' -printf "%p,")" >> $GITHUB_OUTPUT + echo "sonarqube_golangci_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,")" >> $GITHUB_OUTPUT + + - name: SonarQube Scan + if: always() + uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0 + with: + args: > + -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 }} + diff --git a/.github/workflows/pull-request-main.yml b/.github/workflows/pull-request-main.yml deleted file mode 100644 index a8d3b81..0000000 --- a/.github/workflows/pull-request-main.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: pull-request-main - -on: - merge_group: - pull_request: - branches: - - main - -jobs: - ci-lint: - runs-on: ubuntu-latest - permissions: - id-token: write - contents: read - actions: read - steps: - - name: ci-lint - uses: smartcontractkit/.github/actions/ci-lint-go@9e7cc0779934cae4a9028b8588c9adb64d8ce68c # ci-lint-go@0.1.0 - with: - metrics-job-name: ci-lint - golangci-lint-version: v1.55.2 - golangci-lint-args: --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s --out-format checkstyle:golangci-lint-report.xml - # TODO: Setup Grafana secrets for repository - # gc-basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} - # gc-host: ${{ secrets.GRAFANA_CLOUD_HOST }} - - ci-test: - name: CI Tests - runs-on: ubuntu-latest - steps: - - name: Checkout the repo - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Setup Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version-file: "go.mod" - cache: true - - - name: Cache dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go - - - name: Run Test Suite - run: set -o pipefail && go test ./... -coverpkg=./... -coverprofile=coverage.txt $1 | tee $OUTPUT_FILE - - - name: Run Race Test Suite - run: set -o pipefail && go test -race ./... -coverpkg=./... -coverprofile=race_coverage.txt $1 | tee $OUTPUT_FILE - - - name: Upload Go test results - if: always() - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 - with: - name: go-test-results - path: | - ./output.txt - ./coverage.txt - ./race_coverage.txt diff --git a/.github/workflows/push-main.yml b/.github/workflows/push-main.yml deleted file mode 100644 index 65821ac..0000000 --- a/.github/workflows/push-main.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: push-main - -on: - push: - branches: - - main - -jobs: - ci-lint: - runs-on: ubuntu-latest - permissions: - id-token: write - contents: read - actions: read - steps: - - name: ci-lint - uses: smartcontractkit/.github/actions/ci-lint-go@9e7cc0779934cae4a9028b8588c9adb64d8ce68c # ci-lint-go@0.1.0 - with: - metrics-job-name: ci-lint - golangci-lint-version: v1.55.2 - golangci-lint-args: --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s --out-format checkstyle:golangci-lint-report.xml - # TODO: Setup Grafana secrets for repository - # gc-basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }} - # gc-host: ${{ secrets.GRAFANA_CLOUD_HOST }} - - ci-test: - name: CI Tests - runs-on: ubuntu-latest - steps: - - name: Checkout the repo - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Setup Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version-file: "go.mod" - cache: true - - - name: Cache dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3 - with: - path: | - ~/.cache/go-build - ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go - - - name: Run Test Suite - run: set -o pipefail && go test ./... -coverpkg=./... -coverprofile=coverage.txt $1 | tee $OUTPUT_FILE - - - name: Run Race Test Suite - run: set -o pipefail && go test -race ./... -coverpkg=./... -coverprofile=race_coverage.txt $1 | tee $OUTPUT_FILE - - - name: Upload Go test results - if: always() - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 - with: - name: go-test-results - path: | - ./output.txt - ./coverage.txt - ./race_coverage.txt - diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml deleted file mode 100644 index 49c359b..0000000 --- a/.github/workflows/sonar-scan.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: SonarQube Scan - -on: [push] - -jobs: - wait_for_workflows: - name: Wait for workflows - runs-on: ubuntu-latest - if: always() - steps: - - name: Checkout Repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - ref: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }} - - - name: Wait for workflows - uses: smartcontractkit/chainlink-github-actions/utils/wait-for-workflows@main - with: - max-timeout: "900" - polling-interval: "30" - exclude-workflow-names: "" - exclude-workflow-ids: "" - github-token: ${{ secrets.GITHUB_TOKEN }} - env: - DEBUG: "true" - - sonarqube: - name: SonarQube Scan - needs: [wait_for_workflows] - runs-on: ubuntu-latest - if: always() - steps: - - name: Checkout the repo - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - fetch-depth: 0 # fetches all history for all tags and branches to provide more metadata for sonar reports - - - name: Download Golangci-lint report - if: always() - 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: Download Go PKG test reports - if: always() - uses: dawidd6/action-download-artifact@v2.27.0 - with: - workflow: pkg.yml - workflow_conclusion: "" - name_is_regexp: true - name: go-test-results - if_no_artifact_found: warn - - - name: Set SonarQube Report Paths - if: always() - id: sonarqube_report_paths - shell: bash - run: | - echo "sonarqube_coverage_report_paths=$(find -type f -name '*coverage.out' -printf "%p,")" >> $GITHUB_OUTPUT - echo "sonarqube_golangci_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,")" >> $GITHUB_OUTPUT - - - name: SonarQube Scan - if: always() - uses: sonarsource/sonarqube-scan-action@a6ba0aafc293e03de5437af7edbc97f7d3ebc91a # v1.2.0 - with: - args: > - -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