]> granicus.if.org Git - php/commitdiff
Add basic libmysqlclient CI job
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 18 Sep 2020 09:32:05 +0000 (11:32 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 18 Dec 2020 11:52:54 +0000 (12:52 +0100)
This tests that mysqli and pdo_mysql build against libmysqlclient,
and that tests pass for pdo_mysql. mysqli has too many test failures.

This is not an officially supported configuration.

azure-pipelines.yml
azure/libmysqlclient_job.yml [new file with mode: 0644]
azure/libmysqlclient_test.yml [new file with mode: 0644]
ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt

index 7517e58bf20948e222ccdec53d3de64ebc6c34bd..49840e893c13f4a7c6b48f23d3f16993bdf3e92d 100644 (file)
@@ -108,3 +108,7 @@ jobs:
         configurationName: DEBUG_NTS_REPEAT
         configurationParameters: '--enable-debug --disable-zts'
         runTestsParameters: '--repeat 2'
+    - template: azure/libmysqlclient_job.yml
+       parameters:
+        configurationName: LIBMYSQLCLIENT_DEBUG_NTS
+        configurationParameters: '--enable-debug --disable-zts'
diff --git a/azure/libmysqlclient_job.yml b/azure/libmysqlclient_job.yml
new file mode 100644 (file)
index 0000000..72be927
--- /dev/null
@@ -0,0 +1,35 @@
+parameters:
+  configurationName: ''
+  configurationParameters: ''
+  runTestsParameters: ''
+  timeoutInMinutes: 60
+
+jobs:
+  - job: ${{ parameters.configurationName }}
+    timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
+    pool:
+      vmImage: 'ubuntu-20.04'
+    steps:
+    - script: |
+        sudo apt-get update -y | true
+        sudo apt install bison re2c
+      displayName: 'APT'
+    - script: |
+        set -o
+        sudo service mysql start
+        mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS test"
+      displayName: 'Setup MySQL server'
+    # Does not support caching_sha2_auth :(
+    #- template: libmysqlclient_test.yml
+    #  parameters:
+    #    configurationName: ${{ parameters.configurationName }} - MySQL 5.6.49
+    #    libmysql: mysql-5.6.49-linux-glibc2.12-x86_64.tar.gz
+    - template: libmysqlclient_test.yml
+      parameters:
+        configurationName: ${{ parameters.configurationName }} - MySQL 5.7.31
+        libmysql: mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
+    - template: libmysqlclient_test.yml
+      parameters:
+        configurationName: ${{ parameters.configurationName }} - MySQL 8.0.21
+        libmysql: mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz
+        configurationParameters: ${{ parameters.configurationParameters }} --enable-werror
diff --git a/azure/libmysqlclient_test.yml b/azure/libmysqlclient_test.yml
new file mode 100644 (file)
index 0000000..c163345
--- /dev/null
@@ -0,0 +1,53 @@
+parameters:
+  configurationName: ''
+  configurationParameters: ''
+  libmysql: ''
+
+steps:
+  - script: |
+      set -e
+      LIBMYSQL=${{ parameters.libmysql }}
+      MYSQL_BASE=${LIBMYSQL%%-linux-*}
+      MYSQL_VERSION=${MYSQL_BASE#*-}
+      MYSQL_DIR=$HOME/$MYSQL_BASE
+      mkdir -p $MYSQL_DIR
+      URL=https://cdn.mysql.com/Downloads/MySQL-${MYSQL_VERSION%.*}/$LIBMYSQL
+      wget -nv $URL
+      tar -xf $LIBMYSQL --strip-components=1 -C $MYSQL_DIR
+      PDO_MYSQL=${MYSQL_DIR}
+      MYSQLI=${MYSQL_DIR}/bin/mysql_config
+      ./buildconf --force
+      ./configure ${{ parameters.configurationParameters }} \
+          --enable-option-checking=fatal \
+          --disable-all \
+          --enable-pdo \
+          --with-pdo-mysql=${PDO_MYSQL} \
+          --with-mysqli=${MYSQLI}
+      make clean
+      make -j$(/usr/bin/nproc) >/dev/null
+    displayName: 'Build ${{ parameters.configurationName }}'
+    condition: or(succeeded(), failed())
+  - script: |
+      export MYSQL_TEST_USER=root
+      export MYSQL_TEST_PASSWD=root
+      export PDO_MYSQL_TEST_DSN="mysql:host=127.0.0.1;dbname=test"
+      export PDO_MYSQL_TEST_HOST=127.0.0.1
+      export PDO_MYSQL_TEST_USER=root
+      export PDO_MYSQL_TEST_PASS=root
+      export TEST_PHP_JUNIT=junit.xml
+      export REPORT_EXIT_STATUS=no
+      rm -rf junit.xml | true
+      sapi/cli/php run-tests.php -P -q \
+          -g FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP \
+          --offline --show-diff --show-slow 1000 --set-timeout 120 \
+          ext/pdo_mysql
+    displayName: 'Test ${{ parameters.configurationName }}'
+    condition: or(succeeded(), failed())
+  - task: PublishTestResults@2
+    inputs:
+      testResultsFormat: 'JUnit'
+      testResultsFiles: junit.xml
+      testRunTitle: '${{ parameters.configurationName }}'
+      failTaskOnFailedTests: true
+    displayName: 'Export ${{ parameters.configurationName }} Results'
+    condition: or(succeeded(), failed())
index 99cd631a4a2ca4a78aa3fff2b45da9de0cb9882d..55b923be71d5e34573f95cfc93efbdc494238301 100644 (file)
@@ -47,14 +47,21 @@ MySQLPDOTest::skip();
                     $db = new PDO($uri, $user, $pass);
                 } catch (PDOException $e) {
                     $expected = array(
-                        "SQLSTATE[HY000] [1049] Unknown database 'letshopeinvalid'",
-                        "SQLSTATE[42000] [1049] Unknown database 'letshopeinvalid'",
-                        "SQLSTATE[HY000] [2002] No such file or directory"
+                        "SQLSTATE[HY000] [1049]",
+                        "SQLSTATE[42000] [1049]",
+                        "SQLSTATE[HY000] [2002]"
                     );
+                    $isExpected = false;
+                    foreach ($expected as $prefix) {
+                        if (str_starts_with($e->getMessage(), $prefix)) {
+                            $isExpected = true;
+                        }
+                    }
+
                     printf("[003] URI=%s, DSN=%s, File=%s (%d bytes, '%s'), chr(0) test, %s\n",
                     $uri, $dsn,
                     $file, filesize($file), file_get_contents($file),
-                    (in_array($e->getMessage(), $expected) ? 'EXPECTED ERROR' : $e->getMessage()));
+                    ($isExpected ? 'EXPECTED ERROR' : $e->getMessage()));
                 }
                 unlink($file);
             }