Skip to content

Commit

Permalink
Only run 1 test when run on GHA to speed up the build.
Browse files Browse the repository at this point in the history
  • Loading branch information
fmmr committed Dec 3, 2024
1 parent 906a860 commit 9480d3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Java CI

env:
RUN_FROM: GHA

on: [push]

jobs:
Expand Down
14 changes: 8 additions & 6 deletions src/test/kotlin/no/rodland/advent/TestMisc.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import org.junit.jupiter.api.extension.ExtensionContext
import kotlin.system.measureTimeMillis
import kotlin.time.measureTimedValue

val GHA = System.getenv("RUN_FROM") == "GHA"

fun <T> report(function: () -> Pair<T, T>) {
getHeader().run {
println(this)
Expand Down Expand Up @@ -123,8 +125,8 @@ fun <T, S, U> defaultTestSuiteParseOnCall(
numTestPart1: Int = 10,
numTestPart2: Int = 10,
) = AOCTestSuite(
AOCTest(part1, liveData, livePart1, numTestPart1, day = day, part = Part.ONE, live = true),
AOCTest(part2, liveData, livePart2, numTestPart2, day = day, part = Part.TWO, live = true),
AOCTest(part1, liveData, livePart1, if (GHA) 1 else numTestPart1, day = day, part = Part.ONE, live = true),
AOCTest(part2, liveData, livePart2, if (GHA) 1 else numTestPart2, day = day, part = Part.TWO, live = true),
AOCTest(part1, testData, testPart1, 1, day, part = Part.ONE, live = false),
AOCTest(part2, testData, testPart2, 1, day, part = Part.TWO, live = false),
AOCTest(part1, liveData, livePart1, 1, day = day, part = Part.ONE, live = true),
Expand All @@ -146,12 +148,12 @@ fun <T, S> defaultTestSuiteParseOnInit(
numInitLive: Int = 100,
numInitTest: Int = 100,
) = AOCTestSuite(
AOCTest({ liveDay.partOne() }, Unit, livePart1, numTestPart1, liveDay.day, Part.ONE, true),
AOCTest({ liveDay.partTwo() }, Unit, livePart2, numTestPart2, liveDay.day, Part.TWO, true),
AOCTest({ liveDay.partOne() }, Unit, livePart1, if (GHA) 1 else numTestPart1, liveDay.day, Part.ONE, true),
AOCTest({ liveDay.partTwo() }, Unit, livePart2, if (GHA) 1 else numTestPart2, liveDay.day, Part.TWO, true),
AOCTest({ testDay.partOne() }, Unit, testPart1, 1, liveDay.day, Part.ONE, false),
AOCTest({ testDay.partTwo() }, Unit, testPart2, 1, liveDay.day, Part.TWO, false),
AOCTest({ initLive() }, Unit, Unit, numInitLive, liveDay.day, Part.INIT, live = true),
AOCTest({ initTest() }, Unit, Unit, numInitTest, liveDay.day, Part.INIT, live = false),
AOCTest({ initLive() }, Unit, Unit, numInitLive, if (GHA) 1 else liveDay.day, Part.INIT, live = true),
AOCTest({ initTest() }, Unit, Unit, numInitTest, if (GHA) 1 else liveDay.day, Part.INIT, live = false),
)


0 comments on commit 9480d3a

Please sign in to comment.