From a42ea447c0acf2db586a429a6bd8013b82279122 Mon Sep 17 00:00:00 2001
From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
Date: Mon, 12 Dec 2022 21:03:37 +0100
Subject: [PATCH] Migrate BigQuery and classpath driver tests to GitHub actions
 (#27162)

* Migrate BigQuery SDK driver test to GitHub Actions

* Migrate Google related classpath drivers test to GitHub Actions

* Multi-line strings are not working?

* Provide BQ envs
---
 .circleci/config.yml                   | 19 -----------
 .github/actions/test-driver/action.yml |  4 ++-
 .github/workflows/drivers.yml          | 44 ++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 20 deletions(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 19806298c42..23b1b867ad2 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -555,25 +555,6 @@ workflows:
 
           skip-when-no-change: true
 
-      - test-driver:
-          matrix:
-            parameters:
-              driver: ["bigquery-cloud-sdk"]
-          name: be-tests-<< matrix.driver >>-ee
-          requires:
-            - be-deps
-          driver: << matrix.driver >>
-          timeout: 30m
-
-      - test-driver:
-          name: be-google-related-drivers-classpath-test
-          requires:
-            - be-deps
-          driver: googleanalytics,bigquery-cloud-sdk
-          test-args: >-
-            :only "[metabase.query-processor-test.expressions-test metabase.driver.google-test
-                    metabase.driver.googleanalytics-test]"
-
       - test-driver:
           matrix:
             parameters:
diff --git a/.github/actions/test-driver/action.yml b/.github/actions/test-driver/action.yml
index 02974c34c7b..2c179c13f4a 100644
--- a/.github/actions/test-driver/action.yml
+++ b/.github/actions/test-driver/action.yml
@@ -3,6 +3,8 @@ inputs:
   junit-name:
     required: true
     default: 'driver'
+  test-args:
+    required: false
 
 runs:
   using: "composite"
@@ -15,7 +17,7 @@ runs:
       run: yarn build-static-viz
       shell: bash
     - name: Test database driver
-      run: clojure -X:dev:ci:ee:ee-dev:drivers:drivers-dev:test
+      run: clojure -X:dev:ci:ee:ee-dev:drivers:drivers-dev:test ${{ inputs.test-args }}
       shell: bash
     - name: Publish Test Report (JUnit)
       uses: mikepenz/action-junit-report@v3
diff --git a/.github/workflows/drivers.yml b/.github/workflows/drivers.yml
index a0757b80731..d01fca95bf7 100644
--- a/.github/workflows/drivers.yml
+++ b/.github/workflows/drivers.yml
@@ -40,6 +40,26 @@ jobs:
       with:
         junit-name: 'be-tests-athena-ee'
 
+  be-tests-bigquery-cloud-sdk-ee:
+    if: github.event.pull_request.draft == false
+    runs-on: ubuntu-20.04
+    timeout-minutes: 60
+    env:
+      CI: 'true'
+      DRIVERS: bigquery-cloud-sdk
+      MB_BIGQUERY_TEST_PROJECT_ID: ${{ secrets.BIGQUERY_TEST_PROJECT_ID }}
+      MB_BIGQUERY_TEST_CLIENT_ID: ${{ secrets.MB_BIGQUERY_TEST_CLIENT_ID }}
+      MB_BIGQUERY_TEST_CLIENT_SECRET: ${{ secrets.MB_BIGQUERY_TEST_CLIENT_SECRET }}
+      MB_BIGQUERY_TEST_ACCESS_TOKEN: ${{ secrets.MB_BIGQUERY_TEST_ACCESS_TOKEN }}
+      MB_BIGQUERY_TEST_REFRESH_TOKEN: ${{ secrets.MB_BIGQUERY_TEST_REFRESH_TOKEN }}
+      MB_BIGQUERY_CLOUD_SDK_TEST_SERVICE_ACCOUNT_JSON: ${{ secrets.MB_BIGQUERY_CLOUD_SDK_TEST_SERVICE_ACCOUNT_JSON }}
+    steps:
+    - uses: actions/checkout@v3
+    - name: Test BigQuery Cloud SDK driver
+      uses: ./.github/actions/test-driver
+      with:
+        junit-name: 'be-tests-bigquery-cloud-sdk-ee'
+
   be-tests-druid-ee:
     if: github.event.pull_request.draft == false
     runs-on: buildjet-2vcpu-ubuntu-2004
@@ -75,6 +95,30 @@ jobs:
       with:
         junit-name: 'be-tests-googleanalytics-ee'
 
+  be-tests-google-related-classpath-ee:
+    if: github.event.pull_request.draft == false
+    runs-on: ubuntu-20.04
+    timeout-minutes: 60
+    strategy:
+      matrix:
+        driver: ['googleanalytics', 'bigquery-cloud-sdk']
+    env:
+      CI: 'true'
+      DRIVERS: ${{ matrix.driver }}
+      MB_BIGQUERY_TEST_PROJECT_ID: ${{ secrets.BIGQUERY_TEST_PROJECT_ID }}
+      MB_BIGQUERY_TEST_CLIENT_ID: ${{ secrets.MB_BIGQUERY_TEST_CLIENT_ID }}
+      MB_BIGQUERY_TEST_CLIENT_SECRET: ${{ secrets.MB_BIGQUERY_TEST_CLIENT_SECRET }}
+      MB_BIGQUERY_TEST_ACCESS_TOKEN: ${{ secrets.MB_BIGQUERY_TEST_ACCESS_TOKEN }}
+      MB_BIGQUERY_TEST_REFRESH_TOKEN: ${{ secrets.MB_BIGQUERY_TEST_REFRESH_TOKEN }}
+      MB_BIGQUERY_CLOUD_SDK_TEST_SERVICE_ACCOUNT_JSON: ${{ secrets.MB_BIGQUERY_CLOUD_SDK_TEST_SERVICE_ACCOUNT_JSON }}
+    steps:
+    - uses: actions/checkout@v3
+    - name: Test Google Related Classpath drivers
+      uses: ./.github/actions/test-driver
+      with:
+        junit-name: 'be-tests-${{ matrix.driver }}-classpath-ee'
+        test-args: ':only "[metabase.query-processor-test.expressions-test metabase.driver.google-test metabase.driver.googleanalytics-test]"'
+
   be-tests-mariadb-10-2-ee:
     if: github.event.pull_request.draft == false
     runs-on: ubuntu-20.04
-- 
GitLab