Skip to content

Commit bcf92bd

Browse files
committed
feat(toolchain): remote build logs
1 parent fbbfba0 commit bcf92bd

14 files changed

Lines changed: 118 additions & 36 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cloud/packages/ci-manager/src/executors/docker.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export async function runDockerBuild(
3838
`Starting kaniko with args: docker ${kanikoArgs.join(" ")}`,
3939
);
4040

41+
buildStore.updateStatus(buildId, {
42+
type: "running",
43+
data: { docker: {} }
44+
});
45+
4146
return new Promise<void>((resolve, reject) => {
4247
const dockerProcess = spawn("docker", kanikoArgs, {
4348
stdio: ["pipe", "pipe", "pipe"]

cloud/packages/ci-manager/src/executors/rivet.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ export async function runRivetBuild(
7878
const actorId = createResponse.actor.id;
7979
buildStore.addLog(buildId, `Created Rivet actor: ${actorId}`);
8080

81+
buildStore.updateStatus(buildId, {
82+
type: "running",
83+
data: {
84+
rivet: { actorId }
85+
}
86+
});
87+
8188
await pollActorStatus(
8289
buildStore,
8390
client,

cloud/packages/ci-manager/src/kaniko-runner.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ export async function runKanikoBuild(
1717

1818
await mkdir(dirname(build.contextPath!), { recursive: true });
1919

20-
buildStore.updateStatus(buildId, { type: "running", data: {} });
20+
buildStore.updateStatus(buildId, {
21+
type: "running",
22+
data: {
23+
noRunner: {}
24+
}
25+
});
2126

2227
const executionMode = process.env.KANIKO_EXECUTION_MODE || "docker";
2328
buildStore.addLog(buildId, `Using execution mode: ${executionMode}`);

cloud/packages/ci-manager/src/types.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
import { z } from "zod";
22
import { NO_SEP_CHAR_REGEX, UNIT_SEP_CHAR } from "./common";
33

4+
export const RunnerSchema = z.union([
5+
z.object({
6+
rivet: z.object({
7+
actorId: z.string(),
8+
})
9+
}),
10+
z.object({
11+
docker: z.object({})
12+
}),
13+
z.object({
14+
noRunner: z.object({})
15+
})
16+
]);
17+
18+
export type Runner = z.infer<typeof RunnerSchema>;
19+
420
export const StatusSchema = z.discriminatedUnion("type", [
521
z.object({ type: z.literal("starting"), data: z.object({}) }),
6-
z.object({ type: z.literal("running"), data: z.object({}) }),
22+
z.object({ type: z.literal("running"), data: RunnerSchema }),
723
z.object({ type: z.literal("finishing"), data: z.object({}) }),
824
z.object({ type: z.literal("converting"), data: z.object({}) }),
925
z.object({ type: z.literal("uploading"), data: z.object({}) }),

packages/toolchain/cli/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ path = "src/main.rs"
1616
[dependencies]
1717
anyhow = "1.0"
1818
async-posthog.workspace = true
19-
base64 = "0.22.1"
2019
clap = { version = "4.5.9", features = ["derive"] }
2120
ctrlc = "3.4.5"
2221
deno-embed.workspace = true

packages/toolchain/cli/src/commands/actor/create.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub struct Opts {
103103

104104
/// Specify which log stream to display
105105
#[clap(long)]
106-
log_stream: Option<crate::util::actor::logs::LogStream>,
106+
log_stream: Option<toolchain::util::actor::logs::LogStream>,
107107

108108
/// Deploy the build before creating the actor
109109
#[clap(long)]
@@ -299,17 +299,18 @@ impl Opts {
299299

300300
// Tail logs
301301
if self.logs {
302-
crate::util::actor::logs::tail(
302+
toolchain::util::actor::logs::tail(
303303
&ctx,
304-
crate::util::actor::logs::TailOpts {
304+
toolchain::util::actor::logs::TailOpts {
305305
environment: &env,
306306
actor_id: response.actor.id,
307307
stream: self
308308
.log_stream
309309
.clone()
310-
.unwrap_or(crate::util::actor::logs::LogStream::All),
310+
.unwrap_or(toolchain::util::actor::logs::LogStream::All),
311311
follow: true,
312312
timestamps: true,
313+
exit_on_ctrl_c: true,
313314
},
314315
)
315316
.await?;

packages/toolchain/cli/src/commands/actor/logs.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct Opts {
1616

1717
/// Specify which log stream to display (stdout, stderr, or all)
1818
#[clap(long, short = 's')]
19-
stream: Option<crate::util::actor::logs::LogStream>,
19+
stream: Option<toolchain::util::actor::logs::LogStream>,
2020

2121
/// Disable timestamp display in logs
2222
#[clap(long)]
@@ -36,17 +36,18 @@ impl Opts {
3636
let actor_id =
3737
Uuid::parse_str(&self.id).map_err(|_| errors::UserError::new("invalid id uuid"))?;
3838

39-
crate::util::actor::logs::tail(
39+
toolchain::util::actor::logs::tail(
4040
&ctx,
41-
crate::util::actor::logs::TailOpts {
41+
toolchain::util::actor::logs::TailOpts {
4242
environment: &env,
4343
actor_id,
4444
stream: self
4545
.stream
4646
.clone()
47-
.unwrap_or(crate::util::actor::logs::LogStream::All),
47+
.unwrap_or(toolchain::util::actor::logs::LogStream::All),
4848
follow: !self.no_follow,
4949
timestamps: !self.no_timestamps,
50+
exit_on_ctrl_c: true
5051
},
5152
)
5253
.await?;

packages/toolchain/cli/src/util/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pub mod actor;
21
pub mod deploy;
32
pub mod env;
43
pub mod login;

packages/toolchain/toolchain/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ edition.workspace = true
99
[dependencies]
1010
anyhow = "1.0"
1111
async-stream = "0.3.3"
12+
base64 = "0.22.1"
1213
clap = { version = "4.5", features = ["derive"] }
1314
console = "0.15"
1415
const_format = "0.2.32"

0 commit comments

Comments
 (0)