|  | 
|  | 1 | +# CI workflow adapted from https://github.com/cakephp/cakephp/blob/master/.github/workflows/ci.yml | 
|  | 2 | +name: CI | 
|  | 3 | + | 
|  | 4 | +on: | 
|  | 5 | +  push: | 
|  | 6 | +  pull_request: | 
|  | 7 | + | 
|  | 8 | +jobs: | 
|  | 9 | +  testsuite: | 
|  | 10 | +    runs-on: ubuntu-24.04 | 
|  | 11 | +    strategy: | 
|  | 12 | +      fail-fast: false | 
|  | 13 | +      matrix: | 
|  | 14 | +        php-version: ['8.2', '8.3', '8.4'] | 
|  | 15 | +        db-type: [sqlite, mysql, pgsql] | 
|  | 16 | +        prefer-lowest: [''] | 
|  | 17 | + | 
|  | 18 | +    steps: | 
|  | 19 | +      - name: Setup MySQL latest | 
|  | 20 | +        if: matrix.db-type == 'mysql' | 
|  | 21 | +        run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql --default-authentication-plugin=mysql_native_password --disable-log-bin | 
|  | 22 | + | 
|  | 23 | +      - name: Setup PostgreSQL latest | 
|  | 24 | +        if: matrix.db-type == 'pgsql' | 
|  | 25 | +        run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres | 
|  | 26 | + | 
|  | 27 | +      - uses: actions/checkout@v4 | 
|  | 28 | + | 
|  | 29 | +      - name: Setup PHP | 
|  | 30 | +        uses: shivammathur/setup-php@v2 | 
|  | 31 | +        with: | 
|  | 32 | +          php-version: ${{ matrix.php-version }} | 
|  | 33 | +          extensions: mbstring, intl, apcu, memcached, redis, pdo_${{ matrix.db-type }} | 
|  | 34 | +          ini-values: apc.enable_cli = 1 | 
|  | 35 | +          coverage: pcov | 
|  | 36 | + | 
|  | 37 | +      - name: Get composer cache directory | 
|  | 38 | +        id: composer-cache | 
|  | 39 | +        run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | 
|  | 40 | + | 
|  | 41 | +      - name: Get date part for cache key | 
|  | 42 | +        id: key-date | 
|  | 43 | +        run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT | 
|  | 44 | + | 
|  | 45 | +      - name: Cache composer dependencies | 
|  | 46 | +        uses: actions/cache@v4 | 
|  | 47 | +        with: | 
|  | 48 | +          path: ${{ steps.composer-cache.outputs.dir }} | 
|  | 49 | +          key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }} | 
|  | 50 | + | 
|  | 51 | +      - name: Composer install | 
|  | 52 | +        run: | | 
|  | 53 | +          if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then | 
|  | 54 | +            composer update --prefer-lowest --prefer-stable | 
|  | 55 | +          else | 
|  | 56 | +            composer update | 
|  | 57 | +          fi | 
|  | 58 | +
 | 
|  | 59 | +      - name: Setup problem matchers for PHPUnit | 
|  | 60 | +        if: matrix.php-version == '8.2' && matrix.db-type == 'mysql' | 
|  | 61 | +        run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | 
|  | 62 | + | 
|  | 63 | +      - name: Run PHPUnit | 
|  | 64 | +        run: | | 
|  | 65 | +          if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi | 
|  | 66 | +          if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:[email protected]/cakephp'; fi | 
|  | 67 | +          if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/postgres'; fi | 
|  | 68 | +          if [[ ${{ matrix.php-version }} == '8.2' ]]; then | 
|  | 69 | +            export CODECOVERAGE=1 && vendor/bin/phpunit --coverage-clover=coverage.xml --configuration phpunit.xml.dist | 
|  | 70 | +          else | 
|  | 71 | +            vendor/bin/phpunit --configuration phpunit.xml.dist | 
|  | 72 | +          fi | 
|  | 73 | +
 | 
|  | 74 | +      - name: Submit code coverage | 
|  | 75 | +        if: matrix.php-version == '8.2' | 
|  | 76 | +        uses: codecov/codecov-action@v4 | 
|  | 77 | + | 
|  | 78 | +  cs: | 
|  | 79 | +    name: Coding Standard | 
|  | 80 | +    runs-on: ubuntu-24.04 | 
|  | 81 | + | 
|  | 82 | +    steps: | 
|  | 83 | +      - uses: actions/checkout@v4 | 
|  | 84 | + | 
|  | 85 | +      - name: Setup PHP | 
|  | 86 | +        uses: shivammathur/setup-php@v2 | 
|  | 87 | +        with: | 
|  | 88 | +          php-version: '8.2' | 
|  | 89 | +          extensions: mbstring, intl, apcu, memcached, redis | 
|  | 90 | +          tools: cs2pr | 
|  | 91 | +          coverage: none | 
|  | 92 | + | 
|  | 93 | +      - name: Get composer cache directory | 
|  | 94 | +        id: composer-cache | 
|  | 95 | +        run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | 
|  | 96 | + | 
|  | 97 | +      - name: Get date part for cache key | 
|  | 98 | +        id: key-date | 
|  | 99 | +        run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT | 
|  | 100 | + | 
|  | 101 | +      - name: Cache composer dependencies | 
|  | 102 | +        uses: actions/cache@v4 | 
|  | 103 | +        with: | 
|  | 104 | +          path: ${{ steps.composer-cache.outputs.dir }} | 
|  | 105 | +          key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }} | 
|  | 106 | + | 
|  | 107 | +      - name: composer install | 
|  | 108 | +        run: composer install | 
|  | 109 | + | 
|  | 110 | +      - name: Run PHP CodeSniffer | 
|  | 111 | +        run: composer cs-check | 
|  | 112 | +        continue-on-error: true | 
0 commit comments