Skip to content

Commit

Permalink
Trying out sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
smickovskid committed Sep 5, 2023
1 parent 83c50cc commit a8f50d7
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 122 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
39 changes: 39 additions & 0 deletions .github/workflows/relay.yml
Original file line number Diff line number Diff line change
@@ -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
76 changes: 76 additions & 0 deletions .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}


122 changes: 0 additions & 122 deletions .github/workflows/unit-testing-and-static-analysis.yml

This file was deleted.

0 comments on commit a8f50d7

Please sign in to comment.