From aa80a317bc3e5a1102c41df18a1aa27901aef7a6 Mon Sep 17 00:00:00 2001 From: Matt Busche Date: Sun, 21 May 2023 16:59:57 -0500 Subject: [PATCH] Run tests more efficiently --- .github/workflows/gradle.yml | 29 +++++++++++++++---- build.gradle.kts | 4 +++ .../report/CommandLineAppStartupRunner.java | 2 ++ .../java/trap/report/ReportHelperTest.java | 26 ----------------- 4 files changed, 29 insertions(+), 32 deletions(-) delete mode 100644 src/test/java/trap/report/ReportHelperTest.java diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index e326e74..9d05557 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -12,7 +12,7 @@ jobs: java-version: [ 17, 20 ] steps: - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up JDK ${{ matrix.java-version }} @@ -23,10 +23,27 @@ jobs: java-version: ${{ matrix.java-version }} - name: Setup and execute Gradle uses: gradle/gradle-build-action@v2 - - name: Run Gradle task + - name: Run Gradle build shell: bash run: >- - ./gradlew build --no-daemon --info - -Dorg.gradle.parallel=true - -Dorg.gradle.caching=true - -Dorg.gradle.jvmargs="-Xms4g -Xmx6g -XX:+HeapDumpOnOutOfMemoryError -XX:MaxMetaspaceSize=512m" + export SPRING_PROFILES_ACTIVE=test && ./gradlew build --no-daemon --info + - name: Generate file + run: | + cd build/libs/ + mv trap-*.jar trap.jar + java -jar trap.jar + ls -ltra + test -f league-data-*.xlsx || exit 1 +# file1size=stat -c %s league-data-*.xlsx +# echo "file 1 size successful" +# file2size=stat -c %s ../../src/main/resources/main-template.xlsx +# echo "file 2 size successful" +# echo "file1size" +# echo $file1size +# echo "file2size" +# echo $file2size +# if("file1size" -lt "file2size");then +# echo "file 1 is smaller" +# fi + + diff --git a/build.gradle.kts b/build.gradle.kts index 19e7185..609a6b5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,3 +29,7 @@ dependencies { tasks.withType { useJUnitPlatform() } + +tasks.getByName("jar") { + enabled = false +} diff --git a/src/main/java/trap/report/CommandLineAppStartupRunner.java b/src/main/java/trap/report/CommandLineAppStartupRunner.java index 35ff41f..77f763f 100644 --- a/src/main/java/trap/report/CommandLineAppStartupRunner.java +++ b/src/main/java/trap/report/CommandLineAppStartupRunner.java @@ -2,8 +2,10 @@ import lombok.RequiredArgsConstructor; import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; +@Profile("!test") @Component @RequiredArgsConstructor public class CommandLineAppStartupRunner implements CommandLineRunner { diff --git a/src/test/java/trap/report/ReportHelperTest.java b/src/test/java/trap/report/ReportHelperTest.java deleted file mode 100644 index 2d99cb6..0000000 --- a/src/test/java/trap/report/ReportHelperTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package trap.report; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -import java.io.File; -import java.util.Objects; -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; - -@SpringBootTest -class ReportHelperTest { - - @Test - void testFileCreated() { - String excelFileName = Stream.of(Objects.requireNonNull(new File(".").listFiles())) - .filter(file -> !file.isDirectory()) - .map(File::getName) - .filter(fileName -> fileName.endsWith(".xlsx")) - .findFirst() - .orElseThrow(); - long fileSize = new File(excelFileName).length(); - assertThat(fileSize).isGreaterThan(125813L); - } -} \ No newline at end of file