Skip to content

Commit 5dccaec

Browse files
authored
chore: introduce sonar in ci (#60)
Introduce Sonar to CI.
1 parent 8aaeac1 commit 5dccaec

2 files changed

Lines changed: 90 additions & 0 deletions

File tree

.github/workflows/pull-request-main.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ jobs:
3636
only-new-issues: "false"
3737
golangci-lint-version: v2.11.4
3838

39+
ci-lint-misc:
40+
name: Lint GH Actions and scripts
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: read
44+
steps:
45+
- name: Linting Misc (yaml + sh files)
46+
uses: smartcontractkit/.github/actions/ci-lint-misc@eeb76b5870e3c17856d5a60fd064a053c023b5f5 # ci-lint-misc@1.0.0
47+
3948
ci-test:
4049
name: Tests
4150
runs-on: ubuntu-latest
@@ -51,3 +60,22 @@ jobs:
5160
go-test-cmd: go test -race -coverprofile=coverage.txt ./...
5261
use-go-cache: true
5362
artifact-name: unit-tests
63+
64+
sonarqube:
65+
name: Sonar Scan
66+
if: |
67+
always() &&
68+
github.event_name == 'pull_request' &&
69+
!contains(needs.*.result, 'failure') &&
70+
!contains(needs.*.result, 'cancelled')
71+
runs-on: ubuntu-24.04
72+
needs: [go-mod-sync, ci-lint, ci-lint-misc, ci-test]
73+
permissions:
74+
contents: read
75+
actions: read
76+
steps:
77+
- name: Scan with Sonarqube
78+
uses: smartcontractkit/.github/actions/ci-sonarqube-go@01d931b0455a754d12e7143cc54a5a3521a8f6f6 # ci-sonarqube-go@0.3.1
79+
with:
80+
sonar-token: ${{ secrets.SONAR_TOKEN }}
81+
sonar-host-url: ${{ secrets.SONAR_HOST_URL }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: schedule-main
2+
3+
on:
4+
schedule:
5+
# Runs once a day at 1:00 UTC on main branch to collect statistics
6+
- cron: "0 1 * * *"
7+
workflow_dispatch:
8+
9+
jobs:
10+
ci-lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write
15+
contents: read
16+
actions: read
17+
steps:
18+
- name: Linting Go
19+
uses: smartcontractkit/.github/actions/ci-lint-go@ci-lint-go/v2 # ci-lint-go@2.x.x
20+
with:
21+
only-new-issues: "false"
22+
golangci-lint-version: v2.11.4
23+
24+
ci-lint-misc:
25+
name: Lint GH Actions and scripts
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
steps:
30+
- name: Linting Misc (yaml + sh files)
31+
uses: smartcontractkit/.github/actions/ci-lint-misc@eeb76b5870e3c17856d5a60fd064a053c023b5f5 # ci-lint-misc@1.0.0
32+
33+
ci-test:
34+
name: Tests
35+
runs-on: ubuntu-latest
36+
timeout-minutes: 10
37+
permissions:
38+
id-token: write
39+
contents: read
40+
actions: read
41+
steps:
42+
- name: Build and test
43+
uses: smartcontractkit/.github/actions/ci-test-go@dfcba48f05933158428bce867d790e3d5a9baa6b # ci-test-go@1.1.0
44+
with:
45+
go-test-cmd: go test -race -coverprofile=coverage.txt ./...
46+
use-go-cache: true
47+
artifact-name: unit-tests
48+
49+
sonarqube:
50+
name: Sonar Scan
51+
runs-on: ubuntu-24.04
52+
needs: [ci-lint, ci-lint-misc, ci-test]
53+
permissions:
54+
contents: read
55+
actions: read
56+
steps:
57+
- name: Scan with Sonarqube
58+
uses: smartcontractkit/.github/actions/ci-sonarqube-go@01d931b0455a754d12e7143cc54a5a3521a8f6f6 # ci-sonarqube-go@0.3.1
59+
with:
60+
sonar-token: ${{ secrets.SONAR_TOKEN }}
61+
sonar-host-url: ${{ secrets.SONAR_HOST_URL }}
62+
include-lint: true

0 commit comments

Comments
 (0)