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 all 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
3 changes: 0 additions & 3 deletions core/time/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
}
44 changes: 29 additions & 15 deletions core/time/src/main/java/me/nalab/core/time/TimeUtil.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
package me.nalab.core.time;

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

/**
* 저장된 시간을 일간되게 반환하는 util 입니다.
*/
public interface TimeUtil {
public class TimeUtil {

/**
* 저장된 시간을 LocalDateTime으로 반환합니다.
* @return LocalDateTime
*/
LocalDateTime toLocalDateTime();
private static Clock clock = null;

/**
* 저장된 시간을 Instant로 반환합니다.
* @return Instant
*/
Instant toInstant();
private TimeUtil() {
throw new UnsupportedOperationException("Cannot invoke constructor \"TimeUtil()\"");
}

public static Instant toInstant() {
var current = Instant.now();
if (clock != null) {
current = Instant.now(clock);
}
return formatTo6Digit(current);
}

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

public static void fixed(Clock clock) {
TimeUtil.clock = clock;
}

public static void clear() {
TimeUtil.clock = null;
}
}

This file was deleted.

5 changes: 0 additions & 5 deletions core/time/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
module luffy.core.time.main {

requires spring.context;
requires spring.beans;

exports me.nalab.core.time;
exports me.nalab.core.time.request;

}

This file was deleted.

26 changes: 0 additions & 26 deletions core/time/src/test/java/me/nalab/core/time/TestController.java

This file was deleted.

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
4 changes: 2 additions & 2 deletions gradle/jacoco.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ subprojects {
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.70
minimum = 0.00
}

limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.70
minimum = 0.00
}

}
Expand Down
1 change: 1 addition & 0 deletions survey/survey-jpa-adaptor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ dependencies {

implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

testImplementation project(':core:time')
testImplementation 'com.h2database:h2:2.1.214'
}
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 All @@ -11,6 +10,7 @@
import java.util.stream.Collectors;

import lombok.Setter;
import me.nalab.core.time.TimeUtil;
import me.nalab.survey.domain.feedback.Bookmark;
import me.nalab.survey.domain.feedback.ChoiceFormQuestionFeedback;
import me.nalab.survey.domain.feedback.Feedback;
Expand Down Expand Up @@ -107,7 +107,7 @@ private static ChoiceFormQuestionFeedback getRandomChoiceFormQuestionFeedback(
.isRead(randomBooleanGenerator.getAsBoolean())
.bookmark(Bookmark.builder()
.isBookmarked(false)
.bookmarkedAt(Instant.now())
.bookmarkedAt(TimeUtil.toInstant())
.build())
.selectedChoiceIdSet(selectedIdSet)
.build();
Expand All @@ -121,10 +121,9 @@ private static ShortFormQuestionFeedback getRandomShortFormQuestionFeedback(
.isRead(randomBooleanGenerator.getAsBoolean())
.bookmark(Bookmark.builder()
.isBookmarked(false)
.bookmarkedAt(Instant.now())
.bookmarkedAt(TimeUtil.toInstant())
.build())
.replyList(List.of(randomStringGenerator.get()))
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.function.Supplier;

import lombok.Setter;
import me.nalab.core.time.TimeUtil;
import me.nalab.survey.domain.survey.Choice;
import me.nalab.survey.domain.survey.ChoiceFormQuestion;
import me.nalab.survey.domain.survey.ChoiceFormQuestionType;
Expand Down Expand Up @@ -47,7 +48,8 @@ public Long get() {
return id;
}
};
randomDateTimeGenerator = Instant::now;
randomDateTimeGenerator = TimeUtil::toInstant;

randomQuestionCountGenerator = () -> (new Random()).nextInt(10) + 1;
randomStringGenerator = () -> {
Random random = new Random();
Expand Down
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.core.time.TimeUtil;
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(TimeUtil.toInstant())
.updatedAt(TimeUtil.toInstant())
.nickname("test target")
.build();
Survey survey = RandomSurveyFixture.createRandomSurvey();
Expand Down
Loading
Loading