Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/qa 1202 sonarqube integration #506

Merged
merged 38 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7c312de
SonarQube initial setup
davidcauchi May 11, 2023
4b7ddd7
Add on push to workflow
davidcauchi May 11, 2023
508b53e
Adjust styling
davidcauchi May 11, 2023
8c9ebcc
Adjust typo
davidcauchi May 11, 2023
71126df
Remove args multiline
davidcauchi May 11, 2023
f498889
adjust sonar properties
davidcauchi Jun 14, 2023
0612f2b
updated sonar workflow
davidcauchi Jun 19, 2023
5f2b6a1
adjust for linting
davidcauchi Jun 19, 2023
ae9d438
adjust for linting
davidcauchi Jun 19, 2023
b41789f
remove unnecessary piped instruction
davidcauchi Jun 20, 2023
66bb9d1
remove test.ts
davidcauchi Jun 22, 2023
ae0d8a4
rename golint step
davidcauchi Jun 22, 2023
e879e40
remove write to output
davidcauchi Jun 22, 2023
893dd7b
add wildcard
davidcauchi Jun 22, 2023
7c6b203
update find folder
davidcauchi Jun 22, 2023
b3b49ff
switch how we search for reports
davidcauchi Jun 22, 2023
83c50cc
Rebase
smickovskid Sep 5, 2023
a8f50d7
Trying out sonar
smickovskid Sep 5, 2023
b66ba8a
Removed integration tests
smickovskid Sep 5, 2023
86b32c7
Scan fix
smickovskid Sep 7, 2023
3942483
Fixed naming
smickovskid Sep 11, 2023
f0734ea
Changed file names
smickovskid Sep 11, 2023
6c82107
Added gauntlet to ignore for sonar
smickovskid Sep 11, 2023
9e3da7f
Added lint tests
smickovskid Sep 11, 2023
7720854
Fixing broken yml
smickovskid Sep 11, 2023
9cccd89
fixed yml
smickovskid Sep 11, 2023
f686370
Rename
smickovskid Sep 11, 2023
ab746bd
Minor changes
smickovskid Sep 11, 2023
1fa71cf
Added nix to run lint tests
smickovskid Sep 11, 2023
cf6aaad
Removed GOROOT which was not needed from shell.nix
smickovskid Sep 11, 2023
a7c2839
Fixing nix
smickovskid Sep 12, 2023
28c2a00
Added timeout to golangci-lint
smickovskid Sep 12, 2023
0667b8c
Adding || true to ci linters
smickovskid Sep 12, 2023
2de81a3
Adding unused var for sonarcube confirmation
smickovskid Sep 12, 2023
4562ffe
Removing unused var
smickovskid Sep 12, 2023
0c60259
Added udev
smickovskid Sep 12, 2023
8776314
Adjusted coverage
smickovskid Sep 12, 2023
047672d
Chaning name to Golang Lint for required check
smickovskid Sep 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ jobs:

# 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
9 changes: 9 additions & 0 deletions .github/workflows/relay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ jobs:
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
smickovskid marked this conversation as resolved.
Show resolved Hide resolved
./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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no unit testing steps in the workflow, please rename it by removing unit testing part


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,e2e_tests_custom_cl"
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
smickovskid marked this conversation as resolved.
Show resolved Hide resolved
- 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 }}


6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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*
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# required (may be found under "Project Information" in SonarQube)
sonar.projectKey=smartcontractkit_chainlink-solana
sonar.sources=.

# Full exclusions from the static analysis
krebernisak marked this conversation as resolved.
Show resolved Hide resolved
sonar.exclusions=**/node_modules/**/*, **/contracts/artifacts/**/*, **/generated/**/*, **/docs/**/*, **/*.config.ts, **/*.config.js, **/*.txt
# Coverage exclusions
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, **/contracts/tests/**/*
sonar.test.exclusions=**/integration-tests/*
Loading