From 1e75f1d53558114b2ec2e129af69dcb30fdc235d Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Mon, 14 Dec 2020 11:19:24 +0100 Subject: [PATCH] Move CI to GitHub Actions --- .github/workflows/ci.yml | 67 ++++++++++++++++++++---- .travis.yml | 79 ---------------------------- ci/install-geos.sh | 27 ---------- ci/install-mariadb.sh | 7 --- ci/install-postgis.sh | 15 ------ ci/install-spatialite.sh | 3 -- travis-matrix.php | 110 --------------------------------------- 7 files changed, 56 insertions(+), 252 deletions(-) delete mode 100644 .travis.yml delete mode 100644 ci/install-geos.sh delete mode 100644 ci/install-mariadb.sh delete mode 100644 ci/install-postgis.sh delete mode 100644 ci/install-spatialite.sh delete mode 100644 travis-matrix.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8c55a78..5007080e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,9 @@ jobs: strategy: matrix: php-version: + - "7.2" + - "7.3" + - "7.4" - "8.0" services: @@ -36,10 +39,11 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} + extensions: pdo_mysql coverage: xdebug - name: Install composer dependencies - run: composer install --no-interaction --no-progress --no-suggest + uses: "ramsey/composer-install@v1" - name: Run PHPUnit run: vendor/bin/phpunit @@ -61,6 +65,51 @@ jobs: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: ${{ matrix.php-version == '8.0' }} + phpunit-mariadb: + name: PHPUnit MariaDB + runs-on: ubuntu-20.04 + + strategy: + matrix: + php-version: + - "8.0" + + services: + mariadb: + image: "mariadb:10.1" + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + options: >- + --health-cmd "mysqladmin ping --silent" + ports: + - "3306:3306" + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: pdo_mysql + coverage: xdebug + + - name: Install composer dependencies + uses: "ramsey/composer-install@v1" + + - name: Run PHPUnit with coverage + run: | + mkdir -p mkdir -p build/logs + vendor/bin/phpunit --coverage-clover build/logs/clover.xml + env: + ENGINE: PDO_MYSQL + + - name: Upload coverage report to Coveralls + run: vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + phpunit-postgres: name: PHPUnit PostgreSQL runs-on: ubuntu-20.04 @@ -85,10 +134,11 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} + extensions: pdo_pgsql coverage: xdebug - name: Install composer dependencies - run: composer install --no-interaction --no-progress --no-suggest + uses: "ramsey/composer-install@v1" - name: Run PHPUnit with coverage run: | @@ -127,7 +177,7 @@ jobs: run: sudo apt install libsqlite3-mod-spatialite - name: Install composer dependencies - run: composer install --no-interaction --no-progress --no-suggest + uses: "ramsey/composer-install@v1" - name: Run PHPUnit with coverage run: | @@ -158,23 +208,18 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} + extensions: geos coverage: xdebug - - name: Install GEOS - run: bash ci/install-geos.sh - - - name: Setup Debug Session - uses: csexton/debugger-action@master - - name: Install composer dependencies - run: composer install --no-interaction --no-progress --no-suggest + uses: "ramsey/composer-install@v1" - name: Run PHPUnit with coverage run: | mkdir -p mkdir -p build/logs vendor/bin/phpunit --coverage-clover build/logs/clover.xml env: - ENGINE: SQLite3 + ENGINE: GEOS - name: Upload coverage report to Coveralls run: vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8df91ad8..00000000 --- a/.travis.yml +++ /dev/null @@ -1,79 +0,0 @@ -language: php -sudo: required - -# use ci-matrix.php to generate the matrix below - -matrix: - include: - - php: 7.2 - env: ENGINE=PDO_MYSQL - dist: bionic - - php: 7.2 - env: ENGINE=PDO_MYSQL_MARIADB - dist: bionic - - php: 7.2 - env: ENGINE=PDO_PGSQL - dist: bionic - - php: 7.2 - env: ENGINE=SQLite3 - dist: bionic - - php: 7.2 - env: ENGINE=GEOS - dist: bionic - - php: 7.3 - env: ENGINE=PDO_MYSQL - dist: bionic - - php: 7.3 - env: ENGINE=PDO_MYSQL_MARIADB - dist: bionic - - php: 7.3 - env: ENGINE=PDO_PGSQL - dist: bionic - - php: 7.3 - env: ENGINE=SQLite3 - dist: bionic - - php: 7.3 - env: ENGINE=GEOS - dist: bionic - - php: 7.4 - env: ENGINE=PDO_MYSQL - dist: bionic - - php: 7.4 - env: ENGINE=PDO_MYSQL_MARIADB - dist: bionic - - php: 7.4 - env: ENGINE=PDO_PGSQL - dist: bionic - - php: 7.4 - env: ENGINE=SQLite3 - dist: bionic - - php: 7.4 - env: ENGINE=GEOS - dist: bionic - - php: 8.0 - env: ENGINE=PDO_MYSQL - dist: focal - - php: 8.0 - env: ENGINE=PDO_MYSQL_MARIADB - dist: focal - - php: 8.0 - env: ENGINE=PDO_PGSQL - dist: focal - - php: 8.0 - env: ENGINE=SQLite3 - dist: focal - -before_script: - - if [[ $ENGINE = PDO_MYSQL ]]; then ENGINE=PDO_MYSQL; sudo apt-get install mysql-server; sudo systemctl start mysql; fi; - - if [[ $ENGINE = PDO_MYSQL_MARIADB ]]; then ENGINE=PDO_MYSQL; bash ci/install-mariadb.sh; fi; - - if [[ $ENGINE = PDO_PGSQL ]]; then bash ci/install-postgis.sh; fi; - - if [[ $ENGINE = GEOS ]]; then bash ci/install-geos.sh; fi; - - if [[ $ENGINE = SQLite3 ]]; then sudo PHP_VERSION=$(php -r "echo PHP_VERSION;") bash ci/install-spatialite.sh; fi; - - composer install - -script: - - mkdir -p build/logs - - vendor/bin/phpunit --coverage-clover build/logs/clover.xml - -after_script: - - vendor/bin/php-coveralls -v diff --git a/ci/install-geos.sh b/ci/install-geos.sh deleted file mode 100644 index 2a7468c5..00000000 --- a/ci/install-geos.sh +++ /dev/null @@ -1,27 +0,0 @@ -set -e - -GEOS_VERSION=3.8.0 -PHP_GEOS_VERSION=1.0.0 - -sudo apt update -sudo apt autoremove - -wget https://github.com/libgeos/geos/archive/$GEOS_VERSION.tar.gz -tar zxf $GEOS_VERSION.tar.gz -cd geos-$GEOS_VERSION -./autogen.sh -./configure --prefix=/usr -make -sudo make install -cd .. - -wget https://github.com/libgeos/php-geos/archive/$PHP_GEOS_VERSION.tar.gz -tar zxf $PHP_GEOS_VERSION.tar.gz -cd php-geos-$PHP_GEOS_VERSION -./autogen.sh -./configure -make -sudo mv modules/geos.so $(php-config --extension-dir) -cd .. - -echo "extension=geos.so" > geos.ini diff --git a/ci/install-mariadb.sh b/ci/install-mariadb.sh deleted file mode 100644 index 5cc016a6..00000000 --- a/ci/install-mariadb.sh +++ /dev/null @@ -1,7 +0,0 @@ -sudo apt update -sudo apt install mariadb-server-10.1 mariadb-client-10.1 - -echo " -UPDATE mysql.user SET plugin = '' where User = 'root'; -FLUSH PRIVILEGES; -" | sudo mysql diff --git a/ci/install-postgis.sh b/ci/install-postgis.sh deleted file mode 100644 index 93256d14..00000000 --- a/ci/install-postgis.sh +++ /dev/null @@ -1,15 +0,0 @@ -set -e - -sudo apt update -sudo apt autoremove postgis* -sudo apt autoremove postgresql* -sudo apt install postgresql-11 postgresql-11-postgis-2.5 - -echo "starting" -sudo service postgresql start 11 - -echo "sleeping" -sleep 10 - -echo "create ext" -psql -d postgres -c "CREATE EXTENSION postgis;" diff --git a/ci/install-spatialite.sh b/ci/install-spatialite.sh deleted file mode 100644 index b9520d0d..00000000 --- a/ci/install-spatialite.sh +++ /dev/null @@ -1,3 +0,0 @@ -apt update -apt install libsqlite3-mod-spatialite -echo "sqlite3.extension_dir = /usr/lib/x86_64-linux-gnu" >> "/home/travis/.phpenv/versions/$PHP_VERSION/etc/php.ini" diff --git a/travis-matrix.php b/travis-matrix.php deleted file mode 100644 index d72f64c0..00000000 --- a/travis-matrix.php +++ /dev/null @@ -1,110 +0,0 @@ - ['trusty', 'xenial', 'bionic'], - '7.3' => ['trusty', 'xenial', 'bionic'], - '7.4' => ['trusty', 'xenial', 'bionic'], - '8.0' => ['xenial', 'bionic', 'focal'], -]; - -/** @var Job[] $jobs */ -$jobs = []; - -foreach ($phpVersions as $phpVersion) { - foreach ($engines as $engine) { - $job = new Job(); - - $dist = getDist($phpVersion, $engine); - - if ($dist === null) { - continue; - } - - $job->phpVersion = $phpVersion; - $job->engine = $engine; - $job->dist = $dist; - - $jobs[] = $job; - } -} - -echo "matrix:\n"; -echo " include:\n"; - -foreach ($jobs as $job) { - echo " - php: {$job->phpVersion}\n"; - echo " env: ENGINE={$job->engine}\n"; - echo " dist: {$job->dist}\n"; -} - -function getDist(string $phpVersion, string $engine): ?string -{ - global $latestDist; - global $requires; - - if ($phpVersion === '8.0' && $engine === 'GEOS') { - // GEOS PHP does not support PHP 8 yet - // See: https://git.osgeo.org/gitea/geos/php-geos/issues/26 - return null; - } - - $requiredDists = []; - - foreach ([$phpVersion, $engine] as $key) { - if (isset($requires[$key])) { - $requiredDists[] = (array) $requires[$key]; - } - } - - switch (count($requiredDists)) { - case 0: - return $latestDist; - - case 1: - return $requiredDists[0][count($requiredDists[0]) - 1]; - - default: - $dists = array_values(array_intersect($requiredDists[0], $requiredDists[1])); - - if (! $dists) { - // conflicting requirements; can't run! - return null; - } - - return $dists[count($dists) - 1]; - } -} - -class Job { - /** @var string */ - public $phpVersion; - - /** @var string */ - public $engine; - - /** @var string */ - public $dist; -}