Skip to content

Commit

Permalink
Merge pull request #53 from Soundbar91/develop
Browse files Browse the repository at this point in the history
테스트용 pr
  • Loading branch information
Soundbar91 authored Sep 14, 2024
2 parents 71bec5b + 05ad389 commit 90d677d
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 26 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: PR CI

on:
push:
paths:
- '/**'
pull_request:
branches:
- "develop"
- "main"

jobs:
test:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.0.30
env:
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE_NAME }}
ports:
- 3306:3306

steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Make Application.yml
run: |
cd ./src/main/resources
touch ./application.yml
touch ./application-flask.yml
touch ./application.mysql.yml
echo "${{ secrets.APPLICATION }}" > ./application.yml
echo "${{ secrets.FLASK }}" > ./application-flask.yml
echo "${{ secrets.MYSQL }}" > ./application-mysql.yml
- name: Test with Gradle
run: ./gradlew --info test

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: build/test-results/**/*.xml

- name: Cleanup Gradle Cache
if: always()
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
application.yml
application-mysql.yml
application-flask.yml
META-INF

### STS ###
.apt_generated
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# base-image
FROM amazoncorretto:17-alpine-jdk

# continer path
WORKDIR /app

# jar copy
COPY ./build/libs/retrospect-project-0.0.1-SNAPSHOT.jar /app/app.jar

# java app.jar
ENTRYPOINT ["java","-jar","/app/app.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;

@SpringBootApplication
@ConfigurationPropertiesScan
public class RetrospectProjectApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.soundbar91.retrospect_project.global.config;

import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
@ConfigurationProperties(prefix = "cors")
public class CorsProperties {
private final List<String> allowedOrigins;
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
package com.soundbar91.retrospect_project.global.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {

@Bean
public OpenAPI openAPI() {

return new OpenAPI()
.components(new Components())
.info(apiInfo())
.addServersItem(new Server().url("/"));
.components(new Components())
.info(apiInfo());
}

private Info apiInfo() {
return new Info()
.title("회고 프로젝트 API")
.description("회고 프로젝트에서 구현된 API를 사용할 수 있습니다.")
.version("1.0.0");
.title("회고 프로젝트 API")
.description("회고 프로젝트에서 구현된 API를 사용할 수 있습니다.")
.version("1.0.0");
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package com.soundbar91.retrospect_project.global.config;

import com.soundbar91.retrospect_project.global.interceptor.*;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.soundbar91.retrospect_project.global.interceptor.AuthInterceptor;
import com.soundbar91.retrospect_project.global.interceptor.CommentInterceptor;
import com.soundbar91.retrospect_project.global.interceptor.PostInterceptor;
import com.soundbar91.retrospect_project.global.interceptor.ProblemInterceptor;
import com.soundbar91.retrospect_project.global.interceptor.ResultInterceptor;
import com.soundbar91.retrospect_project.global.interceptor.UserInterceptor;

import lombok.RequiredArgsConstructor;

@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {
Expand All @@ -16,33 +24,43 @@ public class WebConfig implements WebMvcConfigurer {
private final ResultInterceptor resultInterceptor;
private final PostInterceptor boardInterceptor;
private final CommentInterceptor commentInterceptor;
private final CorsProperties corsProperties;

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(certInterceptor)
.order(1)
.addPathPatterns("/auth/logout");
.order(1)
.addPathPatterns("/auth/logout");

registry.addInterceptor(userInterceptor)
.order(1)
.addPathPatterns("/user/**");
.order(1)
.addPathPatterns("/user/**");

registry.addInterceptor(problemInterceptor)
.order(1)
.addPathPatterns("/problem/**", "/problems");
.order(1)
.addPathPatterns("/problem/**", "/problems");

registry.addInterceptor(resultInterceptor)
.order(1)
.addPathPatterns("/result/**", "/results");
.order(1)
.addPathPatterns("/result/**", "/results");

registry.addInterceptor(boardInterceptor)
.order(1)
.addPathPatterns("/post/**", "/posts");
.order(1)
.addPathPatterns("/post/**", "/posts");

registry.addInterceptor(commentInterceptor)
.order(1)
.addPathPatterns("/comment/**");
.order(1)
.addPathPatterns("/comment/**");

}

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins(corsProperties.getAllowedOrigins().toArray(new String[0]))
.allowedHeaders("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
.allowCredentials(true)
.maxAge(3600);
}
}
10 changes: 9 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
spring:
config:
import: application-mysql.yml, application-flask.yml

jpa:
database: mysql
hibernate:
ddl-auto: validate

flyway:
enabled: true

springdoc:
swagger-ui:
operations-sorter: method

cors:
allowed-origins:
- "http://localhost:8080"
- "https://localhost:8080"
- "http://localhost:5000"

0 comments on commit 90d677d

Please sign in to comment.