Skip to content

Commit 0bbd568

Browse files
committed
Add tests
1 parent 7cbca6d commit 0bbd568

File tree

3 files changed

+67
-9
lines changed

3 files changed

+67
-9
lines changed

.github/workflows/test-latest.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: My workflow
2+
on: [push, pull_request]
3+
4+
jobs:
5+
my-workflow:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v5
11+
12+
- name: Get PHP Versions
13+
id: php-version
14+
uses: antfroger/php-version-action@v1
15+
16+
- name: Setup PHP (Minimal)
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: ${{ steps.php-version.outputs.minimal }}
20+
tools: composer:v2
21+
22+
- name: Test
23+
run: echo "run your tests"

.github/workflows/test-matrix.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Testing matrix
2+
on: [push, pull_request]
3+
4+
jobs:
5+
php-versions:
6+
name: Lookup PHP versions
7+
runs-on: ubuntu-latest
8+
outputs:
9+
matrix: ${{ steps.versions.outputs.matrix }}
10+
steps:
11+
- uses: actions/checkout@v5
12+
- uses: antfroger/php-version-action@v1
13+
id: versions
14+
15+
test:
16+
name: Test PHP ${{ matrix.php-version }} on ${{ matrix.os }}
17+
runs-on: ${{ matrix.os }}
18+
needs: php-versions
19+
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest] # add more os
23+
php-version: ${{ fromJSON(needs.php-versions.outputs.matrix) }}
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v5
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php-version }}
33+
coverage: xdebug
34+
tools: composer:v2
35+
36+
- name: Test
37+
run: echo "run your tests"

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ jobs:
6767
php-version: ${{ steps.php-version.outputs.minimal }}
6868
tools: composer:v2
6969

70-
- name: Validate composer.json and composer.lock
71-
run: composer validate
70+
- name: Test
71+
run: echo "run your tests"
7272
```
7373
7474
If you want to do the same but using the latest PHP version that meets the requirements defined in `composer.json`, you
@@ -80,7 +80,7 @@ Let's say you want to run the unit tests on all versions starting from the minim
8080
until the latest released one, you need to run the version lookup as a separate job:
8181

8282
```yaml
83-
name: Testing all PHP versions
83+
name: Testing matrix
8484
on: [push, pull_request]
8585
8686
jobs:
@@ -95,13 +95,13 @@ jobs:
9595
id: versions
9696
9797
test:
98-
name: Test on ${{ matrix.os }} with PHP ${{ matrix.php-version }}
98+
name: Test PHP ${{ matrix.php-version }} on ${{ matrix.os }}
9999
runs-on: ${{ matrix.os }}
100100
needs: php-versions
101101
102102
strategy:
103103
matrix:
104-
os: [ubuntu-latest, windows-latest, macos-latest]
104+
os: [ubuntu-latest] # add more os
105105
php-version: ${{ fromJSON(needs.php-versions.outputs.matrix) }}
106106
107107
steps:
@@ -115,10 +115,8 @@ jobs:
115115
coverage: xdebug
116116
tools: composer:v2
117117
118-
- name: Run Tests
119-
run: |
120-
composer install
121-
vendor/bin/phpunit -v
118+
- name: Test
119+
run: echo "run your tests"
122120
```
123121

124122
### Custom Working Directory

0 commit comments

Comments
 (0)