Skip to content

Commit 3c3757f

Browse files
committed
ci: add Makefile & refine workflow
- Use Makefile for install/lint/test - Cache on composer.json (+ lock) hash - Upload JUnit report and ignore it - Run CI on main, develop, tests
1 parent f6c63a9 commit 3c3757f

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

.github/workflows/php.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: PHP Composer
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ "main","develop","tests" ]
66
pull_request:
77
branches: [ "main" ]
88

@@ -26,15 +26,21 @@ jobs:
2626
uses: actions/cache@v3
2727
with:
2828
path: vendor
29-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
29+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json','**/composer.lock') }}
3030
restore-keys: |
3131
${{ runner.os }}-composer-
3232
3333
- name: Install dependencies
34-
run: composer install --prefer-dist --no-progress --no-suggest
34+
run: make install
3535

3636
- name: Lint code (PSR-12)
37-
run: composer run-script lint
37+
run: make lint
3838

3939
- name: Run PHPUnit tests
40-
run: composer run-script phpunit
40+
run: make test
41+
42+
- name: Upload PHPUnit report
43+
uses: actions/upload-artifact@v3
44+
with:
45+
name: phpunit-report
46+
path: .phpunit.junit.xml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
# PHPUnit result cache
77
.phpunit.result.cache
8+
.phpunit.junit.xml
89

910
# Other
1011
.DS_Store

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Makefile for bblslug
2+
3+
.PHONY: install lint test
4+
5+
install:
6+
composer install --no-interaction --optimize-autoloader
7+
8+
lint:
9+
composer run lint
10+
11+
test:
12+
composer run phpunit

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
],
2828
"scripts": {
2929
"lint": "vendor/bin/phpcs --standard=phpcs.xml",
30-
"phpunit": "vendor/bin/phpunit"
30+
"phpunit": "vendor/bin/phpunit --testdox --colors=always --log-junit .phpunit.junit.xml"
3131
},
3232
"authors": [
3333
{

0 commit comments

Comments
 (0)