From cdfda764f8e656ea91b50cfc01066dc28365a98b Mon Sep 17 00:00:00 2001 From: George Grant Date: Wed, 4 May 2022 16:13:04 -0400 Subject: [PATCH] Added a test to validate WDLs in the scripts directory. (#7826) Renamed existing test for validating generated WDLs. --- .github/workflows/gatk-tests.yml | 24 ++++++++++++---- build.gradle | 48 +++++++++++++++++++++++--------- 2 files changed, 53 insertions(+), 19 deletions(-) diff --git a/.github/workflows/gatk-tests.yml b/.github/workflows/gatk-tests.yml index 4fd19452523..6ad01a31f75 100644 --- a/.github/workflows/gatk-tests.yml +++ b/.github/workflows/gatk-tests.yml @@ -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: @@ -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: diff --git a/build.gradle b/build.gradle index 1d6726690e8..512dfd3c99b 100644 --- a/build.gradle +++ b/build.gradle @@ -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 @@ -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") @@ -875,7 +898,6 @@ task gatkWDLGenValidation(dependsOn: [gatkWDLGen, shadowJar]) { file("$buildDir/cromwell-workflow-logs").deleteDir() } } - }