Skip to content

Commit c5ad62a

Browse files
committed
ci: replace labeler with prepare workflow
Signed-off-by: Fery Wardiyanto <ferywardiyanto@gmail.com>
1 parent d81dcc6 commit c5ad62a

File tree

3 files changed

+58
-46
lines changed

3 files changed

+58
-46
lines changed

.github/workflows/prepare.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Prepare
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
composer-cache:
7+
value: ${{ jobs.configure.outputs.composer-cache }}
8+
should-reports:
9+
value: ${{ jobs.configure.outputs.should-reports }}
10+
11+
jobs:
12+
configure:
13+
name: Configure
14+
runs-on: ubuntu-latest
15+
outputs:
16+
composer-cache: ${{ steps.prepare.outputs.composer-cache }}
17+
should-reports: ${{ steps.prepare.outputs.should-reports }}
18+
19+
permissions:
20+
contents: read
21+
pull-requests: write
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Labeler
28+
uses: actions/labeler@v5
29+
with:
30+
dot: true
31+
32+
- name: Setup PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
tools: composer:v2
36+
coverage: none
37+
38+
- name: Prepare environment
39+
id: prepare
40+
env:
41+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
42+
run: |
43+
git config user.name "Creasi.HQ" && git config user.email "dev@creasi.co"
44+
echo "composer-cache=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
45+
echo "should-reports=$(if [[ -z \"${CC_TEST_REPORTER_ID}\" ]]; then echo '0'; else echo '1'; fi)" >> $GITHUB_OUTPUT

.github/workflows/test.yml

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,20 @@ env:
1515
jobs:
1616
prepare:
1717
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
2220

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
4324

4425
tests:
4526
name: Test on PHP ${{ matrix.php }} with DB ${{ matrix.db }}
4627
runs-on: ubuntu-latest
4728
needs: prepare
29+
outputs:
30+
has-reports: ${{ steps.reports.outputs.has-reports }}
31+
4832
env:
4933
DB_CONNECTION: ${{ matrix.db }}
5034
DB_DATABASE: ${{ github.repository_owner }}
@@ -106,24 +90,26 @@ jobs:
10690
run: composer test -- --coverage
10791

10892
- 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' }}
11095
env:
11196
COVERAGE_FILE: tests/reports/clover.xml
11297
CODECLIMATE_REPORT: ${{ github.workspace }}/tests/reports/codeclimate.${{ matrix.php }}.json
11398
run: |
11499
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
115100
./cc-test-reporter format-coverage -t clover -o $CODECLIMATE_REPORT $COVERAGE_FILE
101+
echo "has-reports=1" >> $GITHUB_OUTPUT
116102
117103
- name: Upload tests reports
118104
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' }}
120106
with:
121107
name: test-reports-${{ matrix.php }}-${{ matrix.db }}
122108
path: tests/reports
123109

124110
reports:
125111
name: Report Test Coverages
126-
if: ${{ github.actor != 'dependabot[bot]' }}
112+
if: ${{ github.actor != 'dependabot[bot]' && needs.tests.outputs.has-reports == '1' }}
127113
runs-on: ubuntu-latest
128114
needs: tests
129115

.github/workflows/triage.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)