Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: format #133

Merged
merged 61 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
7f3a812
feat: introduces WDL format
a-frantz Jul 17, 2024
53b883e
tests: format framework (everything panics)
a-frantz Oct 4, 2024
030a3e2
fix(wdl-ast/element): typos in macro call
a-frantz Oct 4, 2024
067e89f
[WIP]
a-frantz Oct 4, 2024
03a0a6e
revise: `s/preceeding/preceding/g`
claymcleod Oct 4, 2024
0064569
revise: updates default indent size
claymcleod Oct 4, 2024
bd0591f
[WIP]revise: rework trivia
a-frantz Oct 5, 2024
fd4da2e
[WIP]revise: trivia rework
a-frantz Oct 5, 2024
e128913
chore: cargo fmt
a-frantz Oct 6, 2024
cb86d0b
[WIP]
a-frantz Oct 6, 2024
c8ac499
[WIP]
a-frantz Oct 7, 2024
63a4eb2
[WIP]
a-frantz Oct 7, 2024
acf0f15
[WIP]
a-frantz Oct 7, 2024
d97580f
[WIP]
a-frantz Oct 8, 2024
343353a
[WIP] tests: seaseq case formats
a-frantz Oct 9, 2024
2cef6f8
[WIP]tests: format each current test
a-frantz Oct 10, 2024
23331da
fix: escape quotes when writing strings
a-frantz Oct 10, 2024
94aa668
feat: all elements in the tree are formatted
a-frantz Oct 10, 2024
fd4b145
fix: don't line split empty arrays
a-frantz Oct 10, 2024
1e66dd0
revise: reorganize format functions
a-frantz Oct 10, 2024
1aee371
feat: line split if/then/else exprs
a-frantz Oct 11, 2024
6f35e56
revise: rename BlankLinesContext
a-frantz Oct 11, 2024
58eeff3
feat: implement LineSpacingPolicy
a-frantz Oct 11, 2024
d2d699f
revise: simplify blank line logic
a-frantz Oct 11, 2024
ea53d1b
Merge branch 'main' into feat/format
a-frantz Oct 11, 2024
502fca0
chore: cleanup after merge
a-frantz Oct 11, 2024
5696b29
revise(LineSpacingPolicy): BetweenComments->BeforeComments
a-frantz Oct 11, 2024
c5581ea
Update Gauntlet.toml
a-frantz Oct 11, 2024
7e1bfa4
chore: rm backup/
a-frantz Oct 11, 2024
72d9238
revise: change how if elses are handled
a-frantz Oct 11, 2024
f2b5453
Update expr.rs
a-frantz Oct 12, 2024
3aed4cf
revise: don't line split empty meta items
a-frantz Oct 12, 2024
9911f52
feat: AssertConsumedIter
a-frantz Oct 12, 2024
83b4757
tests: test for unconsumed children
a-frantz Oct 12, 2024
9f46bd4
chore: cleanup
a-frantz Oct 14, 2024
2cf5814
docs: add docstrings
a-frantz Oct 14, 2024
ba3d0fe
chore: rm wdl-config
a-frantz Oct 14, 2024
9f80c4a
chore: clean up tree.rs
a-frantz Oct 14, 2024
7b5faf8
Update stdlib.rs
a-frantz Oct 14, 2024
fe317be
Update Gauntlet.toml
a-frantz Oct 14, 2024
a89b3ee
fix: don't reference TaskHints in workflow sections
a-frantz Oct 14, 2024
34ddab3
docs: CHANGELOG updates
a-frantz Oct 14, 2024
68a6b1c
Delete engine.rs
a-frantz Oct 14, 2024
de61347
Apply suggestions from code review
a-frantz Oct 14, 2024
a758c8a
chore: cargo fmt
a-frantz Oct 14, 2024
f7cfedc
chore: revert placeholder changes
a-frantz Oct 14, 2024
bf631d8
chore: revert bad hints changes
a-frantz Oct 14, 2024
df4f263
Update v1.rs
a-frantz Oct 14, 2024
7ddb8a7
chore: cleanup
a-frantz Oct 14, 2024
35aed7e
Update main.rs
a-frantz Oct 14, 2024
31bd09a
Update Gauntlet.toml
a-frantz Oct 14, 2024
c8f3770
tests: move registry.rs to tests/
a-frantz Oct 14, 2024
a6ef511
Update registry.rs
a-frantz Oct 14, 2024
e77afde
tests: reconfigure
a-frantz Oct 14, 2024
160dc8b
feat: use config for indents
a-frantz Oct 14, 2024
af1462a
revise: code review feedback
a-frantz Oct 15, 2024
d6aff8b
Apply suggestions from code review
a-frantz Oct 15, 2024
84090d9
chore: code review feedback
a-frantz Oct 15, 2024
68b70b8
chore: cargo fmt
a-frantz Oct 15, 2024
3cbf60b
fix: display for Token
a-frantz Oct 15, 2024
286602d
Update post.rs
a-frantz Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
format:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update nightly && rustup default nightly
- name: Install rustfmt
Expand All @@ -20,7 +20,7 @@ jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update stable && rustup default stable
- name: Install clippy
Expand All @@ -30,53 +30,62 @@ jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update stable && rustup default stable
- run: cargo test --all-features

test-examples:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update stable && rustup default stable
- run: cargo test --all-features --examples

docs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update stable && rustup default stable
- run: cargo doc

gauntlet:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update stable && rustup default stable
- run: cargo run --release --bin gauntlet

arena:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update stable && rustup default stable
- run: cargo run --release --bin gauntlet -- --arena

workspace-lints-enabled:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update stable && rustup default stable
- run: cargo install cargo-workspace-lints --locked
- run: cargo workspace-lints

msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update stable && rustup default stable
- name: Install cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install cargo-msrv
run: cargo binstall -y --version 0.16.0-beta.23 cargo-msrv
- name: Verify the MSRV
working-directory: ./wdl
run: cargo msrv verify --output-format minimal --all-features
- uses: actions/checkout@v4
- name: Update Rust
run: rustup update stable && rustup default stable
- name: Install cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install cargo-msrv
run: cargo binstall -y --version 0.16.0-beta.23 cargo-msrv
- name: Verify the MSRV
working-directory: ./wdl
run: cargo msrv verify --output-format minimal --all-features
70 changes: 44 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[workspace]
members = [ "ci",
members = [
"ci",
"gauntlet",
"wdl",
"wdl-analysis",
"wdl-ast",
"gauntlet",
"wdl-format",
"wdl-grammar",
"wdl-lint",
"wdl-lsp",
Expand All @@ -19,40 +21,56 @@ repository = "https://github.com/stjude-rust-labs/wdl"
rust-version = "1.80.0"

[workspace.dependencies]
anyhow = "1.0.86"
approx = "0.5.1"
clap = { version = "4.5.7", features = ["derive"] }
clap-verbosity-flag = "2.2.1"
codespan-reporting = "0.11.1"
colored = "2.1.0"
convert_case = "0.6.0"
dirs = "5.0.1"
faster-hex = "0.9.0"
futures = "0.3.30"
git2 = "0.18.3"
id-arena = "2.2.1"
indexmap = { version = "2.2.6", features = ["serde"] }
indicatif = "0.17.8"
itertools = "0.13.0"
line-index = "0.1.1"
logos = "0.14.0"
nonempty = "0.10.0"
parking_lot = "0.12.3"
path-clean = "1.0.1"
petgraph = "0.6.5"
pretty_assertions = "1.4.0"
rayon = "1.10.0"
reqwest = "0.12.5"
rowan = "0.15.15"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0.120"
serde_with = "3.8.1"
tempfile = "3.10.1"
tokio = { version = "1.38.0", features = ["full"] }
toml = "0.8.14"
tower-lsp = "0.20.0"
tracing = "0.1.40"
tracing-log = "0.2.0"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
logos = "0.14.0"
rowan = "0.15.15"
pretty_assertions = "1.4.0"
rayon = "1.10.0"
approx = "0.5.1"
codespan-reporting = "0.11.1"
anyhow = "1.0.86"
dirs = "5.0.1"
faster-hex = "0.9.0"
git2 = "0.18.3"
tempfile = "3.10.1"
url = "2.5.2"
urlencoding = "2.1.3"
parking_lot = "0.12.3"
reqwest = "0.12.5"
petgraph = "0.6.5"
futures = "0.3.30"
walkdir = "2.5.0"
path-clean = "1.0.1"
indicatif = "0.17.8"
tower-lsp = "0.20.0"
line-index = "0.1.1"
serde_json = "1.0.120"
uuid = "1.10.0"
id-arena = "2.2.1"
clap-verbosity-flag = "2.2.1"
tracing-log = "0.2.0"
walkdir = "2.5.0"

[workspace.lints.rust]
missing_docs = "warn"
nonstandard-style = "warn"
rust-2018-idioms = "warn"
rust-2021-compatibility = "warn"
rust-2024-compatibility = "warn"
edition_2024_expr_fragment_specifier = "allow"

[workspace.lints.rustdoc]
broken_intra_doc_links = "warn"

[workspace.lints.clippy]
missing_docs_in_private_items = "warn"
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ cargo run --bin wdl --features cli -- $ARGS

Where `$ARGS` are the command line arguments to the `wdl` CLI tool.

The `wdl` CLI tool currently supports three subcommands:
The `wdl` CLI tool currently supports the following subcommands:

* `parse` - Parses a WDL document and prints both the parse diagnostics and the
resulting Concrete Syntax Tree (CST).
Expand All @@ -137,6 +137,8 @@ The `wdl` CLI tool currently supports three subcommands:
document scopes and exits with a status code of `0` if the documents are
valid; otherwise, prints the validation diagnostics and exits with a status
code of `1`.
* `format` - Parses, validates, and then formats a single WDL document, printing
the result to STDOUT.
adthrasher marked this conversation as resolved.
Show resolved Hide resolved

Each of the subcommands supports passing `-` as the file path to denote reading
from STDIN instead of a file on disk.
Expand Down
3 changes: 3 additions & 0 deletions ci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ clap.workspace = true
reqwest = { workspace = true, features = ["blocking", "rustls-tls"] }
toml.workspace = true
toml_edit = { version = "0.22.21", features = ["serde"] }

[lints]
workspace = true
47 changes: 39 additions & 8 deletions ci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,55 +48,82 @@ use std::time::Duration;
use clap::Parser;
use toml_edit::DocumentMut;

// note that this list must be topologically sorted by dependencies
/// Crates names to publish.
// Note that this list must be topologically sorted by dependencies.
const SORTED_CRATES_TO_PUBLISH: &[&str] = &[
"wdl-grammar",
"wdl-ast",
"wdl-lint",
"wdl-format",
"wdl-analysis",
"wdl-lsp",
"wdl",
];

/// Paths to ignore.
const IGNORE_PATHS: &[&str] = &["target", "tests", "examples", "benches", "book", "docs"];

/// An in-memory representation of a crate.
#[derive(Debug, Clone)]
struct Crate {
/// The manifest file.
manifest: DocumentMut,

/// The path to the manifest.
manifest_path: PathBuf,

/// The path to the changelog.
changelog_path: Option<PathBuf>,

/// The name of the crate.
name: String,

/// The version of the crate.
version: String,

/// Whether the version should be bumped.
should_bump: bool,
}

/// The command line arguments.
#[derive(Parser)]
struct Opts {
struct Args {
/// The subcommand.
#[clap(subcommand)]
subcmd: SubCommand,
command: Subcommand,
}

/// The subcommand to use.
#[derive(Parser)]
enum SubCommand {
enum Subcommand {
/// Request to bump a crate/crates.
Bump(Bump),

/// Publishes a crate/crates.
Publish(Publish),
}

/// The arguments to the `bump` subcommand.
#[derive(Parser)]
struct Bump {
/// Whether or not the bump should be a patch version increase.
#[clap(short, long)]
patch: bool,

/// The list of crate names to bump.
#[clap(short, long)]
crates_to_bump: Vec<String>,
}

/// The arguments to the `publish` subcommand.
#[derive(Parser)]
struct Publish {
/// Whether or not to perform a dry-run of the publishing.
#[clap(short, long)]
dry_run: bool,
}

/// The main function.
fn main() {
let mut all_crates: Vec<Rc<RefCell<Crate>>> = Vec::new();
find_crates(".".as_ref(), &mut all_crates);
Expand All @@ -108,9 +135,9 @@ fn main() {
.collect::<HashMap<_, _>>();
all_crates.sort_by_key(|krate| publish_order.get(&krate.borrow().name[..]));

let opts = Opts::parse();
match opts.subcmd {
SubCommand::Bump(Bump {
let opts = Args::parse();
match opts.command {
Subcommand::Bump(Bump {
patch,
crates_to_bump,
}) => {
Expand Down Expand Up @@ -150,7 +177,7 @@ fn main() {
.success()
);
}
SubCommand::Publish(Publish { dry_run }) => {
Subcommand::Publish(Publish { dry_run }) => {
// We have so many crates to publish we're frequently either
// rate-limited or we run into issues where crates can't publish
// successfully because they're waiting on the index entries of
Expand All @@ -177,6 +204,7 @@ fn main() {
}
}

/// Finds crates in a particular directory.
fn find_crates(dir: &Path, dst: &mut Vec<Rc<RefCell<Crate>>>) {
if dir.join("Cargo.toml").exists() {
if let Some(krate) = read_crate(&dir.join("Cargo.toml")) {
Expand All @@ -195,6 +223,7 @@ fn find_crates(dir: &Path, dst: &mut Vec<Rc<RefCell<Crate>>>) {
}
}

/// Reads a crate from a manifest.
fn read_crate(manifest_path: &Path) -> Option<Crate> {
let contents = fs::read_to_string(manifest_path).expect("failed to read manifest");
let mut manifest =
Expand Down Expand Up @@ -223,6 +252,7 @@ fn read_crate(manifest_path: &Path) -> Option<Crate> {
})
}

/// Bumps the version of a crate.
fn bump_version(krate: &Crate, crates: &[Rc<RefCell<Crate>>], patch: bool) {
let mut new_manifest = krate.manifest.clone();

Expand Down Expand Up @@ -289,6 +319,7 @@ fn bump(version: &str, patch_bump: bool) -> String {
}
}

/// Publishes a crate.
fn publish(krate: &Crate, dry_run: bool) -> bool {
if !SORTED_CRATES_TO_PUBLISH.iter().any(|s| *s == krate.name) {
return true;
Expand Down
3 changes: 3 additions & 0 deletions gauntlet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ tracing.workspace = true
tracing-subscriber.workspace = true
anyhow.workspace = true
codespan-reporting.workspace = true

[lints]
workspace = true
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ newline_style = "Unix"
normalize_comments = true
normalize_doc_attributes = true
reorder_impl_items = true
style_edition = "2024"
use_field_init_shorthand = true
wrap_comments = true
style_edition = "2024"
3 changes: 3 additions & 0 deletions wdl-analysis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ tempfile = { workspace = true }
default = []
codespan = ["wdl-ast/codespan"]

[lints]
workspace = true

[[test]]
name = "analysis"
required-features = ["codespan"]
Expand Down
1 change: 0 additions & 1 deletion wdl-analysis/src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use tokio::sync::mpsc;
use tokio::sync::oneshot;
use url::Url;
use walkdir::WalkDir;
use wdl_ast::AstNode;
peterhuene marked this conversation as resolved.
Show resolved Hide resolved
use wdl_ast::Diagnostic;
use wdl_ast::Severity;
use wdl_ast::SyntaxNode;
Expand Down
1 change: 0 additions & 1 deletion wdl-analysis/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use tracing::debug;
use tracing::info;
use url::Url;
use uuid::Uuid;
use wdl_ast::AstNode;
use wdl_ast::Diagnostic;
use wdl_ast::SyntaxNode;
use wdl_ast::Validator;
Expand Down
Loading