From 029b855c774a11b1501a4dc32c4f5a79e11d5b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gamez?= Date: Sat, 22 May 2021 18:35:07 +0200 Subject: [PATCH 1/3] Add MySQL 8.0 to the test matrix --- .github/workflows/test-phpunit.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml index fecd1d78b317..589d96384cc0 100644 --- a/.github/workflows/test-phpunit.yml +++ b/.github/workflows/test-phpunit.yml @@ -42,10 +42,15 @@ jobs: matrix: php-versions: ['7.3', '7.4', '8.0'] db-platforms: ['MySQLi', 'Postgre', 'SQLite3', 'SQLSRV'] + mysql-versions: ['5.7'] + include: + - php-versions: 7.4 + db-platforms: MySQLi + mysql-versions: 8.0 services: mysql: - image: mysql:5.7 + image: mysql:${{ matrix.mysql-versions }} env: MYSQL_ALLOW_EMPTY_PASSWORD: yes MYSQL_DATABASE: test From 5e775bc8d18624f3308ffc41d36d8a39ba58269c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gamez?= Date: Sat, 22 May 2021 00:50:17 +0200 Subject: [PATCH 2/3] Skip coveralls when running on a forked repo --- .github/workflows/test-phpunit.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml index 589d96384cc0..c15f3694698d 100644 --- a/.github/workflows/test-phpunit.yml +++ b/.github/workflows/test-phpunit.yml @@ -138,7 +138,7 @@ jobs: DB: ${{ matrix.db-platforms }} TERM: xterm-256color - - if: matrix.php-versions == '7.4' + - if: github.repository_owner == 'codeigniter4' && matrix.php-versions == '7.4' name: Run Coveralls run: | composer global require php-coveralls/php-coveralls:^2.4 @@ -149,6 +149,7 @@ jobs: COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }} - ${{ matrix.db-platforms }} coveralls-finish: + if: github.repository_owner == 'codeigniter4' needs: [tests] runs-on: ubuntu-20.04 steps: From 5a3625dbc52293b219ce1d3a8a5384295f756011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gamez?= Date: Sat, 22 May 2021 18:09:49 +0200 Subject: [PATCH 3/3] Don't test the max_length attribute on MySQL >= 8.0.17 As of MySQL 8.0.17, the display width attribute for integer data types is deprecated and is not reported back anymore. https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html --- tests/system/Database/Live/ForgeTest.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/system/Database/Live/ForgeTest.php b/tests/system/Database/Live/ForgeTest.php index 9383b46af2bb..c7ea8fc4510b 100644 --- a/tests/system/Database/Live/ForgeTest.php +++ b/tests/system/Database/Live/ForgeTest.php @@ -249,8 +249,16 @@ public function testCreateTableWithArrayFieldConstraints() public function testCreateTableWithNullableFieldsGivesNullDataType(): void { $this->forge->addField([ - 'id' => ['type' => 'INT', 'constraint' => 11, 'auto_increment' => true], - 'name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'auto_increment' => true, + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => true, + ], ]); $createTable = $this->getPrivateMethodInvoker($this->forge, '_createTable'); @@ -620,7 +628,13 @@ public function testAddFields() $this->assertEquals($fieldsData[0]->type, 'int'); $this->assertEquals($fieldsData[1]->type, 'varchar'); - $this->assertEquals($fieldsData[0]->max_length, 11); + if (version_compare($this->db->getVersion(), '8.0.17', '<')) + { + // As of MySQL 8.0.17, the display width attribute for integer data types + // is deprecated and is not reported back anymore. + // @see https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html + $this->assertEquals($fieldsData[0]->max_length, 11); + } $this->assertNull($fieldsData[0]->default); $this->assertNull($fieldsData[1]->default);