|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ '**' ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + basic-tests: |
| 11 | + name: Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }} |
| 12 | + runs-on: ${{ matrix.operating-system }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + operating-system: [ubuntu-latest, windows-latest] |
| 17 | + php-versions: ['7.4', '8.0', '8.1'] |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Setup PHP, with composer and extensions |
| 21 | + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php |
| 22 | + with: |
| 23 | + php-version: ${{ matrix.php-versions }} |
| 24 | + extensions: intl, mbstring, xml |
| 25 | + tools: composer:v2 |
| 26 | + ini-values: error_reporting=E_ALL |
| 27 | + coverage: xdebug |
| 28 | + |
| 29 | + - name: Setup problem matchers for PHP |
| 30 | + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" |
| 31 | + |
| 32 | + - name: Setup problem matchers for PHPUnit |
| 33 | + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" |
| 34 | + |
| 35 | + - name: Set git to use LF |
| 36 | + run: | |
| 37 | + git config --global core.autocrlf false |
| 38 | + git config --global core.eol lf |
| 39 | +
|
| 40 | + - uses: actions/checkout@v2 |
| 41 | + |
| 42 | + - name: Get composer cache directory |
| 43 | + id: composer-cache |
| 44 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 45 | + |
| 46 | + - name: Cache composer dependencies |
| 47 | + uses: actions/cache@v1 |
| 48 | + with: |
| 49 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 50 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 51 | + restore-keys: ${{ runner.os }}-composer- |
| 52 | + |
| 53 | + - name: Validate composer.json and composer.lock |
| 54 | + run: composer validate |
| 55 | + |
| 56 | + - name: Install Composer dependencies |
| 57 | + run: composer install --no-progress --prefer-dist --optimize-autoloader |
| 58 | + |
| 59 | + - name: Syntax check PHP |
| 60 | + run: bash vendor/bin/check-syntax-php.sh |
| 61 | + |
| 62 | + - name: Decide whether to run code coverage or not |
| 63 | + if: ${{ matrix.php-versions != '7.4' || matrix.operating-system != 'ubuntu-latest' }} |
| 64 | + run: | |
| 65 | + echo "NO_COVERAGE=--no-coverage" >> $GITHUB_ENV |
| 66 | +
|
| 67 | + - name: Run unit tests |
| 68 | + run: | |
| 69 | + echo $NO_COVERAGE |
| 70 | + ./vendor/bin/phpunit $NO_COVERAGE |
| 71 | +
|
| 72 | + - name: Save coverage data |
| 73 | + if: ${{ matrix.php-versions == '7.4' && matrix.operating-system == 'ubuntu-latest' }} |
| 74 | + uses: actions/upload-artifact@v3 |
| 75 | + with: |
| 76 | + name: build-data |
| 77 | + path: ${{ github.workspace }}/build |
| 78 | + |
| 79 | + security: |
| 80 | + name: Security checks |
| 81 | + runs-on: [ubuntu-latest] |
| 82 | + steps: |
| 83 | + - name: Setup PHP, with composer and extensions |
| 84 | + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php |
| 85 | + with: |
| 86 | + php-version: '7.4' |
| 87 | + extensions: mbstring, xml |
| 88 | + tools: composer:v2 |
| 89 | + coverage: none |
| 90 | + |
| 91 | + - name: Setup problem matchers for PHP |
| 92 | + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" |
| 93 | + |
| 94 | + - uses: actions/checkout@v2 |
| 95 | + |
| 96 | + - name: Get composer cache directory |
| 97 | + id: composer-cache |
| 98 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 99 | + |
| 100 | + - name: Cache composer dependencies |
| 101 | + uses: actions/cache@v1 |
| 102 | + with: |
| 103 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 104 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 105 | + restore-keys: ${{ runner.os }}-composer- |
| 106 | + |
| 107 | + - name: Install Composer dependencies |
| 108 | + run: composer install --no-progress --prefer-dist --optimize-autoloader |
| 109 | + |
| 110 | + - name: Security check for locked dependencies |
| 111 | + uses: symfonycorp/security-checker-action@v2 |
| 112 | + |
| 113 | + - name: Update Composer dependencies |
| 114 | + run: composer update --no-progress --prefer-dist --optimize-autoloader |
| 115 | + |
| 116 | + - name: Security check for updated dependencies |
| 117 | + uses: symfonycorp/security-checker-action@v2 |
| 118 | + |
| 119 | + sanity-check: |
| 120 | + name: Sanity checks |
| 121 | + runs-on: [ubuntu-latest] |
| 122 | + |
| 123 | + steps: |
| 124 | + - name: Setup PHP, with composer and extensions |
| 125 | + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php |
| 126 | + with: |
| 127 | + php-version: '7.4' |
| 128 | + extensions: mbstring, xml |
| 129 | + tools: composer:v2 |
| 130 | + coverage: none |
| 131 | + |
| 132 | + - name: Setup problem matchers for PHP |
| 133 | + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" |
| 134 | + |
| 135 | + - uses: actions/checkout@v2 |
| 136 | + |
| 137 | + - name: Get composer cache directory |
| 138 | + id: composer-cache |
| 139 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 140 | + |
| 141 | + - name: Cache composer dependencies |
| 142 | + uses: actions/cache@v1 |
| 143 | + with: |
| 144 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 145 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 146 | + restore-keys: ${{ runner.os }}-composer- |
| 147 | + |
| 148 | + - name: Install Composer dependencies |
| 149 | + run: composer install --no-progress --prefer-dist --optimize-autoloader |
| 150 | + |
| 151 | + - name: Syntax check YAML / XML / JSON |
| 152 | + run: | |
| 153 | + bash vendor/bin/check-syntax-yaml.sh |
| 154 | + bash vendor/bin/check-syntax-xml.sh |
| 155 | + bash vendor/bin/check-syntax-json.sh |
| 156 | +
|
| 157 | + quality: |
| 158 | + name: Quality control |
| 159 | + runs-on: [ubuntu-latest] |
| 160 | + needs: [basic-tests] |
| 161 | + |
| 162 | + steps: |
| 163 | + - name: Setup PHP, with composer and extensions |
| 164 | + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php |
| 165 | + with: |
| 166 | + php-version: '7.4' |
| 167 | + tools: composer:v2 |
| 168 | + extensions: mbstring, xml |
| 169 | + |
| 170 | + - name: Setup problem matchers for PHP |
| 171 | + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" |
| 172 | + |
| 173 | + - uses: actions/checkout@v2 |
| 174 | + |
| 175 | + - name: Get composer cache directory |
| 176 | + id: composer-cache |
| 177 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 178 | + |
| 179 | + - name: Cache composer dependencies |
| 180 | + uses: actions/cache@v1 |
| 181 | + with: |
| 182 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 183 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 184 | + restore-keys: ${{ runner.os }}-composer- |
| 185 | + |
| 186 | + - name: Install Composer dependencies |
| 187 | + run: composer install --no-progress --prefer-dist --optimize-autoloader |
| 188 | + |
| 189 | + - uses: actions/download-artifact@v3 |
| 190 | + with: |
| 191 | + name: build-data |
| 192 | + path: ${{ github.workspace }}/build |
| 193 | + |
| 194 | + - name: Codecov |
| 195 | + uses: codecov/codecov-action@v1 |
| 196 | + |
| 197 | + - name: PHP Code Sniffer |
| 198 | + continue-on-error: true |
| 199 | + run: php vendor/bin/phpcs |
| 200 | + |
| 201 | + - name: Psalm |
| 202 | + continue-on-error: true |
| 203 | + run: php vendor/bin/psalm --show-info=true --shepherd |
| 204 | + |
| 205 | + - name: Psalter |
| 206 | + continue-on-error: true |
| 207 | + run: php vendor/bin/psalter --issues=UnnecessaryVarAnnotation --dry-run |
0 commit comments