From 5624bb5ba62c396f32b181c884450ec7eb891260 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Sun, 18 Feb 2024 23:23:46 +0800 Subject: [PATCH 1/5] Set up MySQL according to https://stackoverflow.com/questions/72294279/how-to-connect-to-mysql-databas-using-github-actions --- .github/workflows/ci.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76dd28ec..fcbd0122 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,20 @@ jobs: language: ['java'] runs-on: ${{ matrix.os }} + services: + mysql: + image: mysql:8 + env: + # The MySQL docker container requires these environment variables to be set + # so we can create and migrate the test database. + MYSQL_DATABASE: eventmesh-dashboard + MYSQL_ROOT_PASSWORD: password + ports: + # https://docs.github.com/en/actions/using-containerized-services/about-service-containers + - 3306:3306 + # Set health checks to wait until MySQL has started + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + steps: - name: Checkout repository uses: actions/checkout@v3 From f1189476e9ac4dcc06d80bac7696700d37eeb7ed Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Sun, 18 Feb 2024 23:34:08 +0800 Subject: [PATCH 2/5] Set up MySQL according to https://medium.com/@michaelmatere606/configuring-mysql-for-github-actions-a-step-by-step-guide-f49e0a7aeedc and https://ovirium.com/blog/how-to-make-mysql-work-in-your-github-actions/ --- .github/workflows/ci.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcbd0122..dea6de33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,24 +36,20 @@ jobs: language: ['java'] runs-on: ${{ matrix.os }} - services: - mysql: - image: mysql:8 - env: - # The MySQL docker container requires these environment variables to be set - # so we can create and migrate the test database. - MYSQL_DATABASE: eventmesh-dashboard - MYSQL_ROOT_PASSWORD: password - ports: - # https://docs.github.com/en/actions/using-containerized-services/about-service-containers - - 3306:3306 - # Set health checks to wait until MySQL has started - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + env: + DB_DATABASE: eventmesh-dashboard + DB_USER: root + DB_PASSWORD: password steps: - name: Checkout repository uses: actions/checkout@v3 + - name: Set up MySQL + run: | + sudo systemctl start mysql.service + mysql -e "CREATE DATABASE IF NOT EXISTS $DB_DATABASE;" -u$DB_USER -p$DB_PASSWORD + - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v3 with: From d8720182580e4fe15c65886ca23a225b51587303 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Sun, 18 Feb 2024 23:37:20 +0800 Subject: [PATCH 3/5] Change password according to https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dea6de33..6477ee67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: env: DB_DATABASE: eventmesh-dashboard DB_USER: root - DB_PASSWORD: password + DB_PASSWORD: root steps: - name: Checkout repository From a0df43db05b2838be5048f35eb032b7a9b2c7a0e Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Sun, 18 Feb 2024 23:49:19 +0800 Subject: [PATCH 4/5] Fit database name with `_` instead of `-` --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6477ee67..3be64265 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: runs-on: ${{ matrix.os }} env: - DB_DATABASE: eventmesh-dashboard + DB_DATABASE: EVENTMESH_DASHBOARD DB_USER: root DB_PASSWORD: root From 83af6e61c9488726de93b58d725809a758e9e0c3 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Sun, 18 Feb 2024 23:57:31 +0800 Subject: [PATCH 5/5] Use the `service` sector instead of starting the mysql service of GitHub's ubuntu image --- .github/workflows/ci.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3be64265..f16cdb5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,20 +36,23 @@ jobs: language: ['java'] runs-on: ${{ matrix.os }} - env: - DB_DATABASE: EVENTMESH_DASHBOARD - DB_USER: root - DB_PASSWORD: root + services: + mysql: + image: mysql:8 + env: + # The MySQL docker container requires these environment variables to be set, so we can create and migrate the test database. + MYSQL_DATABASE: EVENTMESH_DASHBOARD + MYSQL_ROOT_PASSWORD: password + ports: + # https://docs.github.com/en/actions/using-containerized-services/about-service-containers + - 3306:3306 + # Set health checks to wait until MySQL has started + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Set up MySQL - run: | - sudo systemctl start mysql.service - mysql -e "CREATE DATABASE IF NOT EXISTS $DB_DATABASE;" -u$DB_USER -p$DB_PASSWORD - - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v3 with: