Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/ci-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,64 @@ permissions:
contents: read

jobs:
verify:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: ci_db
MYSQL_USER: ci_user
MYSQL_PASSWORD: ci_password
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=10

env:
SPRING_PROFILES_ACTIVE: ci
CI_DB_HOST: 127.0.0.1
CI_DB_PORT: 3306
CI_DB_NAME: ci_db
CI_DB_USER: ci_user
CI_DB_PASSWORD: ci_password

steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"

- run: chmod +x gradlew

- name: Wait for MySQL
run: |
for i in {1..30}; do
mysqladmin ping \
-h 127.0.0.1 \
-P 3306 \
-u root \
-proot \
--silent && echo "✅ MySQL is up" && exit 0
echo "Waiting for MySQL..."
sleep 2
done
echo "❌ MySQL not ready"
exit 1

- name: Run tests
run: ./gradlew test

build:
runs-on: ubuntu-latest
needs: verify

steps:
- uses: actions/checkout@v3
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/deploy-staging-auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,68 @@ concurrency:
cancel-in-progress: true

jobs:
verify:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: ci_db
MYSQL_USER: ci_user
MYSQL_PASSWORD: ci_password
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=10

env:
SPRING_PROFILES_ACTIVE: ci
CI_DB_HOST: 127.0.0.1
CI_DB_PORT: 3306
CI_DB_NAME: ci_db
CI_DB_USER: ci_user
CI_DB_PASSWORD: ci_password

steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"

- run: chmod +x gradlew

- name: Wait for MySQL
run: |
for i in {1..30}; do
mysqladmin ping \
-h 127.0.0.1 \
-P 3306 \
-u root \
-proot \
--silent && echo "✅ MySQL is up" && exit 0
echo "Waiting for MySQL..."
sleep 2
done
echo "❌ MySQL not ready"
exit 1

- name: Run tests
run: ./gradlew test

build_and_deploy:
runs-on: ubuntu-latest
environment:
name: staging

needs: verify

steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ dependencies {
implementation 'org.java-websocket:Java-WebSocket:1.5.3'

annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"

// flyway
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-mysql'
}

tasks.named('test') {
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/application-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${CI_DB_HOST:localhost}:${CI_DB_PORT:3306}/${CI_DB_NAME}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&characterEncoding=UTF-8
username: ${CI_DB_USER}
password: ${CI_DB_PASSWORD}

jpa:
hibernate:
ddl-auto: validate
properties:
hibernate:
format_sql: true

flyway:
enabled: true
locations: classpath:db/migration
baseline-on-migrate: true
baseline-version: 1
baseline-description: baseline
4 changes: 4 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ spring:
host: localhost
port: ${REDIS_PORT}

spring:
flyway:
locations: classpath:db/migration,classpath:db/seed

auth:
refresh:
expiration-days: ${REFRESH_TOKEN_EXPIRATION_DAYS}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ spring:
port: ${REDIS_PORT}
password: ${REDIS_PASSWORD}

spring:
flyway:
locations: classpath:db/migration

auth:
refresh:
expiration-days: ${REFRESH_TOKEN_EXPIRATION_DAYS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ spring:
port: ${REDIS_PORT}
password: ${REDIS_PASSWORD}

spring:
flyway:
locations: classpath:db/migration,classpath:db/seed

auth:
refresh:
expiration-days: ${REFRESH_TOKEN_EXPIRATION_DAYS}
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
spring:
application:
name: emotion-storage

profiles:
active: local

task:
scheduling:
pool:
size: 5
thread-name-prefix: "scheduled-task-"

spring:
flyway:
enabled: true
baseline-on-migrate: true
baseline-version: 1
baseline-description: baseline

rest-template:
connect-timeout: 5000
read-timeout: 120000
Loading