Skip to content

[Test] Redis, Java 선착순 통합/단위 테스트 #19

[Test] Redis, Java 선착순 통합/단위 테스트

[Test] Redis, Java 선착순 통합/단위 테스트 #19

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Build test in Github Actions
# Controls when the workflow will run
on:
# Triggers the 'Build' workflow when the pull request updated for the "master" branch
pull_request:
branches: [ master ]
env:
MYSQL_ROOT_PWD: ${{ secrets.MYSQL_ROOT_PWD }}
MYSQL_DB: ${{ secrets.MYSQL_DB }}
MYSQL_HOST: ${{ secrets.MYSQL_HOST }}
REDIS_HOST: ${{ secrets.REDIS_HOST }}
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "deploy"
deploy:
name: Deploy
# The type of runner that the job will run on
runs-on: ubuntu-latest
environment: production
services:
mysql:
image: mysql:8.0.37
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
env:
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PWD }}
MYSQL_DATABASE: ${{ env.MYSQL_DB }}
redis:
image: redis:7.0.15
ports:
- 6379:6379
options: >-
--health-cmd="redis-cli ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# (1) 기본 체크아웃 (v2->v3)
- name: Checkout
uses: actions/checkout@v3
# (2) JDK 17 세팅 (v1->v3)
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
# (3) Gradle 권한설정
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
shell: bash
# (4) Redis 설치
- name: Install redis-cli
run: sudo apt-get update && sudo apt-get install -y redis-tools
# (5) Mysql 세팅 대기
- name: Wait for MySQL
run: |
until mysqladmin ping -h ${{ env.MYSQL_HOST }} --silent; do
echo 'waiting for mysql to be connectable...'
sleep 5
done
# (6) Redis 세팅 대기
- name: Wait for Redis
run: |
until redis-cli -h ${{ env.REDIS_HOST }} ping; do
echo 'waiting for redis to be connectable...'
sleep 5
done
# (7) Gradle build (Test 제외)
- name: Build with Gradle
run: ./gradlew build -x test
shell: bash