Compare commits

...

6 Commits

Author SHA1 Message Date
95834ce908 feat: set internal warnings as errors 2023-02-25 01:55:24 +01:00
f9e7af931d feat: introduce tests again 2023-02-25 01:47:57 +01:00
ecca036bc6 fix(sdk): fix builder pattern to actually work with default values
In previous versions the builder pattern required all values to be set.
This has not been fixed, so that default values are allowed.
2023-02-25 01:47:57 +01:00
6a9a560cdc Release dagger-core v0.2.7, dagger-sdk v0.2.15 2023-02-25 00:11:35 +01:00
e578b0e371 fix: set deserialize on enums as well 2023-02-25 00:10:46 +01:00
3e8ca8d86e feat: update to dagger-v0.3.13
https://github.com/dagger/dagger/releases/tag/v0.3.13
2023-02-25 00:10:46 +01:00
26 changed files with 689 additions and 160 deletions

4
Cargo.lock generated
View File

@@ -260,7 +260,7 @@ dependencies = [
[[package]] [[package]]
name = "dagger-core" name = "dagger-core"
version = "0.2.6" version = "0.2.7"
dependencies = [ dependencies = [
"clap", "clap",
"dirs", "dirs",
@@ -309,7 +309,7 @@ dependencies = [
[[package]] [[package]]
name = "dagger-sdk" name = "dagger-sdk"
version = "0.2.14" version = "0.2.15"
dependencies = [ dependencies = [
"base64", "base64",
"dagger-core", "dagger-core",

View File

@@ -20,7 +20,7 @@ members = [
[dependencies] [dependencies]
dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.5" } dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.5" }
dagger-core = { path = "crates/dagger-core", version = "^0.2.3" } dagger-core = { path = "crates/dagger-core", version = "^0.2.7" }
clap = "4.1.6" clap = "4.1.6"
dirs = "4.0.0" dirs = "4.0.0"

View File

@@ -8,6 +8,6 @@ edition = "2021"
[dependencies] [dependencies]
clap = "4.1.6" clap = "4.1.6"
color-eyre = "0.6.2" color-eyre = "0.6.2"
dagger-sdk = { path = "../crates/dagger-sdk/", version = "^0.2.14" } dagger-sdk = { path = "../crates/dagger-sdk/", version = "^0.2.15" }
eyre = "0.6.8" eyre = "0.6.8"
tokio = { version = "1.25.0", features = ["full"] } tokio = { version = "1.25.0", features = ["full"] }

View File

@@ -165,8 +165,21 @@ async fn select_base_image(client: Arc<Query>) -> eyre::Result<Container> {
src_dir src_dir
} }
async fn validate_pr(_client: Arc<Query>, container: Container) -> eyre::Result<()> { async fn validate_pr(client: Arc<Query>, container: Container) -> eyre::Result<()> {
//let container = container.with_exec(vec!["cargo", "test", "--all"], None); let exit = container.exit_code().await?;
if exit != 0 {
eyre::bail!("container failed with non-zero exit code");
}
let docker_cli = client
.container()
.from("docker:cli")
.file("/usr/local/bin/docker");
let socket = client.host().unix_socket("/var/run/docker.sock");
let container = container
.with_mounted_file("/usr/bin/docker", docker_cli.id().await?)
.with_unix_socket("/var/run/docker.sock", socket.id().await?)
.with_exec(vec!["cargo", "test", "--all"]);
let exit = container.exit_code().await?; let exit = container.exit_code().await?;
if exit != 0 { if exit != 0 {

View File

@@ -11,7 +11,7 @@ publish = true
[dependencies] [dependencies]
convert_case = "0.6.0" convert_case = "0.6.0"
dagger-core = { path = "../dagger-core", version = "^0.2.6" } dagger-core = { path = "../dagger-core", version = "^0.2.7" }
eyre = "0.6.8" eyre = "0.6.8"
genco = "0.17.3" genco = "0.17.3"

View File

@@ -153,6 +153,7 @@ impl From<&TypeRef> for Scalar {
} }
} }
#[allow(dead_code)]
pub fn get_type_from_name<'t>(types: &'t [FullType], name: &'t str) -> Option<&'t FullType> { pub fn get_type_from_name<'t>(types: &'t [FullType], name: &'t str) -> Option<&'t FullType> {
types types
.into_iter() .into_iter()
@@ -258,6 +259,7 @@ pub fn input_values_has_optionals(input_values: &[&InputValue]) -> bool {
> 0 > 0
} }
#[allow(dead_code)]
pub fn input_values_is_empty(input_values: &[InputValue]) -> bool { pub fn input_values_is_empty(input_values: &[InputValue]) -> bool {
input_values.len() > 0 input_values.len() > 0
} }

View File

@@ -1,3 +1,5 @@
#![deny(warnings)]
mod functions; mod functions;
mod generator; mod generator;
pub mod rust; pub mod rust;

View File

@@ -26,9 +26,10 @@ fn render_enum_values(values: &FullType) -> Option<rust::Tokens> {
pub fn render_enum(t: &FullType) -> eyre::Result<rust::Tokens> { pub fn render_enum(t: &FullType) -> eyre::Result<rust::Tokens> {
let serialize = rust::import("serde", "Serialize"); let serialize = rust::import("serde", "Serialize");
let deserialize = rust::import("serde", "Deserialize");
Ok(quote! { Ok(quote! {
#[derive($serialize, Clone, PartialEq, Debug)] #[derive($serialize, $deserialize, Clone, PartialEq, Debug)]
pub enum $(t.name.as_ref()) { pub enum $(t.name.as_ref()) {
$(render_enum_values(t)) $(render_enum_values(t))
} }

View File

@@ -86,7 +86,7 @@ pub fn render_optional_field_args(
} }
quote! { quote! {
$(a.description.pipe(|d| format_struct_comment(d))) $(a.description.pipe(|d| format_struct_comment(d)))
#[builder(setter(into, strip_option))] #[builder(setter(into, strip_option), default)]
pub $(format_struct_name(&a.name)): Option<$(type_)>, pub $(format_struct_name(&a.name)): Option<$(type_)>,
} }
}); });

View File

@@ -5,8 +5,35 @@ 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.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v0.2.7 (2023-02-24)
### New Features
- <csr-id-3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f/> update to dagger-v0.3.13
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 4 days passed between releases.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- update to dagger-v0.3.13 ([`3e8ca8d`](https://github.com/kjuulh/dagger-rs/commit/3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f))
</details>
## v0.2.6 (2023-02-20) ## v0.2.6 (2023-02-20)
<csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/>
### Chore ### Chore
- <csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/> ran clippy - <csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/> ran clippy
@@ -19,7 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<csr-read-only-do-not-edit/> <csr-read-only-do-not-edit/>
- 2 commits contributed to the release. - 3 commits contributed to the release.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org). - 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages - 0 issues like '(#ID)' were seen in commit messages
@@ -30,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<details><summary>view details</summary> <details><summary>view details</summary>
* **Uncategorized** * **Uncategorized**
- Release dagger-core v0.2.6, dagger-codegen v0.2.7, dagger-sdk v0.2.12 ([`7179f8b`](https://github.com/kjuulh/dagger-rs/commit/7179f8b598ef04e62925e39d3f55740253c01686))
- ran clippy ([`1f77d90`](https://github.com/kjuulh/dagger-rs/commit/1f77d90c0f0ac832a181b2322350ea395612986c)) - ran clippy ([`1f77d90`](https://github.com/kjuulh/dagger-rs/commit/1f77d90c0f0ac832a181b2322350ea395612986c))
- cli session keep session alive ([`8dfecf9`](https://github.com/kjuulh/dagger-rs/commit/8dfecf976c5537cc2c03881de2b2fd2b2508683a)) - cli session keep session alive ([`8dfecf9`](https://github.com/kjuulh/dagger-rs/commit/8dfecf976c5537cc2c03881de2b2fd2b2508683a))
</details> </details>

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "dagger-core" name = "dagger-core"
version = "0.2.6" version = "0.2.7"
edition = "2021" edition = "2021"
readme = "README.md" readme = "README.md"
license-file = "LICENSE.MIT" license-file = "LICENSE.MIT"

View File

@@ -1,9 +1,4 @@
use std::{ use std::{fs::canonicalize, path::PathBuf, process::Stdio, sync::Arc};
fs::canonicalize,
path::PathBuf,
process::Stdio,
sync::Arc,
};
use tokio::io::AsyncBufReadExt; use tokio::io::AsyncBufReadExt;
@@ -105,7 +100,9 @@ impl InnerCliSession {
} }
}); });
let conn = receiver.recv().await.ok_or(eyre::anyhow!("could not receive ok signal from dagger-engine"))?; let conn = receiver.recv().await.ok_or(eyre::anyhow!(
"could not receive ok signal from dagger-engine"
))?;
Ok((conn, proc)) Ok((conn, proc))
} }

View File

@@ -1,6 +1,6 @@
use std::{ use std::{
fs::File, fs::File,
io::{copy, Read, Write}, io::{copy, Write},
os::unix::prelude::PermissionsExt, os::unix::prelude::PermissionsExt,
path::PathBuf, path::PathBuf,
}; };
@@ -27,6 +27,7 @@ impl Platform {
let normalize_arch = match arch.as_str() { let normalize_arch = match arch.as_str() {
"x86_64" => "amd64", "x86_64" => "amd64",
"aarch" => "arm64", "aarch" => "arm64",
"aarch64" => "arm64",
arch => arch, arch => arch,
}; };
@@ -129,7 +130,8 @@ impl Downloader {
if !cli_bin_path.exists() { if !cli_bin_path.exists() {
cli_bin_path = self cli_bin_path = self
.download(cli_bin_path).await .download(cli_bin_path)
.await
.context("failed to download CLI from archive")?; .context("failed to download CLI from archive")?;
} }
@@ -137,6 +139,10 @@ impl Downloader {
if let Ok(entry) = file { if let Ok(entry) = file {
let path = entry.path(); let path = entry.path();
if path != cli_bin_path { if path != cli_bin_path {
println!(
"deleting client: path: {:?} vs cli_bin_path: {:?}",
path, cli_bin_path
);
std::fs::remove_file(path)?; std::fs::remove_file(path)?;
} }
} }
@@ -199,8 +205,6 @@ impl Downloader {
hasher.update(&bytes); hasher.update(&bytes);
let res = hasher.finalize(); let res = hasher.finalize();
println!("{}", hex::encode(&res));
if archive_url.ends_with(".zip") { if archive_url.ends_with(".zip") {
// TODO: Nothing for now // TODO: Nothing for now
todo!() todo!()
@@ -219,8 +223,6 @@ impl Downloader {
let mut entry = entry?; let mut entry = entry?;
let path = entry.path()?; let path = entry.path()?;
println!("path: {:?}", path);
if path.ends_with("dagger") { if path.ends_with("dagger") {
copy(&mut entry, output)?; copy(&mut entry, output)?;
@@ -238,7 +240,11 @@ mod test {
#[tokio::test] #[tokio::test]
async fn download() { async fn download() {
let cli_path = Downloader::new("0.3.10".into()).unwrap().get_cli().await.unwrap(); let cli_path = Downloader::new("0.3.10".into())
.unwrap()
.get_cli()
.await
.unwrap();
assert_eq!( assert_eq!(
Some("dagger-0.3.10"), Some("dagger-0.3.10"),

View File

@@ -1,5 +1,3 @@
use crate::{ use crate::{
cli_session::CliSession, config::Config, connect_params::ConnectParams, downloader::Downloader, cli_session::CliSession, config::Config, connect_params::ConnectParams, downloader::Downloader,
}; };
@@ -12,37 +10,18 @@ impl Engine {
} }
async fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, tokio::process::Child)> { async fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
let cli = Downloader::new("0.3.12".into())?.get_cli().await?; let cli = Downloader::new("0.3.13".into())?.get_cli().await?;
let cli_session = CliSession::new(); let cli_session = CliSession::new();
Ok(cli_session.connect(cfg, &cli).await?) Ok(cli_session.connect(cfg, &cli).await?)
} }
pub async fn start(&self, cfg: &Config) -> eyre::Result<(ConnectParams, tokio::process::Child)> { pub async fn start(
&self,
cfg: &Config,
) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
// TODO: Add from existing session as well // TODO: Add from existing session as well
self.from_cli(cfg).await self.from_cli(cfg).await
} }
} }
#[cfg(test)]
mod tests {
use crate::{config::Config, connect_params::ConnectParams};
use super::Engine;
// TODO: these tests potentially have a race condition
#[tokio::test]
async fn engine_can_start() {
let engine = Engine::new();
let params = engine.start(&Config::new(None, None, None, None)).await.unwrap();
assert_ne!(
params.0,
ConnectParams {
port: 123,
session_token: "123".into()
}
)
}
}

View File

@@ -241,6 +241,7 @@ pub struct SchemaTypes {
pub full_type: FullType, pub full_type: FullType,
} }
#[allow(dead_code)]
#[derive(Clone, Debug, Deserialize)] #[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct SchemaDirectivesArgs { pub struct SchemaDirectivesArgs {
@@ -257,6 +258,7 @@ pub struct SchemaDirectives {
pub args: Option<Vec<Option<SchemaDirectivesArgs>>>, pub args: Option<Vec<Option<SchemaDirectivesArgs>>>,
} }
#[allow(dead_code)]
#[derive(Clone, Debug, Deserialize)] #[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Schema { pub struct Schema {

View File

@@ -1,3 +1,5 @@
#![deny(warnings)]
pub mod cli_session; pub mod cli_session;
pub mod config; pub mod config;
pub mod connect_params; pub mod connect_params;

View File

@@ -12,13 +12,3 @@ pub async fn get_schema() -> eyre::Result<IntrospectionResponse> {
Ok(schema) Ok(schema)
} }
#[cfg(test)]
mod tests {
use super::get_schema;
#[tokio::test]
async fn can_get_schema() {
let _ = get_schema().await.unwrap();
}
}

View File

@@ -6,8 +6,40 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v0.2.15 (2023-02-24)
### New Features
- <csr-id-3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f/> update to dagger-v0.3.13
### Bug Fixes
- <csr-id-e578b0e371e13bc30ada793b7cd6ebe75ba83a07/> set deserialize on enums as well
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 2 days passed between releases.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- set deserialize on enums as well ([`e578b0e`](https://github.com/kjuulh/dagger-rs/commit/e578b0e371e13bc30ada793b7cd6ebe75ba83a07))
- update to dagger-v0.3.13 ([`3e8ca8d`](https://github.com/kjuulh/dagger-rs/commit/3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f))
</details>
## v0.2.14 (2023-02-22) ## v0.2.14 (2023-02-22)
<csr-id-e331ca003546f4ebe00f33b65c3b45c6b0586514/>
### Chore ### Chore
- <csr-id-e331ca003546f4ebe00f33b65c3b45c6b0586514/> fix whitespace - <csr-id-e331ca003546f4ebe00f33b65c3b45c6b0586514/> fix whitespace
@@ -16,7 +48,7 @@ and this project adheres to
<csr-read-only-do-not-edit/> <csr-read-only-do-not-edit/>
- 1 commit contributed to the release. - 2 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org). - 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages - 0 issues like '(#ID)' were seen in commit messages
@@ -27,6 +59,7 @@ and this project adheres to
<details><summary>view details</summary> <details><summary>view details</summary>
* **Uncategorized** * **Uncategorized**
- Release dagger-sdk v0.2.14 ([`88b055c`](https://github.com/kjuulh/dagger-rs/commit/88b055cb47d3d474e2c37d8fa8259df5faad9da5))
- fix whitespace ([`e331ca0`](https://github.com/kjuulh/dagger-rs/commit/e331ca003546f4ebe00f33b65c3b45c6b0586514)) - fix whitespace ([`e331ca0`](https://github.com/kjuulh/dagger-rs/commit/e331ca003546f4ebe00f33b65c3b45c6b0586514))
</details> </details>

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "dagger-sdk" name = "dagger-sdk"
version = "0.2.14" version = "0.2.15"
edition = "2021" edition = "2021"
readme = "README.md" readme = "README.md"
license-file = "LICENSE.MIT" license-file = "LICENSE.MIT"
@@ -11,7 +11,7 @@ publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
dagger-core = { path = "../dagger-core", version = "^0.2.6" } dagger-core = { path = "../dagger-core", version = "^0.2.7" }
base64 = "0.21.0" base64 = "0.21.0"
eyre = "0.6.8" eyre = "0.6.8"

View File

@@ -35,7 +35,8 @@ async fn main() -> eyre::Result<()> {
.container() .container()
.from("nginx") .from("nginx")
.with_directory("/usr/share/nginx/html", build_dir.id().await?) .with_directory("/usr/share/nginx/html", build_dir.id().await?)
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?; .publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))
.await?;
println!("published image to: {}", ref_); println!("published image to: {}", ref_);

View File

@@ -13,7 +13,8 @@ async fn main() -> eyre::Result<()> {
let ref_ = client let ref_ = client
.container() .container()
.build(context_dir.id().await?) .build(context_dir.id().await?)
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?; .publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))
.await?;
println!("published image to: {}", ref_); println!("published image to: {}", ref_);

View File

@@ -6,7 +6,8 @@ async fn main() -> eyre::Result<()> {
.container() .container()
.from("golang:1.19") .from("golang:1.19")
.with_exec(vec!["go", "version"]) .with_exec(vec!["go", "version"])
.stdout().await?; .stdout()
.await?;
println!("Hello from Dagger and {}", version.trim()); println!("Hello from Dagger and {}", version.trim());

View File

@@ -39,7 +39,8 @@ async fn main() -> eyre::Result<()> {
"/usr/share/nginx/html", "/usr/share/nginx/html",
client.host().directory(output).id().await?, client.host().directory(output).id().await?,
) )
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?; .publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))
.await?;
println!("published image to: {}", ref_); println!("published image to: {}", ref_);

View File

@@ -23,7 +23,8 @@ async fn main() -> eyre::Result<()> {
let out = runner let out = runner
.with_exec(vec!["npm", "test", "--", "--watchAll=false"]) .with_exec(vec!["npm", "test", "--", "--watchAll=false"])
.stderr().await?; .stderr()
.await?;
println!("{}", out); println!("{}", out);

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,5 @@
#![deny(warnings)]
mod client; mod client;
mod gen; mod gen;
mod querybuilder; mod querybuilder;