Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] : JDK version migration 11 to 17 #372

Merged
merged 7 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/accept-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
with:
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
java-version: 17
- name: Cache Gradle packages
uses: actions/cache@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-release-publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v3

- name: Setup opnenjdk-11
- name: Setup opnenjdk-17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-stage-publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v3

- name: Setup opnenjdk-11
- name: Setup opnenjdk-17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ jobs:
- name: checkout
uses: actions/checkout@v3

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

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
Comment on lines +23 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup-java에서 gradle cache 있었던 거 같은데 다른가 이거랑?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이게 다른 .yml에서 한번이상 cache하면 재사용되는데, 우리처럼 시간 오래지나서 cache한게 없으면 실패되더라고
이거 ciaks 독립적으로 재사용하려면 넣어줘야할거같아


- name: docker setup
uses: docker-practice/actions-setup-docker@master

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
with:
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
java-version: 17
- name: Cache Gradle packages
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:11.0.11-jre-slim
FROM openjdk:17-jdk-slim

ARG JAR_FILE=./api/build/libs/*-SNAPSHOT.jar
ARG DB_URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;

import java.time.format.DateTimeFormatter;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;
Expand All @@ -20,7 +22,10 @@ public class RequestTimeUtil implements TimeUtil {
private final Instant instant;

public RequestTimeUtil() {
instant = Instant.now();
var current = Instant.now();
var formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSX")
.withZone(ZoneId.of("UTC"));
this.instant = Instant.parse(formatter.format(current));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변경이유

DB에서 TIMESTAMP(6) 로 저장하고있는데, Instant.now() 가 9-digit 날짜를 생성해서 DB데이터에 들어갔다가 나온 데이터 <-> 검증데이터 간의 테스트가 깨지는 이슈가 있었고, RequestTimeUtil이 6-digit 시간을 반환하도록 수정했습니다.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DB쪽 timestamp precision 올리는 건 어렵나?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

될거같은데, 한번 flyway랑 @Entity 쪽 수정해서 CI 돌려보겠슴니다

}

/**
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ applicationVersion=0.0.1-SNAPSHOT

### Project configs ###
projectGroup=me.nalab
javaVersion=11
javaVersion=17

### Spring dependency versions ###
springBootVersion=2.7.11
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.nalab.survey.jpa.adaptor;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -107,7 +106,7 @@ private static ChoiceFormQuestionFeedback getRandomChoiceFormQuestionFeedback(
.isRead(randomBooleanGenerator.getAsBoolean())
.bookmark(Bookmark.builder()
.isBookmarked(false)
.bookmarkedAt(Instant.now())
.bookmarkedAt(TestTimeUtil.now())
.build())
.selectedChoiceIdSet(selectedIdSet)
.build();
Expand All @@ -121,10 +120,9 @@ private static ShortFormQuestionFeedback getRandomShortFormQuestionFeedback(
.isRead(randomBooleanGenerator.getAsBoolean())
.bookmark(Bookmark.builder()
.isBookmarked(false)
.bookmarkedAt(Instant.now())
.bookmarkedAt(TestTimeUtil.now())
.build())
.replyList(List.of(randomStringGenerator.get()))
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public Long get() {
return id;
}
};
randomDateTimeGenerator = Instant::now;
randomDateTimeGenerator = () -> {
return TestTimeUtil.now();
};

randomQuestionCountGenerator = () -> (new Random()).nextInt(10) + 1;
randomStringGenerator = () -> {
Random random = new Random();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package me.nalab.survey.jpa.adaptor;

import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

public class TestTimeUtil {

public static Instant now() {
var current = Instant.now();
var formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSX")
.withZone(ZoneId.of("UTC"));
return Instant.parse(formatter.format(current));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.time.Instant;

import javax.persistence.EntityManager;

import me.nalab.survey.jpa.adaptor.TestTimeUtil;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -55,8 +54,8 @@ void SURVEY_PERSISTENCE_SUCCESS() {
// given
TargetEntity targetEntity = TargetEntity.builder()
.id(101L)
.createdAt(Instant.now())
.updatedAt(Instant.now())
.createdAt(TestTimeUtil.now())
.updatedAt(TestTimeUtil.now())
.nickname("test target")
.build();
Survey survey = RandomSurveyFixture.createRandomSurvey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import static org.junit.jupiter.api.Assertions.*;

import java.time.Instant;
import java.util.List;

import javax.persistence.EntityManager;

import me.nalab.survey.jpa.adaptor.TestTimeUtil;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -29,7 +29,7 @@
@DataJpaTest
@EnableJpaRepositories
@EntityScan("me.nalab.core.data")
@ContextConfiguration(classes = FeedbackFindAdaptor.class)
@ContextConfiguration(classes = {FeedbackFindAdaptor.class})
@TestPropertySource("classpath:h2.properties")
class FeedbackFindAdaptorTest {

Expand Down Expand Up @@ -89,8 +89,8 @@ void FIND_ALL_FEEDBACK_WITH_SURVEY_ID_WITH_NO_FEEDBACK() {
private TargetEntity getTargetEntity() {
return TargetEntity.builder()
.id(1L)
.createdAt(Instant.now())
.updatedAt(Instant.now())
.createdAt(TestTimeUtil.now())
.updatedAt(TestTimeUtil.now())
.nickname("nalab")
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import static org.junit.jupiter.api.Assertions.*;

import java.time.Instant;
import java.util.Optional;

import javax.persistence.EntityManager;

import me.nalab.survey.jpa.adaptor.TestTimeUtil;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -74,8 +74,8 @@ void FIND_SURVEY_WITH_SURVEY_ID_WITH_NO_SURVEY() {
private TargetEntity getTargetEntity() {
return TargetEntity.builder()
.id(1L)
.createdAt(Instant.now())
.updatedAt(Instant.now())
.createdAt(TestTimeUtil.now())
.updatedAt(TestTimeUtil.now())
.nickname("nalab")
.build();
}
Expand Down
Loading