Skip to content

Commit a05bd6f

Browse files
committed
Add GitHub Action for running unit tests on push/pull requests
1 parent 51c8bf9 commit a05bd6f

4 files changed

Lines changed: 53 additions & 3 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Exclude dev files from dist prod zip archive
22

3+
/.github export-ignore
34
/tests export-ignore
45
.gitattributes export-ignore
56
.gitignore export-ignore

.github/workflows/test.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Tests
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
run:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ 'ubuntu-latest' ]
11+
php-versions: [ '7.1', '7.2', '7.3', '7.4', '8.0' ]
12+
phpunit-version: [ '9.5' ]
13+
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.os }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: ${{ matrix.php-versions }}
22+
tools: phpunit:${{ matrix.phpunit-version }}, composer:v2
23+
24+
- name: Check PHP Version
25+
run: php -v
26+
27+
- name: Check Composer Version
28+
run: composer -V
29+
30+
- name: Validate Composer json/lock
31+
run: composer validate --strict
32+
33+
- name: Get Composer Cache Directory
34+
id: composer-cache
35+
run: |
36+
echo "::set-output name=dir::$(composer config cache-files-dir)"
37+
38+
- name: Cache Composer dependencies
39+
uses: actions/cache@v2
40+
with:
41+
path: ${{ steps.composer-cache.outputs.dir }}
42+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
43+
restore-keys: |
44+
${{ runner.os }}-composer-
45+
46+
- name: Install Composer Dependencies
47+
run: composer install --prefer-dist --no-interaction --no-progress --no-suggest
48+
49+
- name: Run Unit Test
50+
run: composer test

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ composer.phar
99
*.log
1010
*.tmp
1111

12-
1312
# PHPStorm IDE folder
1413
.idea
1514

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"league/csv": "^9.1"
3030
},
3131
"require-dev": {
32-
"phpunit/phpunit": "^6.5",
33-
"phake/phake": "^3.0"
32+
"phpunit/phpunit": "^7.5",
33+
"phake/phake": "^3.1"
3434
},
3535
"autoload": {
3636
"psr-4": {

0 commit comments

Comments
 (0)