longitude-one/doctrine-spatial

View on GitHub
.github/workflows/full.yaml

Summary

Maintainability
Test Coverage
name: Full tests
on:
  schedule:
    - cron: '0 17 * * 4'
  push:
    branches:
      - main
      - 5.1.x-dev
      - 6.x-dev
    paths-ignore:
      - '**.md'
      - '**.rst'
      - '.readthedocs.yaml'
      - 'LICENSE'
  pull_request:
    branches:
      - main
      - 5.1.x-dev
      - 6.x-dev
    paths-ignore:
      - '**.md'
      - '**.rst'
      - '.readthedocs.yaml'
      - 'LICENSE'

permissions:
  contents: read

jobs:
  stable-build:
    runs-on: ubuntu-latest
    environment: 'Test environment'
    name: PHP 8.3 - doctrine/orm ^3.1
    env:
      HAS_CC_SECRET: ${{secrets.CC_TEST_REPORTER_ID != '' }}
      HAS_CA_SECRET: ${{secrets.COVERALLS_REPO_TOKEN != '' }}
    services:
      mysql5:
        image: mysql:5.7
        env:
          MYSQL_DATABASE: main
          MYSQL_USER: main
          MYSQL_PASSWORD: main
          MYSQL_ROOT_PASSWORD: main
        ports:
          - 3357:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
      mysql8:
        image: mysql:8.0
        env:
          MYSQL_DATABASE: main
          MYSQL_USER: main
          MYSQL_PASSWORD: main
          MYSQL_ROOT_PASSWORD: main
        ports:
          - 3380:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
      postgres:
        # Docker Hub image
        image: postgis/postgis
        # Provide the password for postgres
        env:
          POSTGRES_PASSWORD: main
          POSTGRES_USER: main
          POSTGRES_DATABASE: main
        ports:
          - 5432:5432
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Validate composer.json
        run: composer validate --strict

      - name: Create the composer.lock for the cache key
        run: composer update --no-install

      - name: Restore cache Composer dependencies
        uses: actions/cache@v4
        with:
          path: vendor/
          key: ${{ format('{0}-composer-php83-orm31-{1}', runner.os, hashFiles('composer.lock')) }}
          restore-keys: ${{ format('{0}-composer-php83-orm31-', runner.os, matrix.php, matrix.orm) }}

      - name: Setup PHP 8.3
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.3
          coverage: pcov
          tools: composer:v2

      - name: Echo PHP version
        run: php -v

      - name: Copy test suites
        run: cp .github/phpunit.*.xml .

      - name: Install libraries
        run: composer install -vvv

      - name: Show libraries
        run: composer show

      - name: Run test suite and with coverage for codeclimate for PHP 8.3 and doctrine/orm ^3.1 only
        if: ${{ env.HAS_CC_SECRET == 'true' }}
        uses: paambaati/codeclimate-action@v6.0.0
        env:
           CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
        with:
           coverageCommand: composer run-script test-coverage
           coverageLocations: ${{github.workspace}}/.phpunit.cache/code-coverage/clover*.xml:clover

      - name: Run test suite for forks or version without code coverage
        if: ${{ env.HAS_CC_SECRET != 'true' }}
        run: composer run-script test

      - name: Coveralls.io steps
        if: ${{ env.HAS_CA_SECRET == 'true' }}
        uses: coverallsapp/github-action@v2
        with:
          github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
          file: ${{github.workspace}}/.phpunit.cache/code-coverage/clover.xml

      ## Quality checks
      ## PHP-CS-Fixer is needed with only one version of PHP
      - name: Create the PHP-CS-Fixer composer.lock for the cache key
        run: composer update --working-dir=quality/php-cs-fixer --no-install

      - name: Cache Composer PHP-CS-FIXER packages
        id: composer-phpcsfixer-cache
        uses: actions/cache@v4
        with:
          path: quality/php-cs-fixer/vendor/
          key: ${{ format('{0}-phpcsfixer-{1}', runner.os, hashFiles('quality/php-cs-fixer/vendor/composer.lock')) }}
          restore-keys: ${{ format('{0}-phpcsfixer-', runner.os) }}

      - name: Install PHP-CS-Fixer
        run: composer install --working-dir=quality/php-cs-fixer

      - name: Run PHP-CS-Fixer
        run: ./quality/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=quality/php-cs-fixer/.php-cs-fixer.php --dry-run --allow-risky=yes

      ## PHP-MESS-DETECTOR
      - name: Create the PHP-MESS-DETECTOR composer.lock for the cache key
        run: composer update --working-dir=quality/php-mess-detector --no-install

      - name: Cache Composer PHP-MESS-DETECTOR packages
        id: composer-phpmd-cache
        uses: actions/cache@v4
        with:
          path: quality/php-mess-detector/vendor/
          key: ${{ format('{0}-phpmd-{1}', runner.os, hashFiles('quality/php-mess-detector/vendor/composer.lock')) }}
          restore-keys: ${{ format('{0}-phpmd-', runner.os) }}

      - name: Install PHP-MESS-DETECTOR
        run: composer update --working-dir=quality/php-mess-detector
      - name: Run PHP-MESS-DETECTOR on lib directory
        run: ./quality/php-mess-detector/vendor/bin/phpmd lib text quality/php-mess-detector/ruleset.xml
      - name: Run PHP-MESS-DETECTOR on tests directory
        run: ./quality/php-mess-detector/vendor/bin/phpmd tests text quality/php-mess-detector/test-ruleset.xml

      ## PHP CODE SNIFFER
      - name: Create the PHP CODE SNIFFER composer.lock for the cache key
        run: composer update --working-dir=quality/php-code-sniffer --no-install

      - name: Cache Composer PHP-CS packages
        id: composer-php-cs-cache
        uses: actions/cache@v4
        with:
          path: quality/php-code-sniffer/vendor/
          key: ${{ format('{0}-phpcs-{1}', runner.os, hashFiles('quality/php-code-sniffer/vendor/composer.lock')) }}
          restore-keys: ${{ format('{0}-phpcs-', runner.os) }}

      - name: Install PHP-CS
        run: composer update --working-dir=quality/php-code-sniffer

      - name: Run PHP-CS
        run: ./quality/php-code-sniffer/vendor/bin/phpcs --standard=quality/php-code-sniffer/phpcs.xml -s

      ## PHP-STAN
      - name: Create the PHP-STAN composer.lock for the cache key
        run: composer update --working-dir=quality/php-stan --no-install

      - name: Cache Composer PHP-STAN packages
        id: composer-php-stan-cache
        uses: actions/cache@v4
        with:
          path: quality/php-stan/vendor/
          key: ${{ format('{0}-phpstan-{1}', runner.os, hashFiles('quality/php-stan/vendor/composer.lock')) }}
          restore-keys: ${{ format('{0}-phpstan-', runner.os) }}

      - name: Install PHP-STAN
        run: composer update --working-dir=quality/php-stan
      - name: Run PHP-STAN
        run: ./quality/php-stan/vendor/bin/phpstan analyse --configuration=quality/php-stan/php-stan.neon lib tests --error-format=table --no-progress --no-interaction --no-ansi --level=9 --memory-limit=256M -v

  other-version-build:
    needs: stable-build
    runs-on: ubuntu-latest
    continue-on-error: ${{ matrix.orm == '^3.2' || matrix.orm == '^4.0'}}
    environment: 'Test environment'
    strategy:
      fail-fast: false
      matrix:
        php: [ '8.1', '8.2', '8.3' ]
        orm: [ '^2.9', '^3.1', '^3.2', '^4.0' ]
        exclude:
          # Already tested
          -   php: '8.3'
              orm: '^3.1'
    name: PHP${{ matrix.php }} - doctrine/orm ${{ matrix.orm }}
    services:
      mysql5:
        image: mysql:5.7
        env:
          MYSQL_DATABASE: main
          MYSQL_USER: main
          MYSQL_PASSWORD: main
          MYSQL_ROOT_PASSWORD: main
        ports:
          - 3357:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
      mysql8:
        image: mysql:8.0
        env:
          MYSQL_DATABASE: main
          MYSQL_USER: main
          MYSQL_PASSWORD: main
          MYSQL_ROOT_PASSWORD: main
        ports:
          - 3380:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
      postgres:
        # Docker Hub image
        image: postgis/postgis
        # Provide the password for postgres
        env:
          POSTGRES_PASSWORD: main
          POSTGRES_USER: main
          POSTGRES_DATABASE: main
        ports:
          - 5432:5432
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
    steps:
      -   name: Checkout code
          uses: actions/checkout@v4

      -   name: Validate composer.json
          run: composer validate --strict

      - name: Create the composer.lock for the cache key
        run: composer update --no-install

      -   name: Restore cache Composer dependencies
          uses: actions/cache@v4
          with:
            path: vendor/
            key: ${{ format('{0}-composer-php{1}-orm{2}-{3}', runner.os, matrix.php, matrix.orm, hashFiles('composer.lock')) }}
            restore-keys: ${{ format('{0}-composer-php{1}-orm{2}-', runner.os, matrix.php, matrix.orm) }}

      -   name: Setup PHP ${{ matrix.php }}
          uses: shivammathur/setup-php@v2
          with:
            php-version: ${{ matrix.php }}
            coverage: pcov
            tools: composer:v2

      -   name: Echo PHP version
          run: php -v

      -   name: Copy test suites
          run: cp .github/phpunit.*.xml .

      -   name: Force doctrine/orm library to ${{ matrix.orm }}
          run: composer --prefer-stable require doctrine/orm:${{ matrix.orm }} --with-all-dependencies

      -   name: Run test suite for forks or version without code coverage
          run: composer run-script test