attempt to fix github runner OOM

This commit is contained in:
Irmen de Jong committed 2026-08-30 23:44:05 +02:00
1 parent 05cbe74a60
commit a7c035f4d1
5 files changed
+42 -9

No files matched your search

+1 -1
View File
@@ -31,7 +31,7 @@ jobs:
run: ./gradlew compileKotlin compileTestKotlin --console=plain
- name: Test
run: ./gradlew test --continue --max-workers=3 --console=plain
run: ./gradlew test --continue --max-workers=3 -PtestConcurrency=2 -PtestMaxHeap=8g --console=plain
- name: Package
run: |
+7 -3
View File
@@ -72,16 +72,20 @@ subprojects {
// Enable JUnit 5 (required for Kotest)
useJUnitPlatform()
val testConcurrency = project.findProperty("testConcurrency")?.toString()?.toIntOrNull()
?: (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
project.findProperty("testMaxHeap")?.toString()?.let { maxHeapSize = it }
// Enable concurrent test execution for Kotest
// Set parallelism to number of CPU cores
jvmArgs("-Dkotest.framework.parallelism=${Runtime.getRuntime().availableProcessors()}")
// Allow CI to override parallelism for memory-constrained runners
jvmArgs("-Dkotest.framework.parallelism=$testConcurrency")
// Disable Kotest autoscan warning
jvmArgs("-Dkotest.framework.classpath.scanning.autoscan.disable=true")
// Enable Gradle's parallel test execution (runs multiple test classes concurrently)
// Use 50% of available processors to avoid over-subscription
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
maxParallelForks = testConcurrency
// Allow filtering tests via -PtestFilter="*TestName*" from command line
// Example: gradle test -PtestFilter="*TestLookup*"
+5 -1
View File
@@ -5,10 +5,14 @@ import io.kotest.core.spec.SpecExecutionOrder
import io.kotest.core.test.TestCaseOrder
import io.kotest.engine.concurrency.SpecExecutionMode
private val testParallelism = System.getProperty("kotest.framework.parallelism")?.toIntOrNull()
?.coerceAtLeast(1)
?: (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
object ProjectConfig : AbstractProjectConfig() {
override val testCaseOrder = TestCaseOrder.Lexicographic
override val specExecutionOrder = SpecExecutionOrder.Lexicographic
override val specExecutionMode = SpecExecutionMode.LimitedConcurrency(kotlin.math.max(1, Runtime.getRuntime().availableProcessors()/2))
override val specExecutionMode = SpecExecutionMode.LimitedConcurrency(testParallelism)
// override fun listeners() = listOf(SystemOutToNullListener)
}
+28 -4
View File
@@ -12,8 +12,32 @@ import prog8tests.helpers.CapturingSerialIO
import prog8tests.helpers.compileText
import prog8tests.helpers.simulate
import java.io.ByteArrayOutputStream
import java.io.OutputStream
import java.io.PrintStream
private class BoundedOutputStream(private val maxSize: Int): OutputStream() {
private val output = ByteArrayOutputStream(maxSize)
var overflowed = false
private set
override fun write(value: Int) {
if(output.size() < maxSize)
output.write(value)
else
overflowed = true
}
override fun write(bytes: ByteArray, offset: Int, length: Int) {
val remaining = maxSize - output.size()
if(remaining > 0)
output.write(bytes, offset, minOf(length, remaining))
if(length > remaining)
overflowed = true
}
override fun toString(): String = output.toString()
}
class TestRng: FunSpec({
@@ -234,17 +258,17 @@ main {
val result = compileText(VMTarget(), true, src, outputDir, writeAssembly=true)!!
val virtfile = result.compilationOptions.outputDir.resolve(result.compilerAst.name + ".p8ir").toFile()
val stdout = ByteArrayOutputStream()
val stdout = BoundedOutputStream(expectedOutput.toByteArray().size)
val originalOut = System.out
System.setOut(PrintStream(stdout))
try {
VmRunner().runProgram(virtfile.readText(), false)
VmRunner().runProgram(virtfile.readText(), true)
} finally {
System.setOut(originalOut)
}
val output = stdout.toString().replace("\r\n", "\n")
val relevant = output.substringBefore("\nProgram exit!")
relevant shouldBe expectedOutput
stdout.overflowed shouldBe false
output shouldBe expectedOutput
}
})
+1
View File
@@ -5,3 +5,4 @@ org.gradle.daemon=true
org.gradle.configuration-cache=false
kotlin.code.style=official
version=14.0-SNAPSHOT
testMaxHeap=8g