11name : Tests
22
33on :
4+ schedule : # scheduled to run at 23.00 on Saturday (UTC), means 6.00 on Monday (WIB)
5+ - cron : ' 0 23 * * 6'
46 pull_request :
57 branches : [main]
68 push :
@@ -12,24 +14,18 @@ concurrency:
1214
1315env :
1416 CC_TEST_REPORTER_ID : ${{ secrets.CC_TEST_REPORTER_ID }}
15- CC_TEST_REPORTER_URL : ${{ vars.CC_TEST_REPORTER_URL }}
1617
1718jobs :
18- configs :
19- name : Configure
20- uses : creasico/laravel-package/.github/workflows/configure.yml@main
21- secrets : inherit
22-
23- permissions :
24- contents : read
25- pull-requests : write
19+ prepare :
20+ name : Prepare
21+ uses : feryardiant/actions/.github/workflows/configure.yml@main
22+ secrets :
23+ CC_TEST_REPORTER_ID : ${{ secrets.CC_TEST_REPORTER_ID }}
2624
2725 tests :
2826 name : Test on PHP ${{ matrix.php }}
2927 runs-on : ubuntu-latest
30- needs : configs
31- outputs :
32- has-reports : ${{ steps.reports.outputs.has-reports }}
28+ needs : prepare
3329
3430 strategy :
3531 fail-fast : false
5349 - name : Cache Composer dependencies
5450 uses : actions/cache@v4
5551 with :
56- path : ${{ needs.configs .outputs.composer-cache }}
52+ path : ${{ needs.prepare .outputs.composer-cache }}
5753 key : ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
5854 restore-keys : ${{ runner.os }}-${{ matrix.php }}-composer-
5955
@@ -70,40 +66,29 @@ jobs:
7066 composer test -- --coverage
7167
7268 - name : Generate reports for CodeClimate
73- if : ${{ github.actor != 'dependabot[bot]' || needs.configs .outputs.should-reports == '1' }}
69+ if : needs.prepare .outputs.has-codeclimate == 'true'
7470 id : reports
7571 env :
7672 COVERAGE_FILE : tests/reports/clover.xml
77- CODECLIMATE_REPORT : ${{ github.workspace }}/tests/reports/codeclimate.${{ matrix.php }}.json
73+ CODECLIMATE_REPORT : tests/reports/codeclimate.${{ matrix.php }}.json
74+ CC_TEST_REPORTER_URL : ${{ vars.CC_TEST_REPORTER_URL }}
7875 run : |
79- if [[ -n \"$CC_TEST_REPORTER_URL\" ]]; then
80- curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
81- ./cc-test-reporter format-coverage -t clover -o $CODECLIMATE_REPORT $COVERAGE_FILE
82- echo "has-reports=1" >> $GITHUB_OUTPUT
83- fi
76+ curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
77+ ./cc-test-reporter format-coverage -t clover -o $CODECLIMATE_REPORT $COVERAGE_FILE
8478
8579 - name : Upload tests reports
8680 uses : actions/upload-artifact@v4
87- if : ${{ github.actor != 'dependabot[bot]' || needs.configs .outputs.should-reports == '1' }}
81+ if : needs.prepare .outputs.has-codeclimate == 'true'
8882 with :
8983 name : test-reports-${{ matrix.php }}
9084 path : tests/reports
9185
9286 reports :
93- name : Report Test Coverages
94- if : ${{ github.actor != 'dependabot[bot]' && needs.tests.outputs.has-reports == '1' }}
95- runs-on : ubuntu-latest
96- needs : tests
97-
98- steps :
99- - name : Download test reports
100- uses : actions/download-artifact@v4
101- with :
102- pattern : test-reports-*
103- merge-multiple : true
104-
105- - name : Report to CodeClimate
106- run : |
107- curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
108- ./cc-test-reporter sum-coverage -o - codeclimate.*.json | ./cc-test-reporter upload-coverage --input -
109-
87+ name : Reports
88+ needs : [prepare, tests]
89+ if : needs.prepare.outputs.should-reports == '1'
90+ uses : feryardiant/actions/.github/workflows/report.yml@main
91+ secrets :
92+ CC_TEST_REPORTER_ID : ${{ secrets.CC_TEST_REPORTER_ID }}
93+ with :
94+ has-codeclimate : ${{ needs.prepare.outputs.has-codeclimate == 'true' }}
0 commit comments