Newer
Older
apply plugin: "de.undercouch.download"
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.yaml:snakeyaml:1.33"
}
}
import org.yaml.snakeyaml.Yaml
ext {
nshmDir = "nshms";
envMemory = System.getenv("CI_RUNNER_MEMORY")
def xmx = envMemory ? envMemory : "16g"
downloadNshm = {nshm ->
def repo = nshm.repo
def zipName = "${repo}-${tag}.zip";
def zipFile = new File(nshmDir, zipName)
def nshmFile = file("${nshmDir}/${repo}-${year}")
if (nshmFile.exists()) {
delete nshmFile
}
src "https://code.usgs.gov/ghsc/nshmp/nshms/${repo}/-/archive/${tag}/${zipName}"
dest zipFile
file("${nshmDir}/${repo}-${tag}").renameTo(nshmFile)
// Returns a NSHM from nshms.yml array
findNshm = {repo, year ->
def yaml = new Yaml()
def nshmConfig = new Yaml().load(new File("${projectDir}/nshms.yml").newInputStream())
def nshm = nshmConfig.nshms.find{nshm -> nshm.repo == repo && nshm.year == year}
if (nshm == null) {
throw new Exception("NSHM ${repo} ${year} not found.")
}
return nshm
}
task cleanNshm(type: Delete) {
delete nshmDir
// Download all NSHMs
task nshms() {
dependsOn cleanNshm
def yaml = new Yaml()
def nshmConfig = new Yaml().load(new File("${projectDir}/nshms.yml").newInputStream())
doLast {
for (nshm in nshmConfig.nshms) {
// Download NSHM
downloadNshm(nshm)
}
}
}
// Test Alaska 2007 NSHM
task testAlaska2007(type: Test) {
description = "Test Alaska 2007 NSHM"
group = "verification"
doFirst {
downloadNshm(findNshm("nshm-alaska", 2007))
}
testLogging {
exceptionFormat "full"
}
useJUnitPlatform()
jvmArgs(
"-Xms2g",
)
filter {
includeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTests.testAlaska2007"
}
}
// Test Alaska 2023 NSHM
task testAlaska2023(type: Test) {
description = "Test Alaska 2023 NSHM"
group = "verification"
downloadNshm(findNshm("nshm-alaska", 2023))
testLogging {
exceptionFormat "full"
}
useJUnitPlatform()
jvmArgs(
"-Xms2g",
)
filter {
includeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTests.testAlaska2023"
}
}
// Test CONUS 2018 NSHM
task testConus2018(type: Test) {
description = "Test CONUS 2018 NSHM"
group = "verification"
downloadNshm(findNshm("nshm-conus", 2018))
testLogging {
exceptionFormat "full"
}
useJUnitPlatform()
jvmArgs(
"-Xms2g",
)
filter {
includeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTests.testConus2018"
}
}
// Test CONUS 2023 NSHM
task testConus2023(type: Test) {
description = "Test CONUS 2023 NSHM"
group = "verification"
downloadNshm(findNshm("nshm-conus", 2023))
testLogging {
exceptionFormat "full"
}
useJUnitPlatform()
jvmArgs(
"-Xms2g",
)
filter {
includeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTests.testConus2023"
}
}
// Test Hawaii 2021 NSHM
task testHawaii2021(type: Test) {
description = "Test Hawaii 2021 NSHM"
group = "verification"
downloadNshm(findNshm("nshm-hawaii", 2021))
testLogging {
exceptionFormat "full"
}
useJUnitPlatform()
jvmArgs(
"-Xms2g",