Skip to content

Commit cdd7787

Browse files
committed
ci: update ci workflow
Signed-off-by: Fery Wardiyanto <[email protected]>
1 parent f4bae8e commit cdd7787

File tree

2 files changed

+40
-21
lines changed

2 files changed

+40
-21
lines changed
Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
name: Prepare
1+
name: Configure
22

33
on:
44
workflow_call:
55
outputs:
66
composer-cache:
7-
value: ${{ jobs.configure.outputs.composer-cache }}
7+
value: ${{ jobs.environment.outputs.composer-cache }}
88
should-reports:
9-
value: ${{ jobs.configure.outputs.should-reports }}
9+
value: ${{ jobs.environment.outputs.should-reports }}
1010

1111
jobs:
12-
configure:
13-
name: Configure
12+
labels:
13+
name: Labels
14+
if: github.event_name == 'pull_request'
1415
runs-on: ubuntu-latest
15-
outputs:
16-
composer-cache: ${{ steps.prepare.outputs.composer-cache }}
17-
should-reports: ${{ steps.prepare.outputs.should-reports }}
1816

1917
permissions:
2018
contents: read
@@ -29,15 +27,28 @@ jobs:
2927
with:
3028
dot: true
3129

30+
environment:
31+
name: Configure
32+
runs-on: ubuntu-latest
33+
outputs:
34+
composer-cache: ${{ steps.environment.outputs.composer-cache }}
35+
should-reports: ${{ steps.environment.outputs.should-reports }}
36+
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
3241
- name: Setup PHP
3342
uses: shivammathur/setup-php@v2
3443
with:
3544
tools: composer:v2
3645
coverage: none
3746

38-
- name: Prepare environment
39-
id: prepare
47+
- name: Environment
48+
id: environment
49+
env:
50+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
4051
run: |
41-
git config user.name "Creasi.HQ" && git config user.email "dev@creasi.co"
52+
git config user.name "Creasi.HQ" && git config user.email "developers@creasi.co"
4253
echo "composer-cache=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
4354
echo "should-reports=$([[ -z \"$CC_TEST_REPORTER_ID\" ]] && echo '1')" >> $GITHUB_OUTPUT

.github/workflows/test.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ env:
1313
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }}
1414

1515
jobs:
16-
prepare:
16+
configs:
1717
name: Prepare
18-
uses: ./.github/workflows/prepare.yml
18+
uses: ./.github/workflows/configure.yml
1919
secrets: inherit
2020

2121
permissions:
@@ -25,7 +25,7 @@ jobs:
2525
tests:
2626
name: Test on PHP ${{ matrix.php }} with DB ${{ matrix.db }}
2727
runs-on: ubuntu-latest
28-
needs: prepare
28+
needs: configs
2929
outputs:
3030
has-reports: ${{ steps.reports.outputs.has-reports }}
3131

@@ -42,25 +42,33 @@ jobs:
4242
POSTGRES_DB: ${{ env.DB_DATABASE }}
4343
POSTGRES_USER: ${{ env.DB_USERNAME }}
4444
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
45-
options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3
4645
ports:
4746
- 5432:5432
47+
options: >-
48+
--health-cmd=pg_isready
49+
--health-interval=10s
50+
--health-timeout=5s
51+
--health-retries=3
4852
mysql:
4953
image: mysql:8.0
5054
env:
5155
MYSQL_ROOT_PASSWORD: ${{ env.DB_PASSWORD }}
5256
MYSQL_DATABASE: ${{ env.DB_DATABASE }}
5357
MYSQL_USER: ${{ env.DB_USERNAME }}
5458
MYSQL_PASSWORD: ${{ env.DB_PASSWORD }}
55-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
5659
ports:
5760
- 3306:3306
61+
options: >-
62+
--health-cmd="mysqladmin ping"
63+
--health-interval=10s
64+
--health-timeout=5s
65+
--health-retries=3
5866
5967
strategy:
6068
fail-fast: false
6169
matrix:
6270
php: [8.1, 8.2]
63-
db: ['mysql', 'pgsql', 'sqlite']
71+
db: ['mysql', 'pgsql']
6472

6573
steps:
6674
- name: Checkout
@@ -79,7 +87,7 @@ jobs:
7987
- name: Cache Composer dependencies
8088
uses: actions/cache@v4
8189
with:
82-
path: ${{ needs.prepare.outputs.composer-cache }}
90+
path: ${{ needs.configs.outputs.composer-cache }}
8391
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
8492
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
8593

@@ -91,10 +99,10 @@ jobs:
9199

92100
- name: Generate reports for CodeClimate
93101
id: reports
94-
if: ${{ github.actor != 'dependabot[bot]' || needs.prepare.outputs.should-reports == '1' }}
102+
if: ${{ github.actor != 'dependabot[bot]' || needs.configs.outputs.should-reports == '1' }}
95103
env:
96104
COVERAGE_FILE: tests/reports/clover.xml
97-
CODECLIMATE_REPORT: ${{ github.workspace }}/tests/reports/codeclimate.${{ matrix.php }}.json
105+
CODECLIMATE_REPORT: tests/reports/codeclimate.${{ matrix.php }}.json
98106
run: |
99107
if [[ -z \"$CC_TEST_REPORTER_URL\" ]]; then
100108
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
@@ -104,7 +112,7 @@ jobs:
104112
105113
- name: Upload tests reports
106114
uses: actions/upload-artifact@v4
107-
if: ${{ github.actor != 'dependabot[bot]' || needs.prepare.outputs.should-reports == '1' }}
115+
if: ${{ github.actor != 'dependabot[bot]' || needs.configs.outputs.should-reports == '1' }}
108116
with:
109117
name: test-reports-${{ matrix.php }}-${{ matrix.db }}
110118
path: tests/reports

0 commit comments

Comments
 (0)