Skip to content
Closed
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
14 changes: 14 additions & 0 deletions .github/workflows/block.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Block Perf to Develop

on:
pull_request:
branches: [ "develop" ]

jobs:
block-perf-pr:
runs-on: ubuntu-latest
if: github.head_ref == 'perf'
steps:
- run: |
echo "🚫 perf-test → develop 병합은 금지되어 있습니다."
exit 1
12 changes: 6 additions & 6 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
java-version: '17'
distribution: 'temurin'

# 3. Docker 이미지 build 및 push
# 3. Docker 이미지 build 및 push
- name: docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_USERNAME }}/gotcha:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/gotcha:latest
docker build -t ${{ secrets.DOCKER_USERNAME }}/gotcha_perf_test:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/gotcha_perf_test:latest

# 4. ec2 pull
- name: Deploy to server
Expand All @@ -38,10 +38,10 @@ jobs:
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_KEY }}
script: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
# docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker system prune -a -f
docker-compose down
docker rmi ${{ secrets.DOCKER_USERNAME }}/gotcha:latest
docker pull ${{ secrets.DOCKER_USERNAME }}/gotcha:latest
docker rmi ${{ secrets.DOCKER_USERNAME }}/gotcha_perf_test:latest
docker pull ${{ secrets.DOCKER_USERNAME }}/gotcha_perf_test:latest
docker-compose up -d

44 changes: 6 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Continuous Integration

on:
pull_request:
branches: [ "develop" ]
branches: [ "perf-test" ]
workflow_dispatch:
inputs:
logLevel:
Expand All @@ -24,7 +24,7 @@ on:
required: false

permissions:
contents: write
contents: read

jobs:
develop-test:
Expand All @@ -36,58 +36,26 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.ref }}

# 1. Node.js 설치 (AsyncAPI CLI 실행용)
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Clean old docs
run: rm -rf gotcha-socket/src/main/resources/static.docs gotcha-socket/src/main/resources/static/docs

# 3. AsyncAPI CLI 전역 설치 (최신 버전)
- name: Install AsyncAPI CLI
run: npm install -g @asyncapi/cli@latest

# 4. AsyncAPI → HTML 문서 자동 생성
- name: Generate HTML Docs
run: |
asyncapi generate fromTemplate gotcha-socket/asyncapi.yaml @asyncapi/html-template@3.0.0 --output gotcha-socket/src/main/resources/static/docs --use-new-generator

# 5. 문서 변경사항 커밋 & 푸시
- name: Commit and Push Generated Docs
run: |
git config --global user.name "github-actions"
git config --global user.email "actions@github.com"

git add gotcha-socket/src/main/resources/static/docs
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "Auto-update AsyncAPI docs"
git push
fi

# 7. 자바 환경 설정
# 2. 자바 환경 설정
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

# 7. 테스트를 위한 DB 설정
# 3. 테스트를 위한 DB 설정
- name: Setup MySQL
uses: mirromutth/mysql-action@v1.1
with:
mysql database: ${{ secrets.MYSQL_TEST_DATABASE }}
mysql user: ${{ secrets.MYSQL_TEST_USER }}
mysql password: ${{ secrets.MYSQL_TEST_PASSWORD }}

# 8. Gradlew 실행 권한 설정
# 4. Gradlew 실행 권한 설정
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew

# 9. Gradle Test 실행
# 5. Gradle Test 실행
- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25
with:
Expand Down
10 changes: 10 additions & 0 deletions gotcha/src/main/resources/application-perf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
spring:
datasource:
url: jdbc:mysql://${PERF_DATABASE_HOST:localhost}:${DATABASE_PORT:3306}/${PERF_DATABASE_NAME:gotcha}
username: ${PERF_DATABASE_USER:root}
password: ${PERF_DATABASE_PASSWORD:password}
driver-class-name: com.mysql.cj.jdbc.Driver

csrf:
cookie:
secure: false
2 changes: 1 addition & 1 deletion gotcha/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
spring:
profiles:
active: ${SPRING_PROFILES_ACTIVE:dev}
active: ${SPRING_PROFILES_ACTIVE:perf}

jpa:
hibernate:
Expand Down
Empty file added load-test/config.env
Empty file.
6 changes: 6 additions & 0 deletions load-test/locustfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from locust import HttpUser, between
from scenario.login import LoginScenario

class WebsiteUser(HttpUser):
tasks = [LoginScenario]
wait_time = between(1, 3)
19 changes: 19 additions & 0 deletions load-test/scenario/login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from locust import TaskSet, task

class LoginScenario(TaskSet):
token = None

@task
def login_and_store_token(self):
res = self.client.post(
"/api/auth/sign-in",
json={
"email": "test@gmail.com",
"password": "asdfasdf1"
}
)
if res.status_code == 200:
self.token = res.json().get("accessToken") # 응답 구조에 맞게 key 확인
print(f"[성공] 토큰: {self.token}")
else:
print(f"[실패] 로그인 실패: {res.status_code} / {res.text}")