Skip to content

Commit 152222c

Browse files
committed
ci: enable sonarqube analysis for contributors
1 parent b81f7c1 commit 152222c

File tree

2 files changed

+42
-29
lines changed

2 files changed

+42
-29
lines changed

.github/workflows/pr.yml

+9-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PR's
1+
name: PRs
22
on:
33
pull_request:
44
types: [opened, synchronize, reopened]
@@ -10,8 +10,8 @@ jobs:
1010
pr-test:
1111
uses: ./.github/workflows/basic-test.yml
1212

13-
pr-e2e-test:
14-
uses: ./.github/workflows/e2e-test.yml
13+
# pr-e2e-test: # TODO Uncomment when SONAR for contributors PR is ready to tests
14+
# uses: ./.github/workflows/e2e-test.yml
1515

1616
check-commit-lint:
1717
name: Check commit message follows guidelines
@@ -21,7 +21,9 @@ jobs:
2121
- uses: ./.github/actions/setup
2222

2323
- name: Execute commitlint
24-
run: npx commitlint --from=origin/${{ github.base_ref }}
24+
run: npx commitlint --from="origin/$BASE_REF"
25+
env:
26+
BASE_REF: ${{ github.base_ref }}
2527

2628
check-file-format:
2729
name: Check files changes follow guidelines
@@ -33,28 +35,6 @@ jobs:
3335
- name: Check if Prettier was run
3436
run: npx pretty-quick --check
3537

36-
backwards-compatibility-test:
37-
needs: [pr-test]
38-
uses: ./.github/workflows/backwards-compatibility-test.yml
39-
40-
pr-analysis:
41-
name: SonarCloud Pr Analysis
42-
runs-on: ubuntu-latest
43-
needs: pr-test
44-
steps:
45-
- uses: actions/checkout@v4
46-
with:
47-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
48-
49-
# Download reports
50-
- uses: ./.github/actions/download-coverage-report
51-
- uses: ./.github/actions/download-lint-report
52-
53-
- name: SonarCloud Scan
54-
uses: SonarSource/sonarcloud-github-action@master
55-
env:
56-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
57-
SONAR_TOKEN: ${{ secrets.SONARQUBE_SCANNER }}
58-
with:
59-
args: >
60-
-Dsonar.pullrequest.key=${{ github.env.PR_NUMBER }}
38+
# backwards-compatibility-test: # TODO Uncomment when SONAR for contributors PR is ready to tests
39+
# needs: [pr-test]
40+
# uses: ./.github/workflows/backwards-compatibility-test.yml

.github/workflows/sonar-pr.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Sonar for PRs
2+
on:
3+
workflow_run:
4+
workflows: ['PRs']
5+
types: [requested]
6+
jobs:
7+
sonar:
8+
name: Sonar
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 30
11+
if: github.event.workflow_run.conclusion == 'success'
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
repository: ${{ github.event.workflow_run.head_repository.full_name }}
16+
ref: ${{ github.event.workflow_run.head_branch }}
17+
fetch-depth: 0
18+
19+
# Download reports
20+
- uses: ./.github/actions/download-coverage-report
21+
- uses: ./.github/actions/download-lint-report
22+
23+
- name: SonarCloud Scan
24+
uses: sonarsource/sonarcloud-github-action@master
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
28+
with:
29+
args: >
30+
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }}
31+
-Dsonar.pullrequest.key=${{ github.event.workflow_run.pull_requests[0].number }}
32+
-Dsonar.pullrequest.branch=${{ github.event.workflow_run.pull_requests[0].head.ref }}
33+
-Dsonar.pullrequest.base=${{ github.event.workflow_run.pull_requests[0].base.ref }}

0 commit comments

Comments
 (0)