Skip to content

Commit

Permalink
ci: 백엔드 develop 브랜치 최신화(#596)
Browse files Browse the repository at this point in the history
백엔드 develop 브랜치 최신화
  • Loading branch information
apptie authored Oct 10, 2023
2 parents 109caa0 + 7982da8 commit 86e1110
Show file tree
Hide file tree
Showing 451 changed files with 23,942 additions and 9,515 deletions.
67 changes: 19 additions & 48 deletions .github/workflows/backend_pr_decorator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: run jacocoTestCoverage
run: |
cd backend/ddang
./gradlew jacocoTestCoverage --info
./gradlew jacocoTestCoverage
- name: set author slack id
if: always()
Expand All @@ -50,9 +50,9 @@ jobs:
elif [ "$GIT_ID" == "swonny" ]; then
AUTHOR_NAME="${{ secrets.swonny_slack_display_name }}"
AUTHOR_ID="${{ secrets.swonny_slack_id }}"
elif [ "$GIT_ID" == "jj503" ]; then
AUTHOR_NAME="${{ secrets.jj503_slack_display_name }}"
AUTHOR_ID="${{ secrets.jj503_slack_id }}"
elif [ "$GIT_ID" == "JJ503" ]; then
AUTHOR_NAME="${{ secrets.JJ503_slack_display_name }}"
AUTHOR_ID="${{ secrets.JJ503_slack_id }}"
elif [ "$GIT_ID" == "kwonyj1022" ]; then
AUTHOR_NAME="${{ secrets.kwonyj1022_slack_display_name }}"
AUTHOR_ID="${{ secrets.kwonyj1022_slack_id }}"
Expand All @@ -61,44 +61,9 @@ jobs:
echo "AUTHOR_NAME=${AUTHOR_NAME}" >> $GITHUB_OUTPUT
echo "AUTHOR_ID=${AUTHOR_ID}" >> $GITHUB_OUTPUT
- name: run an analysis of the ${{ github.REF }} branch ${{ github.BASE_REF }} base
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_URL }}
with:
args: >
-Dsonar.issuesReport.console.enable=true
-Dsonar.projectKey=develop-be-project
-Dsonar.java.binaries=backend/ddang/build/classes
-Dsonar.exclusions=**/*Dto*.java,**/*Application*.java,**/*Exception*.java,**/*Response*.java,**/*Request*.java,**/*Configuration*.java,**/*Appender*.java,**/*.html,**/generated/**,**/resources/**
-Dsonar.sourceEncoding=UTF-8
-Dsonar.java.coveragePlugin=jacoco
-Dsonar.coverage.jacoco.xmlReportPaths=backend/ddang/build/reports/jacoco/test/jacocoTestReport.xml
-Dsonar.issue.ignore.multicriteria=e1,e2
-Dsonar.issue.ignore.multicriteria.e1.ruleKey=java:S100
-Dsonar.issue.ignore.multicriteria.e1.resourceKey=**/*Test.java
-Dsonar.issue.ignore.multicriteria.e2.ruleKey=java:S1192
-Dsonar.issue.ignore.multicriteria.e2.resourceKey=**/*Test.java
- name: sonarqube quality check
id: sonar-quality
run: |
SONAR_PROJECT_KEY="develop-be-project"
SONAR_TOKEN="${{ secrets.SONAR_TOKEN }}"
RESULT=$(curl -s -u "admin:root" "${{ secrets.SONAR_URL }}/api/qualitygates/project_status?projectKey=${SONAR_PROJECT_KEY}&pullRequest=${{github.event.number}}")
STATUS=$(echo "$RESULT" | jq -r '.projectStatus.status')
ERROR_METRIC_KEYS=$(echo "$RESULT" | jq -r '.projectStatus.conditions[] | select(.status == "ERROR").metricKey')
echo "STATUS=${STATUS}" >> $GITHUB_OUTPUT
echo "ERROR_METRIC_KEYS=${ERROR_METRIC_KEYS}" >> $GITHUB_OUTPUT
- name: set variables
id: variables
run: |
SONAR_SCANNER_URL="${{ secrets.SONAR_URL }}/dashboard?id=sonarqube-test&pullRequest=${{github.event.number}}"
REVIEWERS_GIT_ID='${{ toJson(github.event.pull_request.requested_reviewers[*].login) }}'
reviewers=$(echo "$REVIEWERS_GIT_ID" | jq -r '.[]')
Expand All @@ -111,32 +76,34 @@ jobs:
elif [ "$reviewer" == "swonny" ]; then
REVIEWERS_SLACK_ID+="<@${{ secrets.swonny_slack_id }}> "
elif [ "$reviewer" == "JJ503" ]; then
REVIEWERS_SLACK_ID+="<@${{ secrets.jj503_slack_id }}> "
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 "SONAR_SCANNER_URL=${SONAR_SCANNER_URL}" >> $GITHUB_OUTPUT
echo "REVIEWERS=${REVIEWERS}" >> $GITHUB_OUTPUT
echo "REVIEWERS_SLACK_ID=${REVIEWERS_SLACK_ID}" >> $GITHUB_OUTPUT
- name: slack test
- name: slack notification
if: github.event_name == 'pull_request' && github.event.action != 'synchronize'
run: |
SLACK_MESSAGE='{"text":"PR 브랜치 분석","blocks":[{"type":"section","text":{"type":"mrkdwn","text":">*PR 브랜치 분석* \n>\n>*PR Author*\n>'
SLACK_MESSAGE+="${{ steps.author-slack.outputs.AUTHOR_NAME }}"
SLACK_MESSAGE+="\n>\n>*PR 링크*\n><"
SLACK_MESSAGE+="${{ github.event.pull_request.html_url }} "
SLACK_MESSAGE+="> \n>\n>분석 결과\n>"
SLACK_MESSAGE+="> \n>\n>*PR 제목*\n>"
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+='"}}]}'
curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}"
curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}"
- name: slack failed test
- name: slack failed notification
if: failure()
run: |
SLACK_MESSAGE='{"text":"PR 브랜치 분석","blocks":[{"type":"section","text":{"type":"mrkdwn","text":">*PR 브랜치 분석* \n>\n>*PR Author*\n>'
Expand All @@ -145,13 +112,15 @@ jobs:
SLACK_MESSAGE+=">"
SLACK_MESSAGE+="\n>\n>*PR 링크*\n><"
SLACK_MESSAGE+="${{ github.event.pull_request.html_url }} "
SLACK_MESSAGE+="> \n>\n>분석 결과\n>"
SLACK_MESSAGE+="> \n>\n>*PR 제목*\n>"
SLACK_MESSAGE+="${{ github.event.pull_request.title }}"
SLACK_MESSAGE+="\n>\n>분석 결과\n>"
SLACK_MESSAGE+=":x:"
SLACK_MESSAGE+='"}}]}'
curl -X POST ${{ secrets.SLACK_WEBHOOK }} -d "${SLACK_MESSAGE}"
- name: slack cancelled test
- name: slack cancelled notification
if: cancelled()
run: |
SLACK_MESSAGE='{"text":"PR 브랜치 분석","blocks":[{"type":"section","text":{"type":"mrkdwn","text":">*PR 브랜치 분석* \n>\n>*PR Author*\n>'
Expand All @@ -160,7 +129,9 @@ jobs:
SLACK_MESSAGE+=">"
SLACK_MESSAGE+="\n>\n>*PR 링크*\n><"
SLACK_MESSAGE+="${{ github.event.pull_request.html_url }} "
SLACK_MESSAGE+="> \n>\n>분석 결과\n>"
SLACK_MESSAGE+="> \n>\n>*PR 제목*\n>"
SLACK_MESSAGE+="${{ github.event.pull_request.title }}"
SLACK_MESSAGE+="\n>\n>분석 결과\n>"
SLACK_MESSAGE+=":black_square_for_stop:"
SLACK_MESSAGE+='"}}]}'
Expand Down
1 change: 1 addition & 0 deletions backend/ddang/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,4 @@ Temporary Items
*.icloud

# End of https://www.toptal.com/developers/gitignore/api/macos,java,intellij
/src/main/resources/firebase/
53 changes: 38 additions & 15 deletions backend/ddang/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
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.asciidoctor.jvm.convert' version '3.3.2'
}

configurations {
Expand All @@ -28,28 +28,51 @@ repositories {
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-mysql:9.16.0'
compileOnly 'org.projectlombok:lombok'
// h2
runtimeOnly 'com.h2database:h2'

// mysql
runtimeOnly 'com.mysql:mysql-connector-j'

// lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

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

// rest docs
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'

// jpa
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
runtimeOnly 'com.mysql:mysql-connector-j'

// jwt
implementation 'io.jsonwebtoken:jjwt-api:0.11.2'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2', 'io.jsonwebtoken:jjwt-jackson:0.11.2'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.2'

// monitoring
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'

// fcm
implementation 'com.google.firebase:firebase-admin:9.2.0'

// logging
implementation 'ch.qos.logback.contrib:logback-json-classic:0.1.5'
implementation 'net.logstash.logback:logstash-logback-encoder:6.1'

implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
annotationProcessor 'jakarta.annotation:jakarta.annotation-api'
annotationProcessor 'jakarta.persistence:jakarta.persistence-api'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
}

tasks.withType(JavaCompile) {
Expand Down Expand Up @@ -77,8 +100,8 @@ jacocoTestReport {

def Qdomains = []

for(qPattern in "**/QA" .. "**/QZ"){
Qdomains.add(qPattern+"*")
for(qPattern in '**/QA' .. '**/QZ'){
Qdomains.add(qPattern + '*')
}

afterEvaluate {
Expand Down
26 changes: 9 additions & 17 deletions backend/ddang/script/dev-pipeline.jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
pipeline {
agent any

tools {
jdk "jdk-17.0.7"
}

environment {
JAVA_HOME = "tool jdk-17.0.7"
}

stages {
stage('build start notification to slack') {
steps {
slackSend (
channel: '#빌드-결과',
color: '#FFFF00',
message: "빌드 시작!: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.EC2_PUBLIC_IP}/jenkins)"
message: "빌드 시작!: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.INFRA_EC2_PUBLIC_IP}/jenkins)"
)
}
}
Expand All @@ -25,7 +17,7 @@ pipeline {
checkout scmGit(
branches: [[name: '*/develop-be']],
extensions: [submodule(parentCredentials: true, reference: '', trackingSubmodules: true)],
userRemoteConfigs: [[credentialsId: 'ddang-dev-token', url: 'https://github.com/woowacourse-teams/2023-3-ddang']])
userRemoteConfigs: [[credentialsId: 'github-token', url: 'https://github.com/woowacourse-teams/2023-3-ddang']])
}
}

Expand All @@ -40,11 +32,11 @@ pipeline {

stage('publish') {
steps {
sshagent(credentials: ['ddang-dev-ec2']) {
sh "scp backend/ddang/build/libs/ddang-0.0.1-SNAPSHOT.jar ubuntu@${env.EC2_PRIVATE_IP}:${env.EC2_DIRECTORY}"
sh "scp backend/ddang/3-ddang-submodule/application-dev.yml ubuntu@${env.EC2_PRIVATE_IP}:${env.EC2_DIRECTORY}"
sh "scp backend/ddang/script/dev-deploy-script.sh ubuntu@${env.EC2_PRIVATE_IP}:${env.EC2_DIRECTORY}"
sh "ssh ubuntu@${env.EC2_PRIVATE_IP} 'sh ${env.EC2_DIRECTORY}/dev-deploy-script.sh' "
sshagent(credentials: ['ec2-dev-key']) {
sh "scp backend/ddang/build/libs/ddang-0.0.1-SNAPSHOT.jar ubuntu@${env.DEV_EC2_PRIVATE_IP}:${env.EC2_DIRECTORY}"
sh "scp backend/ddang/3-ddang-submodule/application-dev.yml ubuntu@${env.DEV_EC2_PRIVATE_IP}:${env.EC2_DIRECTORY}"
sh "scp backend/ddang/script/dev-deploy-script.sh ubuntu@${env.DEV_EC2_PRIVATE_IP}:${env.EC2_DIRECTORY}"
sh "ssh ubuntu@${env.DEV_EC2_PRIVATE_IP} 'sh ${env.EC2_DIRECTORY}/dev-deploy-script.sh' "
}
}
}
Expand All @@ -62,15 +54,15 @@ pipeline {
channel: '#빌드-결과',
color: '#00FF00',
message: """
빌드 성공!: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.EC2_PUBLIC_IP}/jenkins)
빌드 성공!: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.INFRA_EC2_PUBLIC_IP}/jenkins)
"""
)
}
failure {
slackSend (
channel: '#빌드-결과',
color: '#FF0000',
message: "<!channel>\n빌드 실패...: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.EC2_PUBLIC_IP}/jenkins)"
message: "<!channel>\n빌드 실패...: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.INFRA_EC2_PUBLIC_IP}/jenkins)"
)
}
}
Expand Down
18 changes: 5 additions & 13 deletions backend/ddang/script/prod-pipeline.jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
pipeline {
agent any

tools {
jdk "jdk-17.0.7"
}

environment {
JAVA_HOME = "tool jdk-17.0.7"
}

stages {
stage('build start notification to slack') {
steps {
slackSend (
channel: '#빌드-결과',
color: '#FFFF00',
message: "빌드 시작!: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.EC2_PUBLIC_IP}/jenkins)"
message: "빌드 시작!: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.INFRA_EC2_PUBLIC_IP}/jenkins)"
)
}
}
Expand All @@ -25,7 +17,7 @@ pipeline {
checkout scmGit(
branches: [[name: '*/develop']],
extensions: [submodule(parentCredentials: true, reference: '', trackingSubmodules: true)],
userRemoteConfigs: [[credentialsId: 'ddang-dev-token', url: 'https://github.com/woowacourse-teams/2023-3-ddang']])
userRemoteConfigs: [[credentialsId: 'github-token', url: 'https://github.com/woowacourse-teams/2023-3-ddang']])
}
}

Expand All @@ -40,7 +32,7 @@ pipeline {

stage('publish') {
steps {
sshagent(credentials: ['ddang-prod-ec2']) {
sshagent(credentials: ['ec2-prod-key']) {
sh "scp backend/ddang/build/libs/ddang-0.0.1-SNAPSHOT.jar ubuntu@${env.PROD_EC2_PRIVATE_IP}:${env.EC2_DIRECTORY}"
sh "scp backend/ddang/3-ddang-submodule/application-prod.yml ubuntu@${env.PROD_EC2_PRIVATE_IP}:${env.EC2_DIRECTORY}"
sh "scp backend/ddang/script/prod-deploy-script.sh ubuntu@${env.PROD_EC2_PRIVATE_IP}:${env.EC2_DIRECTORY}"
Expand All @@ -62,15 +54,15 @@ pipeline {
channel: '#빌드-결과',
color: '#00FF00',
message: """
빌드 성공!: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.EC2_PUBLIC_IP}/jenkins)
빌드 성공!: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.INFRA_EC2_PUBLIC_IP}/jenkins)
"""
)
}
failure {
slackSend (
channel: '#빌드-결과',
color: '#FF0000',
message: "<!channel>\n빌드 실패...: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.EC2_PUBLIC_IP}/jenkins)"
message: "<!channel>\n빌드 실패...: pipeline : ${env.JOB_NAME}#${env.BUILD_NUMBER} (http://${env.INFRA_EC2_PUBLIC_IP}/jenkins)"
)
}
}
Expand Down
Loading

0 comments on commit 86e1110

Please sign in to comment.