Skip to content

Commit 7737b63

Browse files
committed
Adding: array and object validation; unit tests; code coverage pipeline
1 parent aacd2d4 commit 7737b63

File tree

10 files changed

+2054
-21
lines changed

10 files changed

+2054
-21
lines changed

.github/workflows/php.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: PHP Composer
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Validate composer.json and composer.lock
21+
run: composer validate --strict
22+
23+
- name: Cache Composer packages
24+
id: composer-cache
25+
uses: actions/cache@v3
26+
with:
27+
path: vendor
28+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-php-
31+
32+
- name: Install dependencies
33+
run: composer install --prefer-dist --no-progress
34+
35+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
36+
# Docs: https://getcomposer.org/doc/articles/scripts.md
37+
38+
- name: Run test suite
39+
run: composer run-script test && composer run-script check-coverage
40+
41+
- name: Upload coverage reports to Codecov
42+
if: ${{ github.event_name == 'push' }}
43+
uses: codecov/codecov-action@v4.0.1
44+
with:
45+
token: ${{ secrets.CODECOV_TOKEN }}
46+
file: ./build/coverage-clover.txt

composer.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,22 @@
77
"Webdevcave\\SchemaValidator\\": "src/"
88
}
99
},
10+
"autoload-dev": {
11+
"psr-4": {
12+
"Webdevcave\\SchemaValidator\\Tests\\": "tests/"
13+
}
14+
},
1015
"require": {
11-
"php": ">=8.1"
16+
"php": ">=8.1",
17+
"ext-mbstring": "*",
18+
"webdevcave/utility": "^1.0"
19+
},
20+
"require-dev": {
21+
"phpunit/phpunit": "^10.5",
22+
"rregeer/phpunit-coverage-check": "^0.3.1"
23+
},
24+
"scripts": {
25+
"test": "XDEBUG_MODE=coverage ./vendor/bin/phpunit",
26+
"check-coverage": "./vendor/bin/coverage-check ./build/coverage-clover.xml 85"
1227
}
1328
}

0 commit comments

Comments
 (0)