@@ -12,35 +12,30 @@ name: SonarCloud analysis
12
12
13
13
on :
14
14
workflow_run :
15
- workflows :
16
- - SonarCloud Build
17
- types :
18
- - completed
15
+ workflows : [SonarCloud Build]
16
+ types : [completed]
19
17
20
18
jobs :
21
19
SonarCloudAnalysis :
22
20
runs-on : ubuntu-latest
23
- if : github.event.workflow_run. conclusion == 'success'
21
+ if : github.event.workflow_run && github.event.workflow_run. conclusion == 'success' && github.event.workflow_run.event == 'pull_request '
24
22
timeout-minutes : 15
25
23
26
24
steps :
27
25
- name : Download PR number artifact
28
- if : github.event.workflow_run.event == 'pull_request'
29
26
uses : dawidd6/action-download-artifact@v3
30
27
with :
31
28
workflow : SonarCloud Build
32
29
run_id : ${{ github.event.workflow_run.id }}
33
30
name : PR_NUMBER
34
31
35
32
- name : Read PR_NUMBER.txt
36
- if : github.event.workflow_run.event == 'pull_request'
37
33
id : pr_number
38
34
uses : juliangruber/read-file-action@v1
39
35
with :
40
36
path : ./PR_NUMBER.txt
41
37
42
38
- name : Request GitHub API for PR data
43
- if : github.event.workflow_run.event == 'pull_request'
44
39
45
40
id : get_pr_data
46
41
with :
57
52
fetch-depth : 0
58
53
59
54
- name : Checkout base branch
60
- if : github.event.workflow_run.event == 'pull_request'
61
55
run : |
62
56
git remote add upstream ${{ github.event.repository.clone_url }}
63
57
git fetch upstream
@@ -69,10 +63,12 @@ jobs:
69
63
uses : actions/setup-python@v5
70
64
with :
71
65
python-version : 3.11
66
+ cache : ' pip'
72
67
73
68
- name : Install dependencies
74
69
run : |
75
70
python -m pip install --upgrade pip
71
+ pip install .
76
72
pip install -e .[test]
77
73
78
74
- name : Run tests and generate coverage report
97
93
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }}
98
94
99
95
- name : Run Sonar analysis (Push)
100
- if : ${{ github.event.workflow_run.event == 'push' }}
96
+ if : ${{ github.event.workflow_run.event == 'push' && github.repository == 'phlowers/thermohl' }}
101
97
uses : sonarsource/sonarqube-scan-action@v5
102
98
env :
103
99
SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
0 commit comments