|
1 |
| -name: "PHP" |
| 1 | +# Controls when the action will run. |
2 | 2 | on:
|
| 3 | + # Triggers the workflow on push or pull request events but only for the main branch |
3 | 4 | push:
|
4 |
| - branches: |
5 |
| - - "main" |
6 | 5 | pull_request:
|
7 |
| - branches: |
8 |
| - - "main" |
| 6 | + |
| 7 | + # Allows you to run this workflow manually from the Actions tab |
| 8 | + workflow_dispatch: |
| 9 | + |
9 | 10 | permissions:
|
10 | 11 | contents: "read"
|
| 12 | + |
| 13 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
11 | 14 | jobs:
|
12 |
| - # PHP lint for different PHP versions |
13 |
| - build: |
| 15 | + # composer validation |
| 16 | + composer: |
| 17 | + name: "composer config validation" |
| 18 | + runs-on: "ubuntu-latest" |
| 19 | + steps: |
| 20 | + - uses: "actions/checkout@v3" |
| 21 | + - name: "Validate composer.json" |
| 22 | + run: "composer validate --strict" |
| 23 | + # PHP lint and PHPStan for different PHP versions |
| 24 | + php: |
14 | 25 | runs-on: "ubuntu-latest"
|
15 | 26 | strategy:
|
16 | 27 | matrix:
|
17 | 28 | php-version:
|
18 |
| - - "7.4" |
19 | 29 | - "8.1"
|
20 |
| - env: |
21 |
| - CC_TEST_REPORTER_ID: "b55ff60ba178ed6d17d568f49e8c6034e54aee0cfaf765c317a8545aeafe1215" |
| 30 | + - "8.2" |
| 31 | + - "8.3" |
22 | 32 | name: "PHP ${{ matrix.php-version }}"
|
23 | 33 | steps:
|
24 |
| - - # git checkout |
25 |
| - name: "git checkout" |
| 34 | + - name: "git checkout" |
26 | 35 | uses: "actions/checkout@v3"
|
27 |
| - - # Setup PHP |
28 |
| - name: "Setup PHP" |
| 36 | + - name: "setup PHP" |
29 | 37 | uses: "shivammathur/setup-php@v2"
|
30 | 38 | with:
|
31 | 39 | php-version: "${{ matrix.php-version }}"
|
32 | 40 | coverage: "xdebug"
|
33 |
| - - # Check PHP version |
34 |
| - name: "Check PHP version" |
| 41 | + - name: "check PHP version" |
35 | 42 | run: "php -v"
|
36 |
| - - # Lint PHP files |
37 |
| - name: "Lint PHP files" |
38 |
| - run: | |
39 |
| - for file in $(find ./ -type f -name '*.php'); do |
40 |
| - echo -n "==> ${file}: "; |
41 |
| - php -l "${file}"; |
42 |
| - done |
43 |
| - - # Validate composer.json and composer.lock |
44 |
| - name: "Validate composer.json and composer.lock" |
45 |
| - run: "composer validate --strict" |
46 |
| - - # Cache Composer packages |
47 |
| - name: "Cache Composer packages" |
48 |
| - id: "composer-cache" |
49 |
| - uses: "actions/cache@v3" |
| 43 | + - name: "lint PHP files" |
| 44 | + run: "php -l src/ tests/" |
| 45 | +# - name: "install composer dependencies" |
| 46 | +# run: "composer install --prefer-dist --no-progress" |
| 47 | +# # PHPStan |
| 48 | +# - name: "PHPStan static analysis" |
| 49 | +# uses: "php-actions/phpstan@v3" |
| 50 | +# with: |
| 51 | +# php_version: "${{ matrix.php-version }}" |
| 52 | +# configuration: "phpstan.neon" |
| 53 | +# path: "src/ tests/" |
| 54 | + # run unit tests |
| 55 | + phpunit: |
| 56 | + runs-on: "ubuntu-latest" |
| 57 | + env: |
| 58 | + CC_TEST_REPORTER_ID: "b55ff60ba178ed6d17d568f49e8c6034e54aee0cfaf765c317a8545aeafe1215" |
| 59 | + name: "PHPUnit" |
| 60 | + steps: |
| 61 | + - name: "git checkout" |
| 62 | + uses: "actions/checkout@v3" |
| 63 | + - name: "setup PHP" |
| 64 | + uses: "shivammathur/setup-php@v2" |
50 | 65 | with:
|
51 |
| - path: "vendor" |
52 |
| - key: "${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}" |
53 |
| - restore-keys: "${{ runner.os }}-php-" |
54 |
| - - # Install dependencies |
55 |
| - name: "Install composer dependencies" |
56 |
| - run: "composer install --prefer-dist --no-progress --ignore-platform-req=ext-sapnwrfc" |
57 |
| - - # PHP_CodeSniffer |
58 |
| - name: "PHP_CodeSniffer" |
59 |
| - run: "php vendor/bin/phpcs" |
60 |
| - - # CodeClimate Reporter Setup |
61 |
| - name: "CodeClimate Reporter Setup" |
| 66 | + php-version: "8.1" |
| 67 | + coverage: "xdebug" |
| 68 | + - name: "check PHP version" |
| 69 | + run: "php -v" |
| 70 | + - name: "install composer dependencies" |
| 71 | + run: "composer install --prefer-dist --no-progress" |
| 72 | + - name: "CodeClimate reporter setup" |
62 | 73 | run: |
|
63 | 74 | curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
64 | 75 | chmod +x ./cc-test-reporter
|
65 | 76 | ./cc-test-reporter before-build
|
66 |
| - - # Run phpunit |
67 |
| - name: "Run phpunit" |
| 77 | + - name: "run PHPUnit" |
68 | 78 | run: |
|
69 | 79 | php vendor/bin/phpunit --coverage-clover clover.xml --coverage-text
|
70 | 80 | ./cc-test-reporter after-build -t clover --exit-code $?
|
0 commit comments