|
15 | 15 | jobs: |
16 | 16 | prepare: |
17 | 17 | name: Prepare |
18 | | - runs-on: ubuntu-latest |
19 | | - outputs: |
20 | | - composer-cache: ${{ steps.prepare.outputs.composer-cache }} |
21 | | - enable-reports: ${{ steps.reports.outputs.enabled }} |
| 18 | + uses: ./.github/workflows/prepare.yml |
| 19 | + secrets: inherit |
22 | 20 |
|
23 | | - steps: |
24 | | - - name: Setup PHP |
25 | | - uses: shivammathur/setup-php@v2 |
26 | | - with: |
27 | | - ini-values: error_reporting=E_ALL |
28 | | - tools: composer:v2 |
29 | | - coverage: none |
30 | | - env: |
31 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
32 | | - |
33 | | - - name: Prepare environment |
34 | | - id: prepare |
35 | | - run: | |
36 | | - git config user.name "Creasi.HQ" && git config user.email "dev@creasi.co" |
37 | | - echo "composer-cache=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
38 | | -
|
39 | | - - name: Should have reports |
40 | | - id: reports |
41 | | - run: | |
42 | | - echo "enabled=$(if [[ -z \"${CC_TEST_REPORTER_ID}\" ]]; then echo '0'; else echo '1'; fi)" >> $GITHUB_OUTPUT |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + pull-requests: write |
43 | 24 |
|
44 | 25 | tests: |
45 | 26 | name: Test on PHP ${{ matrix.php }} with DB ${{ matrix.db }} |
46 | 27 | runs-on: ubuntu-latest |
47 | 28 | needs: prepare |
| 29 | + outputs: |
| 30 | + has-reports: ${{ steps.reports.outputs.has-reports }} |
| 31 | + |
48 | 32 | env: |
49 | 33 | DB_CONNECTION: ${{ matrix.db }} |
50 | 34 | DB_DATABASE: ${{ github.repository_owner }} |
@@ -106,24 +90,26 @@ jobs: |
106 | 90 | run: composer test -- --coverage |
107 | 91 |
|
108 | 92 | - name: Generate reports for CodeClimate |
109 | | - if: ${{ github.actor != 'dependabot[bot]' }} |
| 93 | + id: reports |
| 94 | + if: ${{ github.actor != 'dependabot[bot]' || needs.prepare.outputs.should-reports == '1' }} |
110 | 95 | env: |
111 | 96 | COVERAGE_FILE: tests/reports/clover.xml |
112 | 97 | CODECLIMATE_REPORT: ${{ github.workspace }}/tests/reports/codeclimate.${{ matrix.php }}.json |
113 | 98 | run: | |
114 | 99 | curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter |
115 | 100 | ./cc-test-reporter format-coverage -t clover -o $CODECLIMATE_REPORT $COVERAGE_FILE |
| 101 | + echo "has-reports=1" >> $GITHUB_OUTPUT |
116 | 102 |
|
117 | 103 | - name: Upload tests reports |
118 | 104 | uses: actions/upload-artifact@v4 |
119 | | - if: ${{ github.actor != 'dependabot[bot]' || needs.prepare.outputs.enable-reports }} |
| 105 | + if: ${{ github.actor != 'dependabot[bot]' || needs.prepare.outputs.should-reports == '1' }} |
120 | 106 | with: |
121 | 107 | name: test-reports-${{ matrix.php }}-${{ matrix.db }} |
122 | 108 | path: tests/reports |
123 | 109 |
|
124 | 110 | reports: |
125 | 111 | name: Report Test Coverages |
126 | | - if: ${{ github.actor != 'dependabot[bot]' }} |
| 112 | + if: ${{ github.actor != 'dependabot[bot]' && needs.tests.outputs.has-reports == '1' }} |
127 | 113 | runs-on: ubuntu-latest |
128 | 114 | needs: tests |
129 | 115 |
|
|
0 commit comments