작성
·
454
0
안녕하세요 🙂
github action build 시 오류가 발생하여 해결 방안을 찾고자
질문 내용을 작성했습니다.
-- IntegrationTest.class
package com.dnd.gooding.integration;
import java.io.File;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import org.junit.Ignore;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.transaction.annotation.Transactional;
import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.containers.wait.strategy.Wait;
@Ignore
@Transactional
@SpringBootTest
@ContextConfiguration(initializers = IntegrationTest.IntegrationTestInitializer.class)
public class IntegrationTest {
static DockerComposeContainer rdbms;
static {
rdbms =
new DockerComposeContainer(new File("infra/test/docker-compose.yml"))
.withExposedService(
"local-db",
3306,
Wait.forLogMessage(".*ready for connections.*", 1)
.withStartupTimeout(Duration.ofSeconds(180L)))
.withExposedService(
"local-db-migrate",
0,
Wait.forLogMessage("(.*Successfully applied.*)|(.*Successfully validated.*)", 1)
.withStartupTimeout(Duration.ofSeconds(180L)));
rdbms.start();
}
static class IntegrationTestInitializer
implements ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
Map<String, String> properties = new HashMap<>();
String rdbmsHost = rdbms.getServiceHost("local-db", 3306);
Integer rdbmsPort = rdbms.getServicePort("local-db", 3306);
properties.put(
"spring.datasource.url", "jdbc:mysql://" + rdbmsHost + ":" + rdbmsPort + "/gooding");
TestPropertyValues.of(properties).applyTo(applicationContext);
}
}
}
-- GoodingApplicationTest.class
class GoodingApplicationTest extends IntegrationTest {
@Test
void contextLoads() {
}
}
-- Github Action 스크립트
name: Pull Request Test
on:
pull_request:
types: [opened, synchronize, reopened]
permissions: read-all
jobs:
build-test:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Git Checkout
uses: actions/checkout@v3.0.2
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
application:
- 'build.gradle'
- 'src/**'
- name: JDK 설치
if: steps.changes.outputs.application == 'true'
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
cache: 'gradle'
- name: Gradle Build
if: steps.changes.outputs.application == 'true'
run: |
chmod +x ./gradlew
./gradlew build --parallel
-- Github Action 오류 발생
혹시 해당 오류의 원인을 알 수 있을까요..?? ㅠ
감사합니다 ㅠ
혹시 어떻게 해결했는지 알려주실 수 있을까요 ? ㅠㅠㅠㅠ