|
| 1 | +name: Main workflow |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths-ignore: |
| 8 | + - '**.md' |
| 9 | + - 'examples/**' |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + paths-ignore: |
| 14 | + - '**.md' |
| 15 | + - 'examples/**' |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | +env: |
| 19 | + default-php-version: '8.2' |
| 20 | +jobs: |
| 21 | + run: |
| 22 | + name: Run |
| 23 | + runs-on: ${{ matrix.operating-system }} |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + operating-system: ${{ github.actor == 'dependabot[bot]' && fromJson('["ubuntu-24.04"]') || fromJson('["ubuntu-24.04", "ubuntu-22.04", "windows-2022", "macos-15-intel"]') }} |
| 28 | + php-versions: ${{ github.actor == 'dependabot[bot]' && fromJson('["8.6"]') || fromJson('["5.3", "5.4", "5.5", "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5", "8.6"]') }} |
| 29 | + include: |
| 30 | + - operating-system: ubuntu-24.04 |
| 31 | + php-versions: '' |
| 32 | + php-version-file: 'php-version-file' |
| 33 | + env: |
| 34 | + extensions: xml, opcache, xdebug, pcov, gd |
| 35 | + key: cache-v5 |
| 36 | + steps: |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@v6 |
| 39 | + |
| 40 | + - name: Setup cache environment |
| 41 | + id: cache-env |
| 42 | + uses: shivammathur/cache-extensions@v1 |
| 43 | + with: |
| 44 | + php-version: ${{ matrix.php-versions || env.default-php-version }} |
| 45 | + extensions: ${{ env.extensions }} |
| 46 | + key: ${{ env.key }} |
| 47 | + |
| 48 | + - name: Cache extensions |
| 49 | + uses: actions/cache@v5 |
| 50 | + with: |
| 51 | + path: ${{ steps.cache-env.outputs.dir }} |
| 52 | + key: ${{ steps.cache-env.outputs.key }} |
| 53 | + restore-keys: ${{ steps.cache-env.outputs.key }} |
| 54 | + |
| 55 | + - name: Stage php-version-file |
| 56 | + if: ${{ matrix.php-version-file == 'php-version-file' }} |
| 57 | + run: | |
| 58 | + echo ${{ env.default-php-version }} > php-version-file |
| 59 | +
|
| 60 | + - name: Setup PHP with extensions and custom config |
| 61 | + run: node dist/index.js |
| 62 | + env: |
| 63 | + php-version: ${{ matrix.php-versions }} |
| 64 | + php-version-file: ${{ matrix.php-version-file }} |
| 65 | + extensions: ${{ env.extensions }} |
| 66 | + ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata |
| 67 | + |
| 68 | + - name: Testing PHP version |
| 69 | + run: | |
| 70 | + php -v |
| 71 | + php -r "if(strpos(phpversion(), '${{ matrix.php-versions || env.default-php-version }}') === false) {throw new Exception('Wrong PHP version Installed');}" |
| 72 | +
|
| 73 | + - name: Testing Composer version |
| 74 | + run: | |
| 75 | + composer -V |
| 76 | + php -r "if(strpos(@exec('composer -V'), 'Composer version') === false) {throw new Exception('Composer not found');}" |
| 77 | + - name: Testing Extensions |
| 78 | + run: | |
| 79 | + php -m |
| 80 | + php -r "if(! extension_loaded('gd')) {throw new Exception('gd not found');}" |
| 81 | + php -r "if(! extension_loaded('xml')) {throw new Exception('xml not found');}" |
| 82 | + php -r "if(! extension_loaded('Xdebug')) {throw new Exception('Xdebug not found');}" |
| 83 | + php -r "if(phpversion()>=7.1 && ! extension_loaded('pcov')) {throw new Exception('PCOV not found');}" |
| 84 | + - name: Testing ini values |
| 85 | + run: | |
| 86 | + php -r "if(ini_get('memory_limit')!='-1') {throw new Exception('memory_limit not disabled');}" |
| 87 | + php -r "if(ini_get('post_max_size')!='256M') {throw new Exception('post_max_size not added');}" |
| 88 | + php -r "if(ini_get('short_open_tag')!=1) {throw new Exception('short_open_tag not added');}" |
| 89 | + php -r "if(ini_get('date.timezone')!='Asia/Kolkata') {throw new Exception('date.timezone not added');}" |
0 commit comments