diff --git a/.github/workflows/backend_flyway.yml b/.github/workflows/backend_flyway.yml new file mode 100644 index 000000000..77b25804e --- /dev/null +++ b/.github/workflows/backend_flyway.yml @@ -0,0 +1,72 @@ +name: flyway 스크립트 검증 + +on: + pull_request: + paths: + - 'backend/ddang/src/main/resources/db/migration/**.sql' + types: [opened, reopened, synchronize] + branches: [develop-be] + +permissions: write-all +jobs: + build: + if: contains(github.event.pull_request.labels.*.name, 'backend') + runs-on: ubuntu-latest + services: + mysql: + image: mysql:latest + env: + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: testdb + MYSQL_USER: test + MYSQL_PASSWORD: password + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - uses: actions/checkout@v3 + + - name: settings java + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: cache gradle + 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: chmod gradle + run: chmod +x backend/ddang/gradlew + + - name: Wait for MySQL to be ready + run: | + while [ -z "$DATABASE_URL" ]; do + echo "Waiting for MySQL to be ready..." + export DATABASE_URL=$(echo "SELECT 'ready';" | mysql -h127.0.0.1 -P3306 -utest -ppassword testdb --skip-column-names 2>/dev/null) + sleep 1 + done + + - name: Create flyway.conf + run: | + touch flyway.conf + echo "flyway.driver=com.mysql.cj.jdbc.Driver" >> flyway.conf + echo "flyway.url=jdbc:mysql://127.0.0.1:3306/testdb" >> flyway.conf + echo "flyway.user=test" >> flyway.conf + echo "flyway.password=password" >> flyway.conf + echo "flyway.encoding=UTF-8" >> flyway.conf + echo "flyway.locations=filesystem:src/main/resources/db/migration" >> flyway.conf + echo "flyway.validateOnMigrate=true" >> flyway.conf + working-directory: ./backend/ddang + + - name: flywayValidate + run: | + ./gradlew -Dflyway.configFiles=flyway.conf flywayMigrate --stacktrace + working-directory: ./backend/ddang diff --git a/.github/workflows/backend_pr_decorator.yml b/.github/workflows/backend_pr_decorator.yml index 246e81b8d..e63306202 100644 --- a/.github/workflows/backend_pr_decorator.yml +++ b/.github/workflows/backend_pr_decorator.yml @@ -61,31 +61,6 @@ jobs: echo "AUTHOR_NAME=${AUTHOR_NAME}" >> $GITHUB_OUTPUT echo "AUTHOR_ID=${AUTHOR_ID}" >> $GITHUB_OUTPUT - - name: set variables - id: variables - run: | - REVIEWERS_GIT_ID='${{ toJson(github.event.pull_request.requested_reviewers[*].login) }}' - reviewers=$(echo "$REVIEWERS_GIT_ID" | jq -r '.[]') - - REVIEWERS_SLACK_ID="" - - for reviewer in $reviewers; do - echo "Reviewer: $reviewer" - if [ "$reviewer" == "apptie" ]; then - REVIEWERS_SLACK_ID+="<@${{ secrets.apptie_slack_id }}> " - elif [ "$reviewer" == "swonny" ]; then - REVIEWERS_SLACK_ID+="<@${{ secrets.swonny_slack_id }}> " - elif [ "$reviewer" == "JJ503" ]; then - REVIEWERS_SLACK_ID+="<@${{ secrets.JJ503_slack_id }}> " - elif [ "$reviewer" == "kwonyj1022" ]; then - REVIEWERS_SLACK_ID+="<@${{ secrets.kwonyj1022_slack_id }}> " - fi - done - - echo "AUTHOR=${AUTHOR}" >> $GITHUB_OUTPUT - echo "REVIEWERS=${REVIEWERS}" >> $GITHUB_OUTPUT - echo "REVIEWERS_SLACK_ID=${REVIEWERS_SLACK_ID}" >> $GITHUB_OUTPUT - - name: slack notification if: github.event_name == 'pull_request' && github.event.action != 'synchronize' run: | @@ -97,8 +72,7 @@ jobs: SLACK_MESSAGE+="${{ github.event.pull_request.title }}" SLACK_MESSAGE+="\n>\n>분석 결과\n>" SLACK_MESSAGE+=":white_check_mark:" - SLACK_MESSAGE+="\n>\n>*리뷰어*\n>" - SLACK_MESSAGE+="${{ steps.variables.outputs.REVIEWERS_SLACK_ID }}" + SLACK_MESSAGE+="\n\n리뷰 요청은 스레드로 직접 멘션해주세요." SLACK_MESSAGE+='"}}]}' curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}" @@ -116,6 +90,7 @@ jobs: SLACK_MESSAGE+="${{ github.event.pull_request.title }}" SLACK_MESSAGE+="\n>\n>분석 결과\n>" SLACK_MESSAGE+=":x:" + SLACK_MESSAGE+="\n\n리뷰 요청은 문제 해결 후 스레드로 직접 멘션해주세요." SLACK_MESSAGE+='"}}]}' curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}" @@ -133,6 +108,7 @@ jobs: SLACK_MESSAGE+="${{ github.event.pull_request.title }}" SLACK_MESSAGE+="\n>\n>분석 결과\n>" SLACK_MESSAGE+=":black_square_for_stop:" + SLACK_MESSAGE+="\n\n리뷰 요청은 문제 해결 후 스레드로 직접 멘션해주세요." SLACK_MESSAGE+='"}}]}' curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}" diff --git a/backend/ddang/build.gradle b/backend/ddang/build.gradle index ccbc8a1e9..76ceb430d 100644 --- a/backend/ddang/build.gradle +++ b/backend/ddang/build.gradle @@ -1,9 +1,19 @@ +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'org.flywaydb:flyway-mysql:9.16.0' + } +} + plugins { id 'java' id 'org.springframework.boot' version '3.0.8' id 'io.spring.dependency-management' version '1.1.0' id 'jacoco' id 'org.asciidoctor.jvm.convert' version '3.3.2' + id 'org.flywaydb.flyway' version '9.16.0' } configurations { diff --git a/backend/ddang/src/main/java/com/ddang/ddang/configuration/initialization/InitializationUserConfiguration.java b/backend/ddang/src/main/java/com/ddang/ddang/configuration/initialization/InitializationUserConfiguration.java deleted file mode 100644 index f89bfc8ce..000000000 --- a/backend/ddang/src/main/java/com/ddang/ddang/configuration/initialization/InitializationUserConfiguration.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.ddang.ddang.configuration.initialization; - -import com.ddang.ddang.image.domain.ProfileImage; -import com.ddang.ddang.user.domain.Reliability; -import com.ddang.ddang.user.domain.User; -import com.ddang.ddang.user.domain.repository.UserRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Configuration; -import org.springframework.transaction.annotation.Transactional; - -@Configuration -@ConditionalOnProperty(name = "data.init.user.enabled", havingValue = "true") -@RequiredArgsConstructor -public class InitializationUserConfiguration implements ApplicationRunner { - - private final UserRepository userRepository; - - @Override - @Transactional - public void run(final ApplicationArguments args) { - final User seller1 = User.builder() - .name("판매자1") - .profileImage(new ProfileImage("upload.png", "updateImage.png")) - .reliability(new Reliability(4.7d)) - .oauthId("12345") - .build(); - - final User buyer1 = User.builder() - .name("구매자1") - .profileImage(new ProfileImage("upload.png", "updateImage.png")) - .reliability(new Reliability(3.0d)) - .oauthId("12346") - .build(); - - final User buyer2 = User.builder() - .name("구매자2") - .profileImage(new ProfileImage("upload.png", "updateImage.png")) - .reliability(new Reliability(0.8d)) - .oauthId("12347") - .build(); - - userRepository.save(seller1); - userRepository.save(buyer1); - userRepository.save(buyer2); - } -} diff --git a/backend/ddang/src/main/resources/application-local.yml b/backend/ddang/src/main/resources/application-local.yml index 2db9e094b..fd586f349 100644 --- a/backend/ddang/src/main/resources/application-local.yml +++ b/backend/ddang/src/main/resources/application-local.yml @@ -29,10 +29,6 @@ data: init: region: enabled: false - auction: - enabled: false - user: - enabled: false image: store: