Skip to content

Commit

Permalink
feat: implements the container_value lint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
claymcleod committed Jul 26, 2024
1 parent 6faf7db commit 00bae84
Show file tree
Hide file tree
Showing 33 changed files with 3,147 additions and 64 deletions.
495 changes: 495 additions & 0 deletions Arena.toml

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Gauntlet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ commit_hash = "efb0eadd70fe21fe9484a310f12a6c54b752db43"

[repositories."broadinstitute/warp"]
identifier = "broadinstitute/warp"
commit_hash = "ecfa98a29fe5d6b6b3284bdb0eac191b973f7377"
commit_hash = "ed37de679ea878d4c3020ca16dad836e65695623"

[repositories."chanzuckerberg/czid-workflows"]
identifier = "chanzuckerberg/czid-workflows"
commit_hash = "79f77cff3ebc013930cef3d5d63b3b2ca9b32e30"
commit_hash = "d443456a8e99124945e216ec623368cf0c92e7b6"

[repositories."getwilds/ww-fastq-to-cram"]
identifier = "getwilds/ww-fastq-to-cram"
Expand All @@ -49,7 +49,7 @@ filters = ["/template/task-templates.wdl"]

[repositories."theiagen/public_health_bioinformatics"]
identifier = "theiagen/public_health_bioinformatics"
commit_hash = "ba1804b584b2a9012ed99e0456f6c78efa50a397"
commit_hash = "935a8b446c94dc3c72eaa79d0d060977ca0ef7d6"

[[diagnostics]]
document = "aws-samples/amazon-omics-tutorials:/example-workflows/gatk-best-practices/workflows/somatic-snps-and-indels/mutec2.wdl"
Expand Down Expand Up @@ -384,34 +384,34 @@ permalink = "https://github.com/broadinstitute/palantir-workflows/blob/efb0eadd7
[[diagnostics]]
document = "broadinstitute/warp:/pipelines/skylab/scATAC/scATAC.wdl"
message = "scATAC.wdl:203:9: error: duplicate key `cpu` in runtime section"
permalink = "https://github.com/broadinstitute/warp/blob/ecfa98a29fe5d6b6b3284bdb0eac191b973f7377/pipelines/skylab/scATAC/scATAC.wdl/#L203"
permalink = "https://github.com/broadinstitute/warp/blob/ed37de679ea878d4c3020ca16dad836e65695623/pipelines/skylab/scATAC/scATAC.wdl/#L203"

[[diagnostics]]
document = "broadinstitute/warp:/tasks/broad/GermlineVariantDiscovery.wdl"
message = "GermlineVariantDiscovery.wdl:140:32: error: expected string, but found integer"
permalink = "https://github.com/broadinstitute/warp/blob/ecfa98a29fe5d6b6b3284bdb0eac191b973f7377/tasks/broad/GermlineVariantDiscovery.wdl/#L140"
permalink = "https://github.com/broadinstitute/warp/blob/ed37de679ea878d4c3020ca16dad836e65695623/tasks/broad/GermlineVariantDiscovery.wdl/#L140"

[[diagnostics]]
document = "broadinstitute/warp:/tasks/broad/GermlineVariantDiscovery.wdl"
message = "GermlineVariantDiscovery.wdl:67:32: error: expected string, but found integer"
permalink = "https://github.com/broadinstitute/warp/blob/ecfa98a29fe5d6b6b3284bdb0eac191b973f7377/tasks/broad/GermlineVariantDiscovery.wdl/#L67"
permalink = "https://github.com/broadinstitute/warp/blob/ed37de679ea878d4c3020ca16dad836e65695623/tasks/broad/GermlineVariantDiscovery.wdl/#L67"

[[diagnostics]]
document = "broadinstitute/warp:/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl"
message = "UltimaGenomicsWholeGenomeGermlineTasks.wdl:814:27: error: expected string, but found integer"
permalink = "https://github.com/broadinstitute/warp/blob/ecfa98a29fe5d6b6b3284bdb0eac191b973f7377/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl/#L814"
permalink = "https://github.com/broadinstitute/warp/blob/ed37de679ea878d4c3020ca16dad836e65695623/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl/#L814"

[[diagnostics]]
document = "broadinstitute/warp:/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl"
message = "UltimaGenomicsWholeGenomeGermlineTasks.wdl:866:27: error: expected string, but found integer"
permalink = "https://github.com/broadinstitute/warp/blob/ecfa98a29fe5d6b6b3284bdb0eac191b973f7377/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl/#L866"
permalink = "https://github.com/broadinstitute/warp/blob/ed37de679ea878d4c3020ca16dad836e65695623/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl/#L866"

[[diagnostics]]
document = "broadinstitute/warp:/tests/cemba/pr/CheckCembaOutputs.wdl"
message = "CheckCembaOutputs.wdl:1:1: error: a WDL document must start with a version statement"
permalink = "https://github.com/broadinstitute/warp/blob/ecfa98a29fe5d6b6b3284bdb0eac191b973f7377/tests/cemba/pr/CheckCembaOutputs.wdl/#L1"
permalink = "https://github.com/broadinstitute/warp/blob/ed37de679ea878d4c3020ca16dad836e65695623/tests/cemba/pr/CheckCembaOutputs.wdl/#L1"

[[diagnostics]]
document = "chanzuckerberg/czid-workflows:/workflows/index-generation/index-generation.wdl"
message = "index-generation.wdl:1:9: error: unsupported WDL version `development`"
permalink = "https://github.com/chanzuckerberg/czid-workflows/blob/79f77cff3ebc013930cef3d5d63b3b2ca9b32e30/workflows/index-generation/index-generation.wdl/#L1"
permalink = "https://github.com/chanzuckerberg/czid-workflows/blob/d443456a8e99124945e216ec623368cf0c92e7b6/workflows/index-generation/index-generation.wdl/#L1"
9 changes: 9 additions & 0 deletions wdl-ast/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# Unreleased

* Add `as_*()` and `into_*()` methods for each enum item in `Expr` and `LiteralExpr`
([#142](https://github.com/stjude-rust-labs/wdl/pull/142)).
* Add parsing of `container` elements within `runtime` and `requirements` blocks
according to the [current version of the WDL
specification](https://github.com/openwdl/wdl/blob/wdl-1.2/SPEC.md#container)
([#142](https://github.com/stjude-rust-labs/wdl/pull/142)).

## 0.5.0 - 07-17-2024

### Added
Expand Down
39 changes: 39 additions & 0 deletions wdl-ast/examples/explore_requirements.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//! Prints `requirements` keys from the first task in a WDL document.
use wdl_ast::AstToken;
use wdl_ast::Document;

fn main() {
let path = std::env::args().nth(1).expect("missing path");
let contents = std::fs::read_to_string(path).expect("file to be readable to string");

let (document, diagnostics) = Document::parse(&contents);

if !diagnostics.is_empty() {
eprintln!(
"warning: {n} diagnostics were detected, this may affect results",
n = diagnostics.len()
)
}

let task = document
.ast()
// SAFETY: only V1 ASTs are supported for this example at present.
.unwrap_v1()
.tasks()
.next()
// SAFETY: we expect the document to contain at least one task for this example
// to work correctly.
.expect("document to contain at least one task");

let requirements = task.requirements().next().unwrap_or_else(|| {
panic!(
"a `requirements` section to be present in task {name}",
name = task.name().syntax()
)
});

if let Some(container) = requirements.container() {
println!("{:?}", container);
};
}
39 changes: 39 additions & 0 deletions wdl-ast/examples/explore_runtime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//! Prints `runtime` keys from the first task in a WDL document.
use wdl_ast::AstToken;
use wdl_ast::Document;

fn main() {
let path = std::env::args().nth(1).expect("missing path");
let contents = std::fs::read_to_string(path).expect("file to be readable to string");

let (document, diagnostics) = Document::parse(&contents);

if !diagnostics.is_empty() {
eprintln!(
"warning: {n} diagnostics were detected, this may affect results",
n = diagnostics.len()
)
}

let task = document
.ast()
// SAFETY: only V1 ASTs are supported for this example at present.
.unwrap_v1()
.tasks()
.next()
// SAFETY: we expect the document to contain at least one task for this example
// to work correctly.
.expect("document to contain at least one task");

let runtime = task.runtimes().next().unwrap_or_else(|| {
panic!(
"a `runtime` section to be present in task {name}",
name = task.name().syntax()
)
});

if let Some(container) = runtime.container() {
println!("{:?}", container);
};
}
17 changes: 17 additions & 0 deletions wdl-ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,23 @@ impl Ast {
_ => None,
}
}

/// Consumes `self` to attempt to return the V1 AST.
pub fn into_v1(self) -> Option<v1::Ast> {
match self {
Self::V1(ast) => Some(ast),
_ => None,
}
}

/// Consumes `self` to attempt to return the V1 AST.
///
/// # Panics
///
/// Panics if the AST is not a V1 AST.
pub fn unwrap_v1(self) -> v1::Ast {
self.into_v1().expect("the AST is not a V1 AST")
}
}

/// Represents a single WDL document.
Expand Down
Loading

0 comments on commit 00bae84

Please sign in to comment.