1# https://docs.github.com/en/actions 2 3name: "Integrate" 4 5on: 6 pull_request: null 7 push: 8 branches: 9 - "master" 10 11jobs: 12 code-coverage: 13 name: "Code Coverage" 14 15 runs-on: "ubuntu-latest" 16 17 strategy: 18 matrix: 19 php-version: 20 - "8.2" 21 22 steps: 23 - name: "Checkout" 24 uses: "actions/checkout@v4" 25 26 - name: "Set up PHP" 27 uses: "shivammathur/setup-php@v2" 28 with: 29 coverage: "xdebug" 30 extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter" 31 php-version: "${{ matrix.php-version }}" 32 33 - name: "Set up problem matchers for PHP" 34 run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" 35 36 - name: "Set up problem matchers for phpunit/phpunit" 37 run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"" 38 39 - name: "Determine composer cache directory" 40 run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV" 41 42 - name: "Cache dependencies installed with composer" 43 uses: "actions/cache@v3" 44 with: 45 path: "${{ env.COMPOSER_CACHE_DIR }}" 46 key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}" 47 restore-keys: "php-${{ matrix.php-version }}-composer-" 48 49 - name: "Install dependencies with composer" 50 run: "composer install --ansi --no-interaction --no-progress" 51 52 - name: "Collect code coverage from running unit tests with phpunit/phpunit" 53 env: 54 XDEBUG_MODE: "coverage" 55 run: "vendor/bin/phpunit --colors=always --configuration=tests/phpunit.xml --coverage-text --testsuite=unit" 56 57 coding-standards: 58 name: "Coding Standards" 59 60 runs-on: "ubuntu-latest" 61 62 strategy: 63 matrix: 64 php-version: 65 - "8.2" 66 67 steps: 68 - name: "Checkout" 69 uses: "actions/checkout@v4" 70 71 - name: "Set up PHP" 72 uses: "shivammathur/setup-php@v2" 73 with: 74 coverage: "none" 75 extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter" 76 php-version: "${{ matrix.php-version }}" 77 78 - name: "Set up problem matchers for PHP" 79 run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" 80 81 - name: "Validate composer.json and composer.lock" 82 run: "composer validate --ansi --strict" 83 84 - name: "Determine composer cache directory" 85 run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV" 86 87 - name: "Cache dependencies installed with composer" 88 uses: "actions/cache@v4" 89 with: 90 path: "${{ env.COMPOSER_CACHE_DIR }}" 91 key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}" 92 restore-keys: "php-${{ matrix.php-version }}-composer-" 93 94 - name: "Install dependencies with composer" 95 run: "composer install --ansi --no-interaction --no-progress" 96 97 - name: "Run friendsofphp/php-cs-fixer" 98 run: "vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --dry-run --show-progress=dots --verbose" 99 100 tests: 101 name: "Tests" 102 103 runs-on: "ubuntu-latest" 104 105 strategy: 106 matrix: 107 php-version: 108 - "8.2" 109 110 env: 111 HTTP_HOST: "localhost:8080" 112 113 steps: 114 - name: "Checkout" 115 uses: "actions/checkout@v4" 116 117 - name: "Set up PHP" 118 uses: "shivammathur/setup-php@v2" 119 with: 120 coverage: "none" 121 extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter" 122 php-version: "${{ matrix.php-version }}" 123 124 - name: "Set up problem matchers for PHP" 125 run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" 126 127 - name: "Set up problem matchers for phpunit/phpunit" 128 run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"" 129 130 - name: "Determine composer cache directory" 131 run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV" 132 133 - name: "Cache dependencies installed with composer" 134 uses: "actions/cache@v3" 135 with: 136 path: "${{ env.COMPOSER_CACHE_DIR }}" 137 key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}" 138 restore-keys: "php-${{ matrix.php-version }}-composer-" 139 140 - name: "Install dependencies with composer" 141 run: "composer install --ansi --no-interaction --no-progress" 142 143 - name: "Run unit tests with phpunit/phpunit" 144 run: "vendor/bin/phpunit --colors=always --configuration=tests/phpunit.xml --testsuite=unit" 145 146 - name: "Start built-in web server for PHP" 147 run: "php -S ${{ env.HTTP_HOST }} .router.php &" 148 149 - name: "Run end-to-end tests with phpunit/phpunit" 150 run: "vendor/bin/phpunit --colors=always --configuration=tests/phpunit.xml --testsuite=end-to-end" 151