Compare commits

...

20 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
88b055cb47 Release dagger-sdk v0.2.14 2023-02-22 23:09:36 +01:00
e331ca0035 chore(sdk): fix whitespace 2023-02-22 23:09:20 +01:00
456f48389b Release dagger-codegen v0.2.8, dagger-sdk v0.2.13 2023-02-22 22:38:42 +01:00
7c3654d276 chore(sdk): ran clippy 2023-02-22 22:38:33 +01:00
266ad32dff feat(sdk): with clone 2023-02-22 22:38:15 +01:00
7179f8b598 Release dagger-core v0.2.6, dagger-codegen v0.2.7, dagger-sdk v0.2.12 2023-02-20 12:07:33 +01:00
1f77d90c0f chore(sdk): ran clippy 2023-02-20 11:54:44 +01:00
8dfecf976c fix(core): cli session keep session alive 2023-02-20 11:54:22 +01:00
085a998bc6 fix(ci): set path to local dagger sdk 2023-02-20 11:45:59 +01:00
1725c5188e Release dagger-core v0.2.5, dagger-sdk v0.2.12, dagger-codegen v0.2.7 2023-02-20 11:42:14 +01:00
a13a2a9ecb fix(all): race condition in process 2023-02-20 11:42:03 +01:00
b86710d71e revert disable caching 2023-02-20 11:28:24 +01:00
08a2e30967 disable cache 2023-02-20 10:56:56 +01:00
b552dc5d75 chore(ci): with dagger v0.2.11 2023-02-20 10:50:48 +01:00
27 changed files with 1278 additions and 924 deletions

56
Cargo.lock generated
View File

@@ -114,7 +114,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"clap", "clap",
"color-eyre", "color-eyre",
"dagger-sdk 0.2.10", "dagger-sdk",
"eyre", "eyre",
"tokio", "tokio",
] ]
@@ -246,10 +246,10 @@ dependencies = [
[[package]] [[package]]
name = "dagger-codegen" name = "dagger-codegen"
version = "0.2.6" version = "0.2.8"
dependencies = [ dependencies = [
"convert_case", "convert_case",
"dagger-core 0.2.4", "dagger-core",
"eyre", "eyre",
"genco", "genco",
"itertools", "itertools",
@@ -260,32 +260,7 @@ dependencies = [
[[package]] [[package]]
name = "dagger-core" name = "dagger-core"
version = "0.2.3" version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e18641c2b159006cab7d750c05d3272f0cabfe9532df20b47076353aa73bf1e"
dependencies = [
"clap",
"dirs",
"eyre",
"flate2",
"genco",
"graphql-introspection-query",
"graphql_client",
"hex",
"hex-literal",
"platform-info",
"reqwest",
"serde",
"serde_json",
"sha2",
"tar",
"tempfile",
"tokio",
]
[[package]]
name = "dagger-core"
version = "0.2.4"
dependencies = [ dependencies = [
"clap", "clap",
"dirs", "dirs",
@@ -313,7 +288,7 @@ dependencies = [
"clap", "clap",
"color-eyre", "color-eyre",
"dagger-codegen", "dagger-codegen",
"dagger-core 0.2.4", "dagger-core",
"dirs", "dirs",
"eyre", "eyre",
"flate2", "flate2",
@@ -334,27 +309,10 @@ dependencies = [
[[package]] [[package]]
name = "dagger-sdk" name = "dagger-sdk"
version = "0.2.10" version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af3b3404f52ddf367998475bc48e5a08699950ee7ba54ba334b7ffe1681df0c5"
dependencies = [ dependencies = [
"base64", "base64",
"dagger-core 0.2.3", "dagger-core",
"derive_builder",
"eyre",
"futures",
"gql_client",
"serde",
"serde_json",
"tokio",
]
[[package]]
name = "dagger-sdk"
version = "0.2.11"
dependencies = [
"base64",
"dagger-core 0.2.4",
"derive_builder", "derive_builder",
"eyre", "eyre",
"futures", "futures",

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 = "0.2.10" 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

@@ -5,6 +5,57 @@ 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.8 (2023-02-22)
### New Features
- <csr-id-266ad32dff4c8957c7cdd291f9ef6f8a8c1d055c/> with clone
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 2 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**
- with clone ([`266ad32`](https://github.com/kjuulh/dagger-rs/commit/266ad32dff4c8957c7cdd291f9ef6f8a8c1d055c))
</details>
## v0.2.7 (2023-02-20)
### Bug Fixes
- <csr-id-a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de/> race condition in process
### Commit Statistics
<csr-read-only-do-not-edit/>
- 3 commits contributed to the release.
- 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**
- 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))
- Release dagger-core v0.2.5, dagger-sdk v0.2.12, dagger-codegen v0.2.7 ([`1725c51`](https://github.com/kjuulh/dagger-rs/commit/1725c5188e8a81069ec4a4de569484c921a94927))
- race condition in process ([`a13a2a9`](https://github.com/kjuulh/dagger-rs/commit/a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de))
</details>
## v0.2.6 (2023-02-20) ## v0.2.6 (2023-02-20)
<csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/> <csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/>
@@ -17,7 +68,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.
- 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
@@ -28,6 +79,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.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`f869e57`](https://github.com/kjuulh/dagger-rs/commit/f869e574dd788cd60e5b1b5d502bec68e300694c))
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab)) - Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab))
- ran clippy ([`803cfc4`](https://github.com/kjuulh/dagger-rs/commit/803cfc4f8c4d72ab7d011be5523b3bfc6039de39)) - ran clippy ([`803cfc4`](https://github.com/kjuulh/dagger-rs/commit/803cfc4f8c4d72ab7d011be5523b3bfc6039de39))
</details> </details>

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "dagger-codegen" name = "dagger-codegen"
version = "0.2.6" version = "0.2.8"
edition = "2021" edition = "2021"
readme = "README.md" readme = "README.md"
license-file = "LICENSE.MIT" license-file = "LICENSE.MIT"
@@ -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.4" } 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

@@ -1,9 +1,8 @@
use dagger_core::introspection::{FullType, FullTypeFields, FullTypeFieldsArgs}; use dagger_core::introspection::{FullType, FullTypeFields, FullTypeFieldsArgs};
use genco::prelude::rust; use genco::prelude::rust;
use genco::quote; use genco::quote;
use itertools::Itertools;
use crate::functions::{CommonFunctions}; use crate::functions::CommonFunctions;
use crate::rust::functions::{ use crate::rust::functions::{
field_options_struct_name, format_function, format_name, format_optional_args, field_options_struct_name, format_function, format_name, format_optional_args,
format_struct_comment, format_struct_name, format_struct_comment, format_struct_name,
@@ -12,11 +11,12 @@ use crate::utility::OptionExt;
pub fn render_object(funcs: &CommonFunctions, t: &FullType) -> eyre::Result<rust::Tokens> { pub fn render_object(funcs: &CommonFunctions, t: &FullType) -> eyre::Result<rust::Tokens> {
let selection = rust::import("crate::querybuilder", "Selection"); let selection = rust::import("crate::querybuilder", "Selection");
let child = rust::import("std::process", "Child"); let child = rust::import("tokio::process", "Child");
let conn = rust::import("dagger_core::connect_params", "ConnectParams"); let conn = rust::import("dagger_core::connect_params", "ConnectParams");
let arc = rust::import("std::sync", "Arc"); let arc = rust::import("std::sync", "Arc");
Ok(quote! { Ok(quote! {
#[derive(Debug, Clone)]
pub struct $(t.name.pipe(|s| format_name(s))) { pub struct $(t.name.pipe(|s| format_name(s))) {
pub proc: $arc<$child>, pub proc: $arc<$child>,
pub selection: $selection, pub selection: $selection,
@@ -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,12 +5,42 @@ 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.4 (2023-02-20) ## 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)
<csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/>
### Chore
- <csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/> ran clippy
### Bug Fixes ### Bug Fixes
- <csr-id-8385aa8a15ff7b45fecc3462c482b998118c14eb/> remove blocking - <csr-id-8dfecf976c5537cc2c03881de2b2fd2b2508683a/> cli session keep session alive
- <csr-id-921e61b5e248013cb5fbf4f1bad3eef5a2673145/> remove blocking
### Commit Statistics ### Commit Statistics
@@ -27,6 +57,59 @@ 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))
- cli session keep session alive ([`8dfecf9`](https://github.com/kjuulh/dagger-rs/commit/8dfecf976c5537cc2c03881de2b2fd2b2508683a))
</details>
## v0.2.5 (2023-02-20)
### Bug Fixes
- <csr-id-a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de/> race condition in process
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 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**
- Release dagger-core v0.2.5, dagger-sdk v0.2.12, dagger-codegen v0.2.7 ([`1725c51`](https://github.com/kjuulh/dagger-rs/commit/1725c5188e8a81069ec4a4de569484c921a94927))
- race condition in process ([`a13a2a9`](https://github.com/kjuulh/dagger-rs/commit/a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de))
</details>
## v0.2.4 (2023-02-20)
### Bug Fixes
- <csr-id-8385aa8a15ff7b45fecc3462c482b998118c14eb/> remove blocking
- <csr-id-921e61b5e248013cb5fbf4f1bad3eef5a2673145/> remove blocking
### Commit Statistics
<csr-read-only-do-not-edit/>
- 4 commits contributed to the release.
- 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**
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`f869e57`](https://github.com/kjuulh/dagger-rs/commit/f869e574dd788cd60e5b1b5d502bec68e300694c))
- remove blocking ([`921e61b`](https://github.com/kjuulh/dagger-rs/commit/921e61b5e248013cb5fbf4f1bad3eef5a2673145)) - remove blocking ([`921e61b`](https://github.com/kjuulh/dagger-rs/commit/921e61b5e248013cb5fbf4f1bad3eef5a2673145))
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab)) - Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab))
- remove blocking ([`8385aa8`](https://github.com/kjuulh/dagger-rs/commit/8385aa8a15ff7b45fecc3462c482b998118c14eb)) - remove blocking ([`8385aa8`](https://github.com/kjuulh/dagger-rs/commit/8385aa8a15ff7b45fecc3462c482b998118c14eb))

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "dagger-core" name = "dagger-core"
version = "0.2.4" 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,10 +1,6 @@
use std::{ use std::{fs::canonicalize, path::PathBuf, process::Stdio, sync::Arc};
fs::canonicalize,
io::{BufRead, BufReader}, use tokio::io::AsyncBufReadExt;
path::PathBuf,
process::{Child, Stdio},
sync::Arc,
};
use crate::{config::Config, connect_params::ConnectParams}; use crate::{config::Config, connect_params::ConnectParams};
@@ -24,7 +20,7 @@ impl CliSession {
&self, &self,
config: &Config, config: &Config,
cli_path: &PathBuf, cli_path: &PathBuf,
) -> eyre::Result<(ConnectParams, Child)> { ) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
self.inner.connect(config, cli_path).await self.inner.connect(config, cli_path).await
} }
} }
@@ -37,13 +33,13 @@ impl InnerCliSession {
&self, &self,
config: &Config, config: &Config,
cli_path: &PathBuf, cli_path: &PathBuf,
) -> eyre::Result<(ConnectParams, Child)> { ) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
let proc = self.start(config, cli_path)?; let proc = self.start(config, cli_path)?;
let params = self.get_conn(proc).await?; let params = self.get_conn(proc).await?;
Ok(params) Ok(params)
} }
fn start(&self, config: &Config, cli_path: &PathBuf) -> eyre::Result<std::process::Child> { fn start(&self, config: &Config, cli_path: &PathBuf) -> eyre::Result<tokio::process::Child> {
let mut args: Vec<String> = vec!["session".into()]; let mut args: Vec<String> = vec!["session".into()];
if let Some(workspace) = &config.workdir_path { if let Some(workspace) = &config.workdir_path {
let abs_path = canonicalize(workspace)?; let abs_path = canonicalize(workspace)?;
@@ -54,7 +50,7 @@ impl InnerCliSession {
args.extend(["--project".into(), abs_path.to_string_lossy().to_string()]) args.extend(["--project".into(), abs_path.to_string_lossy().to_string()])
} }
let proc = std::process::Command::new( let proc = tokio::process::Command::new(
cli_path cli_path
.to_str() .to_str()
.ok_or(eyre::anyhow!("could not get string from path"))?, .ok_or(eyre::anyhow!("could not get string from path"))?,
@@ -72,8 +68,8 @@ impl InnerCliSession {
async fn get_conn( async fn get_conn(
&self, &self,
mut proc: std::process::Child, mut proc: tokio::process::Child,
) -> eyre::Result<(ConnectParams, std::process::Child)> { ) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
let stdout = proc let stdout = proc
.stdout .stdout
.take() .take()
@@ -87,29 +83,26 @@ impl InnerCliSession {
let (sender, mut receiver) = tokio::sync::mpsc::channel(1); let (sender, mut receiver) = tokio::sync::mpsc::channel(1);
tokio::spawn(async move { tokio::spawn(async move {
let stdout_bufr = BufReader::new(stdout); let mut stdout_bufr = tokio::io::BufReader::new(stdout).lines();
for line in stdout_bufr.lines() { while let Ok(Some(line)) = stdout_bufr.next_line().await {
let out = line.as_ref().unwrap(); if let Ok(conn) = serde_json::from_str::<ConnectParams>(&line) {
if let Ok(conn) = serde_json::from_str::<ConnectParams>(&out) {
sender.send(conn).await.unwrap(); sender.send(conn).await.unwrap();
} }
if let Ok(line) = line {
println!("dagger: {}", line); println!("dagger: {}", line);
} }
}
}); });
tokio::spawn(async move { tokio::spawn(async move {
let stderr_bufr = BufReader::new(stderr); let mut stdout_bufr = tokio::io::BufReader::new(stderr).lines();
for line in stderr_bufr.lines() { while let Ok(Some(line)) = stdout_bufr.next_line().await {
if let Ok(line) = line {
println!("dagger: {}", line); println!("dagger: {}", line);
} }
//panic!("could not start dagger session: {}", out)
}
}); });
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 std::process::Child;
use crate::{ use crate::{
cli_session::CliSession, config::Config, connect_params::ConnectParams, downloader::Downloader, cli_session::CliSession, config::Config, connect_params::ConnectParams, downloader::Downloader,
}; };
@@ -11,38 +9,19 @@ impl Engine {
Self {} Self {}
} }
async fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, 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, 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,13 +6,43 @@ 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.11 (2023-02-20) ## v0.2.15 (2023-02-24)
<csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/> ### 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)
<csr-id-e331ca003546f4ebe00f33b65c3b45c6b0586514/>
### Chore ### Chore
- <csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/> ran clippy - <csr-id-e331ca003546f4ebe00f33b65c3b45c6b0586514/> fix whitespace
### Commit Statistics ### Commit Statistics
@@ -29,6 +59,89 @@ 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))
</details>
## v0.2.13 (2023-02-22)
<csr-id-7c3654d276bb5f66e692a210cb60cdf46b19e226/>
<csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/>
### Chore
- <csr-id-7c3654d276bb5f66e692a210cb60cdf46b19e226/> ran clippy
- <csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/> ran clippy
### New Features
- <csr-id-266ad32dff4c8957c7cdd291f9ef6f8a8c1d055c/> with clone
### Bug Fixes
- <csr-id-a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de/> race condition in process
### Commit Statistics
<csr-read-only-do-not-edit/>
- 7 commits contributed to the release over the course of 2 calendar days.
- 2 days passed between releases.
- 4 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**
- Release dagger-codegen v0.2.8, dagger-sdk v0.2.13 ([`456f483`](https://github.com/kjuulh/dagger-rs/commit/456f48389b5514d7f743a600a7732fb02dd87418))
- ran clippy ([`7c3654d`](https://github.com/kjuulh/dagger-rs/commit/7c3654d276bb5f66e692a210cb60cdf46b19e226))
- with clone ([`266ad32`](https://github.com/kjuulh/dagger-rs/commit/266ad32dff4c8957c7cdd291f9ef6f8a8c1d055c))
- 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))
- Release dagger-core v0.2.5, dagger-sdk v0.2.12, dagger-codegen v0.2.7 ([`1725c51`](https://github.com/kjuulh/dagger-rs/commit/1725c5188e8a81069ec4a4de569484c921a94927))
- race condition in process ([`a13a2a9`](https://github.com/kjuulh/dagger-rs/commit/a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de))
</details>
## v0.2.12 (2023-02-20)
<csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/>
### Chore
- <csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/> ran clippy
### Bug Fixes
- <csr-id-a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de/> race condition in process
## v0.2.11 (2023-02-20)
<csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/>
### Chore
- <csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/> ran clippy
### Commit Statistics
<csr-read-only-do-not-edit/>
- 3 commits contributed to the release.
- 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**
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`f869e57`](https://github.com/kjuulh/dagger-rs/commit/f869e574dd788cd60e5b1b5d502bec68e300694c))
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab)) - Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab))
- ran clippy ([`803cfc4`](https://github.com/kjuulh/dagger-rs/commit/803cfc4f8c4d72ab7d011be5523b3bfc6039de39)) - ran clippy ([`803cfc4`](https://github.com/kjuulh/dagger-rs/commit/803cfc4f8c4d72ab7d011be5523b3bfc6039de39))
</details> </details>

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "dagger-sdk" name = "dagger-sdk"
version = "0.2.11" 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.4" } 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;