From e4ab74bc65e88c9c5d569a7c8192592767d1a859 Mon Sep 17 00:00:00 2001 From: mirageoasis Date: Wed, 21 Aug 2024 10:24:48 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20workflow?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 51 +++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 66bc167e..1f8f7945 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,34 @@ -name: unit test on push +name: test on push on: [ pull_request ] jobs: deploy: - name: unit test + name: test runs-on: ubuntu-latest + services: + mysql: + image: mysql:8.0.32 + ports: + - 3306:3306 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: ticketing + options: >- + --health-cmd "mysqladmin ping -u root -proot" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + redis: + image: redis:7.0.11 + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: - name: checkout uses: actions/checkout@v3 @@ -18,7 +42,28 @@ jobs: distribution: 'temurin' java-version: '17' + - name: Set /etc/hosts for MySQL and Redis + run: | + echo "127.0.0.1 mysql" | sudo tee -a /etc/hosts + echo "127.0.0.1 redis" | sudo tee -a /etc/hosts + + - name: Wait for MySQL to be ready + run: | + until mysqladmin ping -h mysql -u root -proot --silent; do + echo 'waiting for mysql...' + sleep 5 + done + + - name: Wait for Redis to be ready + run: | + until nc -zv redis 6379; do + echo 'waiting for redis...' + sleep 5 + done + + - name: Build with Gradle run: | chmod +x ./gradlew - ./gradlew --info test + ./gradlew copyYml + ./gradlew test