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: race local builds against remotes #439

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
492 changes: 274 additions & 218 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ moka = { version = "0.12", features = ["sync"] }
notify = "8"
num = "0.4"
oauth2 = "5.0.0-rc.1"
octocrab = "0.42"
octocrab = "0.43"
once_cell = "1"
petgraph = "0.7"
pin-project = "1"
Expand All @@ -108,7 +108,7 @@ reqwest = { version = "0.12", default-features = false, features = [
"stream",
"rustls-tls",
] }
rusqlite = { version = "0.32", features = ["blob", "bundled"] }
rusqlite = { version = "0.33", features = ["blob", "bundled"] }
rustls = "0.23"
scopeguard = "1"
serde = { version = "1", features = ["rc", "derive"] }
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ curl -fsSL https://tangram.dev/install.sh | sh
Create a file at the root of your project called `tangram.ts` with the following content:

```ts
export default tg.target(() => tg.file("Hello, World!"));
export default tg.command(() => tg.file("Hello, World!"));
```

Run `tg build`.
Expand All @@ -51,7 +51,7 @@ import * as std from "std";

import source from "./packages/hello";

export default tg.target(() => {
export default tg.command(() => {
return cargo.build({
env: std.env(openssl()),
source,
Expand All @@ -75,7 +75,7 @@ import jq from "jq";
import sqlite from "sqlite";
import * as std from "std";

export default tg.target(() => std.env(jq(), ripgrep()));
export default tg.command(() => std.env(jq(), ripgrep()));
```

Run `tg run -- sh` to build the environment and run a shell in it.
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/artifact/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ pub struct Args {
pub format: tg::artifact::archive::Format,

#[command(flatten)]
pub inner: crate::target::build::InnerArgs,
pub inner: crate::command::run::InnerArgs,
}

impl Cli {
pub async fn command_artifact_archive(&self, args: Args) -> tg::Result<()> {
let handle = self.handle().await?;
let artifact = tg::Artifact::with_id(args.artifact);
let format = args.format;
let target = artifact.archive_target(format);
let target = target.id(&handle).await?;
let args = crate::target::build::Args {
reference: Some(tg::Reference::with_object(&target.into())),
let command = artifact.archive_command(format);
let command = command.id(&handle).await?;
let args = crate::command::build::Args {
reference: Some(tg::Reference::with_object(&command.into())),
inner: args.inner,
};
self.command_target_build(args).await?;
self.command_command_build(args).await?;
Ok(())
}
}
14 changes: 7 additions & 7 deletions packages/cli/src/artifact/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Cli;
use tangram_client as tg;
use tangram_client::{self as tg};

/// Bundle an artifact.
#[derive(Clone, Debug, clap::Args)]
Expand All @@ -9,20 +9,20 @@ pub struct Args {
pub artifact: tg::artifact::Id,

#[command(flatten)]
pub inner: crate::target::build::InnerArgs,
pub inner: crate::command::run::InnerArgs,
}

impl Cli {
pub async fn command_artifact_bundle(&self, args: Args) -> tg::Result<()> {
let handle = self.handle().await?;
let artifact = tg::Artifact::with_id(args.artifact);
let target = artifact.bundle_target();
let target = target.id(&handle).await?;
let args = crate::target::build::Args {
reference: Some(tg::Reference::with_object(&target.into())),
let command = artifact.bundle_command();
let command = command.id(&handle).await?;
let args = crate::command::build::Args {
reference: Some(tg::Reference::with_object(&command.into())),
inner: args.inner,
};
self.command_target_build(args).await?;
self.command_command_build(args).await?;
Ok(())
}
}
12 changes: 6 additions & 6 deletions packages/cli/src/artifact/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ pub struct Args {
pub artifact: tg::artifact::Id,

#[command(flatten)]
pub inner: crate::target::build::InnerArgs,
pub inner: crate::command::run::InnerArgs,
}

impl Cli {
pub async fn command_artifact_checksum(&self, args: Args) -> tg::Result<()> {
let handle = self.handle().await?;
let artifact = tg::Artifact::with_id(args.artifact);
let algorithm = args.algorithm;
let target = artifact.checksum_target(algorithm);
let target = target.id(&handle).await?;
let args = crate::target::build::Args {
reference: Some(tg::Reference::with_object(&target.into())),
let command = artifact.checksum_command(algorithm);
let command = command.id(&handle).await?;
let args = crate::command::build::Args {
reference: Some(tg::Reference::with_object(&command.into())),
inner: args.inner,
};
self.command_target_build(args).await?;
self.command_command_build(args).await?;
Ok(())
}
}
12 changes: 6 additions & 6 deletions packages/cli/src/artifact/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ pub struct Args {
pub format: Option<tg::artifact::archive::Format>,

#[command(flatten)]
pub inner: crate::target::build::InnerArgs,
pub inner: crate::command::run::InnerArgs,
}

impl Cli {
pub async fn command_artifact_extract(&self, args: Args) -> tg::Result<()> {
let handle = self.handle().await?;
let blob = tg::Blob::with_id(args.blob);
let format = args.format;
let target = tg::Artifact::extract_target(&blob, format);
let target = target.id(&handle).await?;
let args = crate::target::build::Args {
reference: Some(tg::Reference::with_object(&target.into())),
let command = tg::Artifact::extract_command(&blob, format);
let command = command.id(&handle).await?;
let args = crate::command::build::Args {
reference: Some(tg::Reference::with_object(&command.into())),
inner: args.inner,
};
self.command_target_build(args).await?;
self.command_command_build(args).await?;
Ok(())
}
}
12 changes: 6 additions & 6 deletions packages/cli/src/blob/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ pub struct Args {
pub blob: tg::blob::Id,

#[command(flatten)]
pub inner: crate::target::build::InnerArgs,
pub inner: crate::command::run::InnerArgs,
}

impl Cli {
pub async fn command_blob_checksum(&self, args: Args) -> tg::Result<()> {
let handle = self.handle().await?;
let blob = tg::Blob::with_id(args.blob);
let algorithm = args.algorithm;
let target = blob.checksum_target(algorithm);
let target = target.id(&handle).await?;
let args = crate::target::build::Args {
reference: Some(tg::Reference::with_object(&target.into())),
let command = blob.checksum_command(algorithm);
let command = command.id(&handle).await?;
let args = crate::command::build::Args {
reference: Some(tg::Reference::with_object(&command.into())),
inner: args.inner,
};
self.command_target_build(args).await?;
self.command_command_build(args).await?;
Ok(())
}
}
12 changes: 6 additions & 6 deletions packages/cli/src/blob/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ pub struct Args {
pub format: tg::blob::compress::Format,

#[command(flatten)]
pub inner: crate::target::build::InnerArgs,
pub inner: crate::command::run::InnerArgs,
}

impl Cli {
pub async fn command_blob_compress(&self, args: Args) -> tg::Result<()> {
let handle = self.handle().await?;
let blob = tg::Blob::with_id(args.blob);
let format = args.format;
let target = blob.compress_target(format);
let target = target.id(&handle).await?;
let args = crate::target::build::Args {
reference: Some(tg::Reference::with_object(&target.into())),
let command = blob.compress_command(format);
let command = command.id(&handle).await?;
let args = crate::command::build::Args {
reference: Some(tg::Reference::with_object(&command.into())),
inner: args.inner,
};
self.command_target_build(args).await?;
self.command_command_build(args).await?;
Ok(())
}
}
12 changes: 6 additions & 6 deletions packages/cli/src/blob/decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ pub struct Args {
pub format: tg::blob::compress::Format,

#[command(flatten)]
pub inner: crate::target::build::InnerArgs,
pub inner: crate::command::run::InnerArgs,
}

impl Cli {
pub async fn command_blob_decompress(&self, args: Args) -> tg::Result<()> {
let handle = self.handle().await?;
let blob = tg::Blob::with_id(args.blob);
let format = args.format;
let target = blob.decompress_target(format);
let target = target.id(&handle).await?;
let args = crate::target::build::Args {
reference: Some(tg::Reference::with_object(&target.into())),
let command = blob.decompress_command(format);
let command = command.id(&handle).await?;
let args = crate::command::build::Args {
reference: Some(tg::Reference::with_object(&command.into())),
inner: args.inner,
};
self.command_target_build(args).await?;
self.command_command_build(args).await?;
Ok(())
}
}
16 changes: 8 additions & 8 deletions packages/cli/src/blob/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Args {
pub checksum: Option<tg::Checksum>,

#[command(flatten)]
pub inner: crate::target::build::InnerArgs,
pub inner: crate::command::run::InnerArgs,

#[arg(index = 1)]
pub url: Url,
Expand All @@ -20,17 +20,17 @@ impl Cli {
pub async fn command_blob_download(&self, args: Args) -> tg::Result<()> {
let handle = self.handle().await?;
let host = "builtin";
let target_args = vec!["download".into(), args.url.to_string().into()];
let target = tg::Target::builder(host)
.args(target_args)
let command_args = vec!["download".into(), args.url.to_string().into()];
let command = tg::Command::builder(host)
.args(command_args)
.checksum(args.checksum)
.build();
let target = target.id(&handle).await?;
let args = crate::target::build::Args {
reference: Some(tg::Reference::with_object(&target.into())),
let command = command.id(&handle).await?;
let args = crate::command::build::Args {
reference: Some(tg::Reference::with_object(&command.into())),
inner: args.inner,
};
self.command_target_build(args).await?;
self.command_command_build(args).await?;
Ok(())
}
}
79 changes: 0 additions & 79 deletions packages/cli/src/build.rs

This file was deleted.

2 changes: 1 addition & 1 deletion packages/cli/src/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct Args {
pub algorithm: tg::checksum::Algorithm,

#[command(flatten)]
pub inner: crate::target::build::InnerArgs,
pub inner: crate::command::run::InnerArgs,

/// The artifact, blob, or URL to checksum.
#[arg(index = 1, default_value = ".")]
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/clean.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::Cli;
use tangram_client::{self as tg, Handle as _};

/// Remove unused builds and objects.
/// Remove unused processes and objects.
#[derive(Clone, Debug, clap::Args)]
#[group(skip)]
pub struct Args {}
Expand Down
Loading