Skip to content

Commit

Permalink
return directory or file
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Nov 22, 2023
1 parent a8aaebe commit d714f52
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/zenith.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ jobs:
dagger query --doc test.gql
dagger query --doc llvm_cov.gql
dagger query --doc build.gql
dagger query --doc clippy.gql
working-directory: example
22 changes: 14 additions & 8 deletions example/.fluentci/src/dagger/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const getDirectory = (
};

export const clippy = async (src: string | Directory | undefined = ".") => {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
const ctr = client
Expand All @@ -48,15 +49,16 @@ export const clippy = async (src: string | Directory | undefined = ".") => {
])
.withExec(["ls", "-la", "/app"]);

await ctr
.file("/app/rust-clippy-results.sarif")
.export("./rust-clippy-results.sarif");
const results = await ctr.file("/app/rust-clippy-results.sarif");
results.export("./rust-clippy-results.sarif");
await ctr.stdout();
id = await results.id();
});
return "Done";
return id;
};

export const llvmCov = async (src: string | Directory | undefined = ".") => {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
const ctr = client
Expand Down Expand Up @@ -100,10 +102,12 @@ export const llvmCov = async (src: string | Directory | undefined = ".") => {
])
.withExec(["ls", "-la", "/app"]);

await ctr.file("/app/lcov.info").export("./lcov.info");
const lcov = ctr.file("/app/lcov.info");
await lcov.export("./lcov.info");
await ctr.stdout();
id = await lcov.id();
});
return "Done";
return id;
};

export const test = async (
Expand All @@ -126,7 +130,7 @@ export const test = async (

console.log(result);
});
return "done";
return "Done";
};

export const build = async (
Expand All @@ -135,6 +139,7 @@ export const build = async (
target = "x86_64-unknown-linux-gnu",
options: string[] = []
) => {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
const ctr = client
Expand Down Expand Up @@ -163,8 +168,9 @@ export const build = async (
const result = await ctr.stdout();

console.log(result);
id = await ctr.directory("/app/target").id();
});
return "done";
return id;
};

export type JobExec = (src?: string) =>
Expand Down
3 changes: 3 additions & 0 deletions example/.fluentci/src/dagger/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ schema.description = JSON.stringify({
"test.src": "directory",
"build.src": "directory",
"llvmCov.src": "directory",
clippy: "file",
llvmCov: "file",
build: "directory",
});

export { schema };
4 changes: 3 additions & 1 deletion example/build.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
rust {
build
build {
id
}
}
}
7 changes: 7 additions & 0 deletions example/clippy.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
rust {
clippy {
id
}
}
}
4 changes: 3 additions & 1 deletion example/llvm_cov.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
rust {
llvmCov
llvmCov {
id
}
}
}
22 changes: 14 additions & 8 deletions src/dagger/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const getDirectory = (
};

export const clippy = async (src: string | Directory | undefined = ".") => {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
const ctr = client
Expand All @@ -48,15 +49,16 @@ export const clippy = async (src: string | Directory | undefined = ".") => {
])
.withExec(["ls", "-la", "/app"]);

await ctr
.file("/app/rust-clippy-results.sarif")
.export("./rust-clippy-results.sarif");
const results = await ctr.file("/app/rust-clippy-results.sarif");
results.export("./rust-clippy-results.sarif");
await ctr.stdout();
id = await results.id();
});
return "Done";
return id;
};

export const llvmCov = async (src: string | Directory | undefined = ".") => {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
const ctr = client
Expand Down Expand Up @@ -100,10 +102,12 @@ export const llvmCov = async (src: string | Directory | undefined = ".") => {
])
.withExec(["ls", "-la", "/app"]);

await ctr.file("/app/lcov.info").export("./lcov.info");
const lcov = ctr.file("/app/lcov.info");
await lcov.export("./lcov.info");
await ctr.stdout();
id = await lcov.id();
});
return "Done";
return id;
};

export const test = async (
Expand All @@ -126,7 +130,7 @@ export const test = async (

console.log(result);
});
return "done";
return "Done";
};

export const build = async (
Expand All @@ -135,6 +139,7 @@ export const build = async (
target = "x86_64-unknown-linux-gnu",
options: string[] = []
) => {
let id = "";
await connect(async (client: Client) => {
const context = getDirectory(client, src);
const ctr = client
Expand Down Expand Up @@ -163,8 +168,9 @@ export const build = async (
const result = await ctr.stdout();

console.log(result);
id = await ctr.directory("/app/target").id();
});
return "done";
return id;
};

export type JobExec = (src?: string) =>
Expand Down
3 changes: 3 additions & 0 deletions src/dagger/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ schema.description = JSON.stringify({
"test.src": "directory",
"build.src": "directory",
"llvmCov.src": "directory",
clippy: "file",
llvmCov: "file",
build: "directory",
});

export { schema };

0 comments on commit d714f52

Please sign in to comment.