Skip to content

Commit

Permalink
Added a test to validate WDLs in the scripts directory. (#7826)
Browse files Browse the repository at this point in the history
Renamed existing test for validating generated WDLs.
  • Loading branch information
gbggrant committed May 4, 2022
1 parent 02cbbf1 commit cdfda76
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 19 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/gatk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,24 @@ jobs:
identifier: Java ${{ matrix.Java }} test on docker ${{matrix.testType}}
only-artifact: ${{ needs.check-secrets.outputs.google-credentials != 'true' }}

#run wdl validation on WDLs in the scripts directory
scriptsWdlValidation:
runs-on: ubuntu-latest
name: Validate script WDLs using womtools
steps:
- uses: actions/checkout@v2
with:
fetch: 0
- uses: ./.github/actions/install-cromwell
with:
CROMWELL_VERSION: ${{ env.CROMWELL_VERSION }}
- name: Run Scripts WDL Validation Test
run: ./gradlew gatkValidateScriptsWdl

#test wdl auto generation
wdlGen:
#run wdl validation on generated WDLs
generatedWdlValidation:
runs-on: ubuntu-latest
name: Test WDL Generation
name: Validate generated WDLs using womtools
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -270,9 +283,8 @@ jobs:
with:
CROMWELL_VERSION: ${{ env.CROMWELL_VERSION }}

- name: Run WDL Generation Test
run: ./gradlew gatkWDLGenValidation

- name: Run Generated WDL Validation Test
run: ./gradlew gatkValidateGeneratedWdl

#Run our various targeted medium scale wdl wiring tests
wdlTests:
Expand Down
48 changes: 35 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,20 @@ task gatkWDLGen(type: Javadoc, dependsOn: classes) {
options.addStringOption("build-dir", System.getenv("TRAVIS_BUILD_DIR") ?: new File(".").getAbsolutePath())
}

task gatkWDLGenValidation(dependsOn: [gatkWDLGen, shadowJar]) {
def execWDLValidation = { validateWDL ->
println "Executing: $validateWDL"
try {
def retCode = validateWDL.execute().waitFor()
if (retCode.intValue() != 0) {
throw new GradleException("Execution of \"$validateWDL\" failed with exit code: $retCode.")
}
return retCode
} catch (IOException e) {
throw new GradleException("An IOException occurred while attempting to execute the command $validateWDL.")
}
}

task gatkValidateScriptsWdl() {
doFirst {
// running this task requires a local cromwell installation, with environment variables CROMWELL_JAR,
// WOMTOOL_JAR set to the jar locations
Expand All @@ -825,21 +838,31 @@ task gatkWDLGenValidation(dependsOn: [gatkWDLGen, shadowJar]) {
}
}

def execWDLValidation = { validateWDL ->
println "Executing: $validateWDL"
try {
def retCode = validateWDL.execute().waitFor()
if (retCode.intValue() != 0) {
throw new GradleException("Execution of \"$validateWDL\" failed with exit code: $retCode.")
}
return retCode
} catch (IOException e) {
throw new GradleException("An IOException occurred while attempting to execute the command $validateWDL.")
doLast {
// Run the womtool validator on all WDL files in the 'scripts' directory
final File wdlFolder = new File("scripts")
def wdlFiles = fileTree(dir: wdlFolder).filter {
f -> f.getAbsolutePath().endsWith(".wdl")
}
final womtoolLocation = System.getenv('WOMTOOL_JAR')
wdlFiles.any() { wdlFile ->
final validateWDLCommand = "java -jar $womtoolLocation validate $wdlFile"
execWDLValidation(validateWDLCommand)
}
}
}

task gatkValidateGeneratedWdl(dependsOn: [gatkWDLGen, shadowJar]) {
doFirst {
// running this task requires a local cromwell installation, with environment variables CROMWELL_JAR,
// WOMTOOL_JAR set to the jar locations
if (System.getenv('CROMWELL_JAR') == null || System.getenv('WOMTOOL_JAR') == null) {
throw new GradleException("Running this task requires the CROMWELL_JAR and WOMTOOL_JAR environment variables to be set")
}
}

doLast {
// first, run the womtool validator
// first, run the womtool validator on WDL files in the 'docs/wdlGen' directory
final File wdlGenFolder = new File("$docBuildDir/wdlGen")
def wdlFiles = fileTree(dir: wdlGenFolder).filter {
f -> !f.getAbsolutePath().endsWith(".html") && !f.getAbsolutePath().endsWith(".json")
Expand Down Expand Up @@ -875,7 +898,6 @@ task gatkWDLGenValidation(dependsOn: [gatkWDLGen, shadowJar]) {
file("$buildDir/cromwell-workflow-logs").deleteDir()
}
}

}


Expand Down

0 comments on commit cdfda76

Please sign in to comment.