|
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
|
|
97 | 102 | -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }}
|
98 | 103 |
|
99 | 104 | - name: Run Sonar analysis (Push)
|
100 |
| - if: ${{ github.event.workflow_run.event == 'push' }} |
| 105 | + if: ${{ github.event.workflow_run.event == 'push' && github.repository == 'phlowers/thermohl'}} |
101 | 106 | uses: sonarsource/sonarqube-scan-action@v5
|
102 | 107 | env:
|
103 | 108 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
0 commit comments