Skip to content

Commit

Permalink
fix: potential fix for sonarqube job
Browse files Browse the repository at this point in the history
  • Loading branch information
erikburt committed Jan 15, 2024
1 parent d364651 commit c5fe6b0
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 122 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI Lint

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 }}

55 changes: 55 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI Test

on:
push:
branches:
- main
pull_request:

jobs:
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: |
./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
122 changes: 0 additions & 122 deletions .github/workflows/ci.yml

This file was deleted.

88 changes: 88 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: SonarQube Scan

on:
push:
branches:
- main
pull_request:

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 }}

- 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
permissions:
actions: read
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: ci-lint.yml
name: golangci-lint-report
workflow_conclusion: ""
name_is_regexp: true
if_no_artifact_found: warn
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Download go unit test coverage reports
if: always()
uses: dawidd6/action-download-artifact@v2.27.0
with:
workflow: ci-test.yml
name: go-test-results
workflow_conclusion: ""
name_is_regexp: true
if_no_artifact_found: warn
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Set SonarQube Report Paths
if: always()
id: sonarqube_report_paths
shell: bash
run: |
COVERAGE_REPORT_PATHS=$(find -type f -name '*coverage.txt' -printf '%p,')
GOLANGCI_REPORT_PATHS=$(find -type f -name 'golangci-lint-report.xml' -printf '%p,')
echo "COVERAGE_REPORT_PATHS=$COVERAGE_REPORT_PATHS"
echo "GOLANGCI_REPORT_PATHS=$GOLANGCI_REPORT_PATHS"
echo "sonarqube_coverage_report_paths=$COVERAGE_REPORT_PATHS" >> $GITHUB_OUTPUT
echo "sonarqube_golangci_report_paths=$GOLANGCI_REPORT_PATHS" >> $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 }}

0 comments on commit c5fe6b0

Please sign in to comment.