|
| 1 | +name: Test and Static Analysis (Pull Request) |
| 2 | + |
| 3 | +on: pull_request |
| 4 | + |
| 5 | +jobs: |
| 6 | + check-version-in-composer-json: |
| 7 | + name: Check Version |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + steps: |
| 11 | + - name: Set up PHP |
| 12 | + uses: shivammathur/setup-php@v2 |
| 13 | + with: |
| 14 | + php-version: 8.2 |
| 15 | + tools: composer:v2 |
| 16 | + |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v3 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: PHP Version Check |
| 23 | + run: php -v |
| 24 | + |
| 25 | + - name: Validate Composer JSON |
| 26 | + run: composer validate |
| 27 | + |
| 28 | + - name: Get Version From Comopser JSON |
| 29 | + id: new-version |
| 30 | + run: | |
| 31 | + echo version=$(cat composer.json | grep version | head -1 | grep -Po '\d+\.\d+\.\d+') >> $GITHUB_OUTPUT |
| 32 | + |
| 33 | + - name: Show New Version |
| 34 | + run: echo "version=${{ steps.new-version.outputs.version }}" |
| 35 | + |
| 36 | + - name: Show Tags |
| 37 | + run: git tag |
| 38 | + |
| 39 | + - name: Check If The Version Is Not In The Tag List |
| 40 | + run: | |
| 41 | + for tag in `git tag` |
| 42 | + do |
| 43 | + if [ $tag = ${{ steps.new-version.outputs.version }} ]; then |
| 44 | + echo "version ${{ steps.new-version.outputs.version }} already exists." |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + done |
| 48 | + echo "OK." |
| 49 | +
|
| 50 | + test-and-static-analysis: |
| 51 | + name: Test and Lint |
| 52 | + runs-on: ubuntu-latest |
| 53 | + strategy: |
| 54 | + matrix: |
| 55 | + php: ['8.1', '8.2', '8.3'] |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Set up PHP |
| 59 | + uses: shivammathur/setup-php@v2 |
| 60 | + with: |
| 61 | + php-version: ${{ matrix.php }} |
| 62 | + coverage: xdebug |
| 63 | + tools: composer:v2 |
| 64 | + |
| 65 | + - name: Set up Node |
| 66 | + uses: actions/setup-node@v3 |
| 67 | + with: |
| 68 | + node-version: '14.x' |
| 69 | + |
| 70 | + - name: Checkout code |
| 71 | + uses: actions/checkout@v3 |
| 72 | + with: |
| 73 | + fetch-depth: 0 |
| 74 | + |
| 75 | + - name: PHP Version Check |
| 76 | + run: php -v |
| 77 | + |
| 78 | + - name: Validate Composer JSON |
| 79 | + run: composer validate |
| 80 | + |
| 81 | + - name: Run Composer Install |
| 82 | + id: composerinstall |
| 83 | + run: composer install --no-interaction |
| 84 | + |
| 85 | + - name: PHP Lint |
| 86 | + run: ./vendor/bin/parallel-lint src tests examples |
| 87 | + |
| 88 | + - name: Neon Lint |
| 89 | + run: ./vendor/nette/neon/bin/neon-lint conf |
| 90 | + |
| 91 | + - name: PHP MD |
| 92 | + run: | |
| 93 | + ./vendor/bin/phpmd --version |
| 94 | + ./vendor/bin/phpmd ./src/ ./examples/ ./tests/ text phpmd.xml |
| 95 | +
|
| 96 | + - name: PHP Code Sniffer |
| 97 | + run: | |
| 98 | + ./vendor/bin/phpcs --version |
| 99 | + ./vendor/bin/phpcs --ignore=vendor --standard=phpcs.xml -s -p . |
| 100 | +
|
| 101 | + - name: PHPStan |
| 102 | + run: | |
| 103 | + ./vendor/bin/phpstan --version |
| 104 | + ./vendor/bin/phpstan analyze -c phpstan.neon |
| 105 | +
|
| 106 | + - name: Unit tests |
| 107 | + run: | |
| 108 | + mkdir -p build/logs |
| 109 | + ./vendor/bin/phpunit --version |
| 110 | + echo "Test suite All" |
| 111 | + ./vendor/bin/phpunit ./tests/ |
| 112 | + |
| 113 | + code-coverage: |
| 114 | + name: Code coverage |
| 115 | + runs-on: ubuntu-latest |
| 116 | + strategy: |
| 117 | + matrix: |
| 118 | + php: ['8.1'] |
| 119 | + |
| 120 | + steps: |
| 121 | + - name: Set up PHP |
| 122 | + uses: shivammathur/setup-php@v2 |
| 123 | + with: |
| 124 | + php-version: ${{ matrix.php }} |
| 125 | + coverage: xdebug |
| 126 | + tools: composer:v2 |
| 127 | + |
| 128 | + - name: Set up Node |
| 129 | + uses: actions/setup-node@v3 |
| 130 | + with: |
| 131 | + node-version: '14.x' |
| 132 | + |
| 133 | + - name: Checkout code |
| 134 | + uses: actions/checkout@v3 |
| 135 | + with: |
| 136 | + fetch-depth: 0 |
| 137 | + |
| 138 | + - name: Run Composer |
| 139 | + run: composer install --no-interaction |
| 140 | + |
| 141 | + - name: Update PHPUnit for Code Coverage |
| 142 | + run: composer require phpunit/phpunit:^9.6 phploc/phploc:* sebastian/version:* --with-all-dependencies |
| 143 | + |
| 144 | + - name: PHP Lint |
| 145 | + run: ./vendor/bin/parallel-lint src tests examples |
| 146 | + |
| 147 | + - name: Unit tests |
| 148 | + run: | |
| 149 | + mkdir -p build/logs |
| 150 | + ./vendor/bin/phpunit ./tests/ --coverage-clover build/logs/clover.xml |
0 commit comments