-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from MYONGSIK/develop
main <- develop
- Loading branch information
Showing
3 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | ||
|
||
name: Java CD with Gradle | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# 1) μν¬νλ‘μ° μ€ν μ κΈ°λ³Έμ μΌλ‘ 체ν¬μμ νμ | ||
- uses: actions/checkout@v3 | ||
|
||
# 2) JDK 11 λ²μ μ€μΉ | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
|
||
# 3) Gradle Caching | ||
- name: Gradle Cashing | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
# 4) Gradle κΆν λΆμ¬ | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
# 5) Build exclude test package | ||
#- name: Build with gradle | ||
# run: ./gradlew build -x test | ||
|
||
# 6) Set for yml | ||
- name: Make application-secret.yml | ||
run: | | ||
cd ./src/main/resources | ||
touch ./application-secret.yml | ||
echo "${{ secrets.PROPERTIES_TEST }}" > ./application-secret.yml | ||
shell: bash | ||
|
||
# 7) λΉλ | ||
- name: Build with gradle | ||
run: ./gradlew bootJar | ||
|
||
# 8) Docker λΉλ & νΈμ¬ | ||
- name: docker build and push | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -f Dockerfile -t myongsik_prod1 . | ||
docker tag myongsik_prod1 ${{ secrets.DOCKER_USERNAME }}/myongsik | ||
docker push ${{ secrets.DOCKER_USERNAME }}/myongsik | ||
# 9) Deploy | ||
- name: Deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.EC2_KEY }} | ||
script: | | ||
docker stop myongsik_prod1 | ||
docker rm myongsik_prod1 | ||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/myongsik | ||
sudo docker run -d --name myongsik_prod1 -v /etc/localtime:/etc/localtime:ro -e JAVA_OPTS=-Djasypt.encryptor.password=${{ secrets.YML_PASSWORD }} -e TZ=Asia/Seoul -e ENVIRONMENT_VALUE=-Dspring.profiles.active=prod -p 8081:8080 ${{ secrets.DOCKER_USERNAME }}/myongsik:latest | ||
docker rmi -f $(docker images -f "dangling=true" -q) |
File renamed without changes.
43 changes: 43 additions & 0 deletions
43
src/test/java/com/example/myongsick/domain/food/service/FoodServiceImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.example.myongsick.domain.food.service; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import com.example.myongsick.domain.food.dto.response.WeekFoodResponse; | ||
import com.example.myongsick.domain.food.repository.DinnerRepository; | ||
import com.example.myongsick.domain.food.repository.LunchRepository; | ||
import com.example.myongsick.domain.food.repository.WeekRepository; | ||
import java.util.List; | ||
import java.util.NoSuchElementException; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Transactional | ||
@SpringBootTest | ||
class FoodServiceImplTest { | ||
|
||
@Autowired FoodServiceImpl foodService; | ||
@Autowired WeekRepository weekRepository; | ||
@Autowired DinnerRepository dinnerRepository; | ||
@Autowired LunchRepository lunchRepository; | ||
|
||
@Test | ||
@DisplayName("μ£Όκ° μλ¨ μ‘°νμ, κ°μ΄ μλ κ²½μ° - μμΈ") | ||
void μ£Όκ°μλ¨μ‘°ν_NoSuchElement() { | ||
// given | ||
|
||
// when | ||
|
||
// then | ||
assertThrows(NoSuchElementException.class, () -> foodService.getWeekFoods()); | ||
} | ||
|
||
// @Test | ||
// @DisplayName("μ£Όκ° μλ¨ μ‘°νμ, κ°μ΄ μλ κ²½μ° - μ€ν¨") | ||
// void μ£Όκ°μλ¨μ‘°ν_μ€ν¨() { | ||
// assertThrows(IndexOutOfBoundsException.class, () -> foodService.getWeekFoods()); | ||
// } | ||
} |