From 8744adb89a1a3d14ef4f2fe1b65c9071797c0ba1 Mon Sep 17 00:00:00 2001
From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
Date: Sat, 10 Dec 2022 14:15:54 +0100
Subject: [PATCH] Migrate MySQL latest driver test to GitHub Actions (#27071)

* Migrate MySQL latest driver test to GitHub Actions

* Increase the timeout for MySQL latest driver test

* Make env vars available to the host machine

* Increase the timeout again

* Bump timeout to 1h for all driver tests
---
 .circleci/config.yml          | 35 --------------------
 .github/workflows/drivers.yml | 62 +++++++++++++++++++++++++++--------
 2 files changed, 49 insertions(+), 48 deletions(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index a1a16b34b76..9695f4be7b0 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -27,19 +27,6 @@ executors:
     docker:
       - image: metabase/ci:java-17-clj-1.11.0.1100.04-2022-build
 
-  mysql-latest:
-    working_directory: /home/circleci/metabase/metabase/
-    docker:
-      - image: metabase/ci:java-11-clj-1.11.0.1100.04-2022-build
-        environment:
-          MB_DB_TYPE: mysql
-          MB_DB_HOST: localhost
-          MB_DB_PORT: 3306
-          MB_DB_DBNAME: circle_test
-          MB_DB_USER: root
-          MB_MYSQL_TEST_USER: root
-      - image: circleci/mysql:latest
-
   mongo-4-0-ssl:
      working_directory: /home/circleci/metabase/metabase/
      docker:
@@ -607,28 +594,6 @@ workflows:
             MB_MONGO_TEST_USER=metabase
             MB_MONGO_TEST_PASSWORD=metasample123
 
-      - test-driver:
-          name: be-tests-mysql-latest-ee
-          description: "(MySQL latest)"
-          requires:
-            - be-deps
-          e:
-            name: mysql-latest
-          driver: mysql
-          # set up env vars for something named "MYSQL_SSL" to run MySQL SSL tests verifying connectivity with PEM cert
-          # they are deliberately given a different name to prevent them from affecting the regular test run against
-          # the configured MySQL instance, but there is one particular test (mysql-connect-with-ssl-and-pem-cert-test)
-          # that overrides the MB_MYSQL_TEST_* values with them
-          # the MYSQL_RDS_SSL_INSTANCE vars are secret and/or changeable, so they are defined in the CircleCI settings
-          timeout: 30m
-          extra-env: >-
-            MB_MYSQL_SSL_TEST_HOST=$MYSQL_RDS_SSL_INSTANCE_HOST
-            MB_MYSQL_SSL_TEST_SSL=true
-            MB_MYSQL_SSL_TEST_ADDITIONAL_OPTIONS='verifyServerCertificate=true'
-            MB_MYSQL_SSL_TEST_SSL_CERT="$(cat /home/circleci/metabase/metabase/resources/certificates/rds-combined-ca-bundle.pem)"
-            MB_MYSQL_SSL_TEST_USER=metabase
-            MB_MYSQL_SSL_TEST_PASSWORD=$MYSQL_RDS_SSL_INSTANCE_PASSWORD
-
       - test-driver:
           name: be-tests-oracle-ee
           requires:
diff --git a/.github/workflows/drivers.yml b/.github/workflows/drivers.yml
index 28544a976f1..944411267ec 100644
--- a/.github/workflows/drivers.yml
+++ b/.github/workflows/drivers.yml
@@ -24,7 +24,7 @@ jobs:
 
   be-tests-druid-ee:
     runs-on: buildjet-2vcpu-ubuntu-2004
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: druid
@@ -44,7 +44,7 @@ jobs:
 
   be-tests-mariadb-10-2-ee:
     runs-on: ubuntu-20.04
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: mysql
@@ -68,7 +68,7 @@ jobs:
 
   be-tests-mariadb-latest-ee:
     runs-on: ubuntu-20.04
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: mysql
@@ -92,7 +92,7 @@ jobs:
 
   be-tests-mongo-4-0-ee:
     runs-on: ubuntu-20.04
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: mongo
@@ -112,7 +112,7 @@ jobs:
 
   be-tests-mongo-5-0-ee:
     runs-on: ubuntu-20.04
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: mongo
@@ -132,7 +132,7 @@ jobs:
 
   be-tests-mongo-latest-ee:
     runs-on: ubuntu-20.04
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: mongo
@@ -155,7 +155,7 @@ jobs:
 
   be-tests-mysql-5-7-ee:
     runs-on: ubuntu-20.04
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: mysql
@@ -177,9 +177,45 @@ jobs:
       with:
         junit-name: 'be-tests-mysql-5-7-ee'
 
+  be-tests-mysql-latest-ee:
+    runs-on: ubuntu-20.04
+    timeout-minutes: 60
+    env:
+      CI: 'true'
+      DRIVERS: mysql
+      MB_DB_TYPE: mysql
+      MB_DB_HOST: localhost
+      MB_DB_PORT: 3306
+      MB_DB_DBNAME: circle_test
+      MB_DB_USER: root
+      MB_MYSQL_TEST_USER: root
+      # set up env vars for something named "MYSQL_SSL" to run MySQL SSL tests verifying connectivity with PEM cert
+      # they are deliberately given a different name to prevent them from affecting the regular test run against
+      # the configured MySQL instance, but there is one particular test (mysql-connect-with-ssl-and-pem-cert-test)
+      # that overrides the MB_MYSQL_TEST_* values with them
+      # the MYSQL_RDS_SSL_INSTANCE vars are defined as secrets and can be altered
+      MB_MYSQL_SSL_TEST_HOST: ${{ secrets.MYSQL_RDS_SSL_INSTANCE_HOST }}
+      MB_MYSQL_SSL_TEST_SSL: true
+      MB_MYSQL_SSL_TEST_ADDITIONAL_OPTIONS: 'verifyServerCertificate=true'
+      # the contents of the ./resources/certificates/rds-combined-ca-bundle.pem file
+      MB_MYSQL_SSL_TEST_SSL_CERT: ${{ secrets.MB_MYSQL_SSL_TEST_SSL_CERT }}
+      MB_MYSQL_SSL_TEST_USER: metabase
+      MB_MYSQL_SSL_TEST_PASSWORD: ${{ secrets.MYSQL_RDS_SSL_INSTANCE_PASSWORD }}
+    services:
+      mysql:
+        image: circleci/mysql:latest
+        ports:
+        - "3306:3306"
+    steps:
+    - uses: actions/checkout@v3
+    - name: Test MySQL driver (latest)
+      uses: ./.github/actions/test-driver
+      with:
+        junit-name: 'be-tests-mysql-latest-ee'
+
   be-tests-postgres-ee:
     runs-on: ubuntu-20.04
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: postgres
@@ -206,7 +242,7 @@ jobs:
 
   be-tests-postgres-latest-ee:
     runs-on: ubuntu-20.04
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: postgres
@@ -237,7 +273,7 @@ jobs:
 
   be-tests-presto-186-ee:
     runs-on: ubuntu-20.04
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: presto
@@ -257,7 +293,7 @@ jobs:
 
   be-tests-sparksql-ee:
     runs-on: buildjet-2vcpu-ubuntu-2004
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: sparksql
@@ -275,7 +311,7 @@ jobs:
 
   be-tests-sqlite-ee:
     runs-on: ubuntu-20.04
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: sqlite
@@ -288,7 +324,7 @@ jobs:
 
   be-tests-sqlserver-ee:
     runs-on: ubuntu-20.04
-    timeout-minutes: 30
+    timeout-minutes: 60
     env:
       CI: 'true'
       DRIVERS: sqlserver
-- 
GitLab