20
20
jobs :
21
21
SonarCloudAnalysis :
22
22
runs-on : ubuntu-latest
23
- if : github.event.workflow_run. conclusion == 'success'
23
+ if : github.event.workflow_run && github.event.workflow_run. conclusion == 'success' && github.event.workflow_run.event == 'pull_request '
24
24
timeout-minutes : 15
25
25
26
26
steps :
27
27
- name : Download PR number artifact
28
- if : github.event.workflow_run.event == 'pull_request'
29
28
uses : dawidd6/action-download-artifact@v3
30
29
with :
31
30
workflow : SonarCloud Build
32
31
run_id : ${{ github.event.workflow_run.id }}
33
32
name : PR_NUMBER
34
33
35
34
- name : Read PR_NUMBER.txt
36
- if : github.event.workflow_run.event == 'pull_request'
37
35
id : pr_number
38
36
uses : juliangruber/read-file-action@v1
39
37
with :
40
38
path : ./PR_NUMBER.txt
41
39
42
40
- name : Request GitHub API for PR data
43
- if : github.event.workflow_run.event == 'pull_request'
44
41
45
42
id : get_pr_data
46
43
with :
57
54
fetch-depth : 0
58
55
59
56
- name : Checkout base branch
60
- if : github.event.workflow_run.event == 'pull_request'
61
57
run : |
62
58
git remote add upstream ${{ github.event.repository.clone_url }}
63
59
git fetch upstream
70
66
with :
71
67
python-version : 3.11
72
68
69
+ - name : Cache Python packages
70
+ uses : actions/cache@v4
71
+ with :
72
+ path : ~/.cache/pip
73
+ key : ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
74
+ restore-keys : |
75
+ ${{ runner.os }}-pip
76
+
73
77
- name : Install dependencies
74
78
run : |
75
79
python -m pip install --upgrade pip
80
+ pip install .
76
81
pip install -e .[test]
77
82
78
83
- name : Run tests and generate coverage report
@@ -91,18 +96,24 @@ jobs:
91
96
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
92
97
with :
93
98
args : >
99
+ -Dsonar.host.url=https://sonarcloud.io
100
+ -Dsonar.projectKey=phlowers_thermohl
101
+ -Dsonar.organization=phlowers
94
102
-Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}
95
103
-Dsonar.pullrequest.key=${{ fromJson(steps.get_pr_data.outputs.data).number }}
96
104
-Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
97
105
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }}
98
106
99
107
- name : Run Sonar analysis (Push)
100
- if : ${{ github.event.workflow_run.event == 'push' }}
108
+ if : ${{ github.event.workflow_run.event == 'push' && github.repository == 'phlowers/thermohl' }}
101
109
uses : sonarsource/sonarqube-scan-action@v5
102
110
env :
103
111
SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
104
112
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
105
113
with :
106
114
args : >
115
+ -Dsonar.host.url=https://sonarcloud.io
116
+ -Dsonar.projectKey=phlowers_thermohl
117
+ -Dsonar.organization=phlowers
107
118
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }}
108
119
-Dsonar.branch.name=${{ github.event.workflow_run.head_branch }}
0 commit comments