Skip to content

Commit

Permalink
Merge pull request #4 from FacerAin/feat/setup-cicd
Browse files Browse the repository at this point in the history
[Feat/#3] Sonarqube Github Action workflow 추가
  • Loading branch information
FacerAin authored Jan 27, 2024
2 parents 44ed478 + ae847b4 commit e31fd35
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build

on: [pull_request, workflow_dispatch]


jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Make application-prod.yml
run: |
touch src/main/resources/application-prod.yml
echo "${{ secrets.APPLICATION_PROD }}" | base64 --decode > src/main/resources/application-prod.yml
- name: Make application-test.yml
run: |
touch src/main/resources/application-test.yml
echo "${{ secrets.APPLICATION_TEST }}" | base64 --decode > src/main/resources/application-test.yml
- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew clean build sonar --info
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ build/

**/application-local.yml
**/application-prod.yml
**/application-test.yml

### IntelliJ IDEA ###
.idea
Expand Down
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.2.1'
id 'io.spring.dependency-management' version '1.1.4'
id "org.sonarqube" version "4.0.0.2929"
}

group = 'org.dnd'
Expand Down Expand Up @@ -36,6 +37,7 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'com.h2database:h2'

// third-party
implementation group: 'com.auth0', name: 'java-jwt', version: '4.3.0'
Expand All @@ -45,3 +47,9 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}

sonar {
properties {
property "sonar.projectKey", "dnd-10th-2-backend"
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/dnd/modutimer/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
@Entity
@Table(name = "user")
@Table(name = "member")
@Where(clause = "is_deleted=0")
@AttributeOverride(name = "id", column = @Column(name = "user_id"))
public class User extends AbstractJpaEntity {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
spring:
profiles:
active:
- local
- test
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;

@SpringBootTest
@TestPropertySource(properties = {"spring.config.location = classpath:application-test.yml"})
class ModutimerApplicationTests {

@Test
Expand Down

0 comments on commit e31fd35

Please sign in to comment.