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 - name: "Get libxml2-utils" 101 run: | 102 set -x 103 export DEBIAN_FRONTEND=noninteractive 104 sudo apt-get update -y | true 105 sudo apt-get install -y libxml2-utils 106 107 - name: "Validate XML files" 108 run: "for a in $(find . -name '*.xml'); do xmllint --quiet --noout $a; done" 109 110 tests: 111 name: "Tests" 112 113 runs-on: "ubuntu-latest" 114 115 strategy: 116 matrix: 117 php-version: 118 - "8.2" 119 120 env: 121 HTTP_HOST: "localhost:8080" 122 123 steps: 124 - name: "Checkout" 125 uses: "actions/checkout@v4" 126 127 - name: "Set up PHP" 128 uses: "shivammathur/setup-php@v2" 129 with: 130 coverage: "none" 131 extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter" 132 php-version: "${{ matrix.php-version }}" 133 134 - name: "Set up problem matchers for PHP" 135 run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" 136 137 - name: "Set up problem matchers for phpunit/phpunit" 138 run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"" 139 140 - name: "Determine composer cache directory" 141 run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV" 142 143 - name: "Cache dependencies installed with composer" 144 uses: "actions/cache@v3" 145 with: 146 path: "${{ env.COMPOSER_CACHE_DIR }}" 147 key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}" 148 restore-keys: "php-${{ matrix.php-version }}-composer-" 149 150 - name: "Install dependencies with composer" 151 run: "composer install --ansi --no-interaction --no-progress" 152 153 - name: "Run unit tests with phpunit/phpunit" 154 run: "vendor/bin/phpunit --colors=always --configuration=tests/phpunit.xml --testsuite=unit" 155 156 - name: "Start built-in web server for PHP" 157 run: "php -S ${{ env.HTTP_HOST }} .router.php &" 158 159 - name: "Run end-to-end tests with phpunit/phpunit" 160 run: "vendor/bin/phpunit --colors=always --configuration=tests/phpunit.xml --testsuite=end-to-end" 161