mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #10416 from creative-commoners/pulls/4.10/backport-ci
MNT Add GitHub Actions CI
This commit is contained in:
commit
5a91cfca8a
16
.github/workflows/ci.yml
vendored
Normal file
16
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
# Every Tuesday at 2:20pm UTC
|
||||||
|
schedule:
|
||||||
|
- cron: '20 14 * * 2'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
|
||||||
|
with:
|
||||||
|
# Turn phpcoverage off because it causes a segfault
|
||||||
|
phpcoverage_force_off: true
|
16
.github/workflows/keepalive.yml
vendored
Normal file
16
.github/workflows/keepalive.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
name: Keepalive
|
||||||
|
|
||||||
|
on:
|
||||||
|
# The 4th of every month at 10:50am UTC
|
||||||
|
schedule:
|
||||||
|
- cron: '50 10 4 * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
keepalive:
|
||||||
|
name: Keepalive
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Keepalive
|
||||||
|
uses: silverstripe/gha-keepalive@v1
|
@ -1,6 +1,6 @@
|
|||||||
## SilverStripe Framework
|
## SilverStripe Framework
|
||||||
|
|
||||||
[![Build Status](https://api.travis-ci.com/silverstripe/silverstripe-framework.svg?branch=4)](https://travis-ci.com/silverstripe/silverstripe-framework)
|
[![CI](https://github.com/silverstripe/silverstripe-framework/actions/workflows/ci.yml/badge.svg)](https://github.com/silverstripe/silverstripe-framework/actions/workflows/ci.yml)
|
||||||
[![Build Docs](https://github.com/silverstripe/silverstripe-framework/workflows/Build%20Docs/badge.svg)](https://docs.silverstripe.org/)
|
[![Build Docs](https://github.com/silverstripe/silverstripe-framework/workflows/Build%20Docs/badge.svg)](https://docs.silverstripe.org/)
|
||||||
[![Latest Stable Version](https://poser.pugx.org/silverstripe/framework/version.svg)](https://www.silverstripe.org/stable-download/)
|
[![Latest Stable Version](https://poser.pugx.org/silverstripe/framework/version.svg)](https://www.silverstripe.org/stable-download/)
|
||||||
[![Latest Unstable Version](https://poser.pugx.org/silverstripe/framework/v/unstable.svg)](https://packagist.org/packages/silverstripe/framework)
|
[![Latest Unstable Version](https://poser.pugx.org/silverstripe/framework/v/unstable.svg)](https://packagist.org/packages/silverstripe/framework)
|
||||||
|
34
behat.yml
34
behat.yml
@ -1,34 +0,0 @@
|
|||||||
# Run framework behat tests with this command (installed with silverstripe/installer)
|
|
||||||
# Note that framework behat tests require CMS module
|
|
||||||
# ========================================================================= #
|
|
||||||
# vendor/bin/selenium-server-standalone -Dwebdriver.firefox.bin="/Applications/Firefox31.app/Contents/MacOS/firefox-bin"
|
|
||||||
# vendor/bin/serve --bootstrap-file vendor/silverstripe/framework/tests/behat/serve-bootstrap.php
|
|
||||||
# vendor/bin/behat @framework
|
|
||||||
# ========================================================================= #
|
|
||||||
default:
|
|
||||||
suites:
|
|
||||||
framework:
|
|
||||||
paths:
|
|
||||||
- "%paths.modules.admin%/tests/behat/features"
|
|
||||||
contexts:
|
|
||||||
- SilverStripe\Framework\Tests\Behaviour\FeatureContext
|
|
||||||
- SilverStripe\Framework\Tests\Behaviour\CmsFormsContext
|
|
||||||
- SilverStripe\Framework\Tests\Behaviour\CmsUiContext
|
|
||||||
- SilverStripe\BehatExtension\Context\BasicContext
|
|
||||||
- SilverStripe\BehatExtension\Context\EmailContext
|
|
||||||
- SilverStripe\BehatExtension\Context\LoginContext
|
|
||||||
-
|
|
||||||
SilverStripe\BehatExtension\Context\FixtureContext:
|
|
||||||
- "%paths.modules.admin%/tests/behat/features/files/"
|
|
||||||
|
|
||||||
extensions:
|
|
||||||
SilverStripe\BehatExtension\MinkExtension:
|
|
||||||
default_session: facebook_web_driver
|
|
||||||
javascript_session: facebook_web_driver
|
|
||||||
facebook_web_driver:
|
|
||||||
browser: chrome
|
|
||||||
wd_host: "http://127.0.0.1:9515" #chromedriver port
|
|
||||||
|
|
||||||
SilverStripe\BehatExtension\Extension:
|
|
||||||
screenshot_path: "%paths.base%/artifacts/screenshots"
|
|
||||||
bootstrap_file: "tests/behat/serve-bootstrap.php"
|
|
@ -8,6 +8,7 @@ use SilverStripe\ORM\DB;
|
|||||||
use SilverStripe\ORM\FieldType\DBEnum;
|
use SilverStripe\ORM\FieldType\DBEnum;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\ORM\Connect\MySQLiConnector;
|
||||||
use SilverStripe\ORM\Tests\DataObjectSchemaGenerationTest\SortedObject;
|
use SilverStripe\ORM\Tests\DataObjectSchemaGenerationTest\SortedObject;
|
||||||
use SilverStripe\ORM\Tests\DataObjectSchemaGenerationTest\TestIndexObject;
|
use SilverStripe\ORM\Tests\DataObjectSchemaGenerationTest\TestIndexObject;
|
||||||
use SilverStripe\ORM\Tests\DataObjectSchemaGenerationTest\TestObject;
|
use SilverStripe\ORM\Tests\DataObjectSchemaGenerationTest\TestObject;
|
||||||
@ -67,11 +68,26 @@ class DataObjectSchemaGenerationTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function isMySQL8(): bool
|
||||||
|
{
|
||||||
|
$connector = DB::get_conn()->getConnector();
|
||||||
|
if ($connector instanceof MySQLiConnector &&
|
||||||
|
preg_match('#^8\.#', $connector->getVersion())
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that once a schema has been generated, then it doesn't need any more updating
|
* Check that once a schema has been generated, then it doesn't need any more updating
|
||||||
*/
|
*/
|
||||||
public function testFieldsDontRerequestChanges()
|
public function testFieldsDontRerequestChanges()
|
||||||
{
|
{
|
||||||
|
// TODO: remove the MySQL8 skip when `int(11)` is no longer the default field type for integers and has been replaced with `int`
|
||||||
|
if ($this->isMySQL8()) {
|
||||||
|
$this->markTestSkipped();
|
||||||
|
}
|
||||||
$schema = DB::get_schema();
|
$schema = DB::get_schema();
|
||||||
$test = $this;
|
$test = $this;
|
||||||
DB::quiet();
|
DB::quiet();
|
||||||
@ -126,6 +142,10 @@ class DataObjectSchemaGenerationTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function testIndexesDontRerequestChanges()
|
public function testIndexesDontRerequestChanges()
|
||||||
{
|
{
|
||||||
|
// TODO: remove the MySQL8 skip when `int(11)` is no longer the default field type for integers and has been replaced with `int`
|
||||||
|
if ($this->isMySQL8()) {
|
||||||
|
$this->markTestSkipped();
|
||||||
|
}
|
||||||
$schema = DB::get_schema();
|
$schema = DB::get_schema();
|
||||||
$test = $this;
|
$test = $this;
|
||||||
DB::quiet();
|
DB::quiet();
|
||||||
|
@ -9,6 +9,7 @@ use SilverStripe\Dev\SapphireTest;
|
|||||||
use SilverStripe\Dev\TestOnly;
|
use SilverStripe\Dev\TestOnly;
|
||||||
use SilverStripe\ORM\Tests\MySQLPDOConnectorTest\PDOConnector;
|
use SilverStripe\ORM\Tests\MySQLPDOConnectorTest\PDOConnector;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\Tests\ORM\Utf8\Utf8TestHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires extension PDO
|
* @requires extension PDO
|
||||||
@ -38,8 +39,9 @@ class MySQLPDOConnectorTest extends SapphireTest implements TestOnly
|
|||||||
$cset = $connection->query('show variables like "character_set_connection"')->fetch(PDO::FETCH_NUM)[1];
|
$cset = $connection->query('show variables like "character_set_connection"')->fetch(PDO::FETCH_NUM)[1];
|
||||||
$collation = $connection->query('show variables like "collation_connection"')->fetch(PDO::FETCH_NUM)[1];
|
$collation = $connection->query('show variables like "collation_connection"')->fetch(PDO::FETCH_NUM)[1];
|
||||||
|
|
||||||
$this->assertEquals($charset, $cset);
|
$helper = new Utf8TestHelper();
|
||||||
$this->assertEquals($defaultCollation, $collation);
|
$this->assertEquals($helper->getUpdatedUtfCharsetForCurrentDB($charset), $cset);
|
||||||
|
$this->assertEquals($helper->getUpdatedUtfCollationForCurrentDB($defaultCollation), $collation);
|
||||||
|
|
||||||
unset($cset, $connection, $connector, $config);
|
unset($cset, $connection, $connector, $config);
|
||||||
}
|
}
|
||||||
@ -66,8 +68,9 @@ class MySQLPDOConnectorTest extends SapphireTest implements TestOnly
|
|||||||
$cset = $connection->query('show variables like "character_set_connection"')->fetch(PDO::FETCH_NUM)[1];
|
$cset = $connection->query('show variables like "character_set_connection"')->fetch(PDO::FETCH_NUM)[1];
|
||||||
$collation = $connection->query('show variables like "collation_connection"')->fetch(PDO::FETCH_NUM)[1];
|
$collation = $connection->query('show variables like "collation_connection"')->fetch(PDO::FETCH_NUM)[1];
|
||||||
|
|
||||||
$this->assertEquals($charset, $cset);
|
$helper = new Utf8TestHelper();
|
||||||
$this->assertEquals($customCollation, $collation);
|
$this->assertEquals($helper->getUpdatedUtfCharsetForCurrentDB($charset), $cset);
|
||||||
|
$this->assertEquals($helper->getUpdatedUtfCollationForCurrentDB($customCollation), $collation);
|
||||||
|
|
||||||
unset($cset, $connection, $connector, $config);
|
unset($cset, $connection, $connector, $config);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ use SilverStripe\Dev\SapphireTest;
|
|||||||
use SilverStripe\Dev\TestOnly;
|
use SilverStripe\Dev\TestOnly;
|
||||||
use SilverStripe\ORM\Tests\MySQLiConnectorTest\MySQLiConnector;
|
use SilverStripe\ORM\Tests\MySQLiConnectorTest\MySQLiConnector;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\Tests\ORM\Utf8\Utf8TestHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires extension mysqli
|
* @requires extension mysqli
|
||||||
@ -31,6 +32,10 @@ class MySQLiConnectorTest extends SapphireTest implements TestOnly
|
|||||||
|
|
||||||
$cset = $connection->get_charset();
|
$cset = $connection->get_charset();
|
||||||
|
|
||||||
|
// Note: we do not need to update the utf charset here because mysqli with newer
|
||||||
|
// version of mysql/mariadb still self-reports as 'utf8' rather than 'utf8mb3'
|
||||||
|
// This is unlike self::testConnectionCollationControl()
|
||||||
|
// And also unlike MySQLPDOConnectorTest::testConnectionCharsetControl()
|
||||||
$this->assertEquals($charset, $cset->charset);
|
$this->assertEquals($charset, $cset->charset);
|
||||||
$this->assertEquals($defaultCollation, $cset->collation);
|
$this->assertEquals($defaultCollation, $cset->collation);
|
||||||
|
|
||||||
@ -77,8 +82,9 @@ class MySQLiConnectorTest extends SapphireTest implements TestOnly
|
|||||||
$cset = $connection->query('show variables like "character_set_connection"')->fetch_array()[1];
|
$cset = $connection->query('show variables like "character_set_connection"')->fetch_array()[1];
|
||||||
$collation = $connection->query('show variables like "collation_connection"')->fetch_array()[1];
|
$collation = $connection->query('show variables like "collation_connection"')->fetch_array()[1];
|
||||||
|
|
||||||
$this->assertEquals($charset, $cset);
|
$helper = new Utf8TestHelper();
|
||||||
$this->assertEquals($customCollation, $collation);
|
$this->assertEquals($helper->getUpdatedUtfCharsetForCurrentDB($charset), $cset);
|
||||||
|
$this->assertEquals($helper->getUpdatedUtfCollationForCurrentDB($customCollation), $collation);
|
||||||
|
|
||||||
$connection->close();
|
$connection->close();
|
||||||
unset($cset, $connection, $connector, $config);
|
unset($cset, $connection, $connector, $config);
|
||||||
|
69
tests/php/ORM/Utf8/Utf8TestHelper.php
Normal file
69
tests/php/ORM/Utf8/Utf8TestHelper.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Tests\ORM\Utf8;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
|
class Utf8TestHelper implements TestOnly
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
private $dbVersion = null;
|
||||||
|
|
||||||
|
public function getUpdatedUtfCharsetForCurrentDB(string $charset): string
|
||||||
|
{
|
||||||
|
if ($charset !== 'utf8') {
|
||||||
|
return $charset;
|
||||||
|
}
|
||||||
|
return $this->isMySqlGte80() || $this->isMariaDBGte106() ? 'utf8mb3' : 'utf8';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUpdatedUtfCollationForCurrentDB(string $collation): string
|
||||||
|
{
|
||||||
|
if ($collation === 'utf8_general_ci') {
|
||||||
|
return $this->isMariaDBGte106() ? 'utf8mb3_general_ci' : 'utf8_general_ci';
|
||||||
|
}
|
||||||
|
if ($collation === 'utf8_unicode_520_ci') {
|
||||||
|
return $this->isMariaDBGte106() ? 'utf8mb3_unicode_520_ci' : 'utf8_unicode_520_ci';
|
||||||
|
}
|
||||||
|
return $collation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MySQL has used utf8 as an alias for utf8mb3
|
||||||
|
* Beginning with MySQL 8.0.28, utf8mb3 is used
|
||||||
|
* https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html
|
||||||
|
*/
|
||||||
|
private function isMySqlGte80(): bool
|
||||||
|
{
|
||||||
|
// Example MySQL version: 8.0.29
|
||||||
|
if (preg_match('#^([0-9]+)\.[0-9]+\.[0-9]+$#', $this->getDBVersion(), $m)) {
|
||||||
|
return (int) $m[1] >= 8;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Until MariaDB 10.5, utf8mb3 was an alias for utf8.
|
||||||
|
* From MariaDB 10.6, utf8 is by default an alias for utf8mb3
|
||||||
|
* https://mariadb.com/kb/en/unicode/
|
||||||
|
*/
|
||||||
|
private function isMariaDBGte106(): bool
|
||||||
|
{
|
||||||
|
// Example mariadb version: 5.5.5-10.6.8-mariadb-1:10.6.8+maria~focal
|
||||||
|
if (preg_match('#([0-9]+)\.([0-9]+)\.[0-9]+-mariadb#', $this->getDBVersion(), $m)) {
|
||||||
|
return (int) $m[1] >= 11 || ((int) $m[1] >= 10 && (int) $m[2] >= 6);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDBVersion(): string
|
||||||
|
{
|
||||||
|
if (is_null($this->dbVersion)) {
|
||||||
|
$this->dbVersion = strtolower(DB::get_conn()->getVersion());
|
||||||
|
}
|
||||||
|
return $this->dbVersion;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user