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

chore(actors-sdk-embed): auto-build & install manager dependencies #1964

Closed
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
41 changes: 39 additions & 2 deletions packages/toolchain/actors-sdk-embed/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,24 @@ use std::{

#[tokio::main]
async fn main() -> Result<()> {
// Check if yarn is installed
let yarn_check = tokio::process::Command::new("yarn")
.arg("--version")
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.await;
ensure!(
yarn_check.is_ok() && yarn_check.unwrap().success(),
"yarn is not installed, please install yarn to build this project"
Comment on lines +19 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: unwrap() after is_ok() check is redundant and could be simplified to yarn_check?.success()

Suggested change
ensure!(
yarn_check.is_ok() && yarn_check.unwrap().success(),
"yarn is not installed, please install yarn to build this project"
ensure!(
yarn_check?.success(),
"yarn is not installed, please install yarn to build this project"

);

let manifest_dir = std::env::var("CARGO_MANIFEST_DIR")?;
let out_dir = std::env::var("OUT_DIR")?;

let sdk_path = PathBuf::from(manifest_dir.clone()).join("../../../sdks/actor");
let project_root = PathBuf::from(manifest_dir.clone()).join("../../..");
let sdk_path = project_root.join("sdks/actor");
let manager_path = sdk_path.join("manager");

// Copy SDK directory to out_dir
let dist_path = Path::new(&out_dir).join("actor-sdk");
Expand All @@ -22,7 +36,26 @@ async fn main() -> Result<()> {
fs::remove_dir_all(&dist_path).context("fs::remove_dir_all")?;
}

// Build manager
// Build manager dependencies (required for building the manager itself)
let status = tokio::process::Command::new("yarn")
.arg("install")
.arg("--immutable")
.current_dir(&manager_path)
.status()
.await?;
ensure!(status.success(), "yarn install failed");

let status = tokio::process::Command::new("yarn")
.arg("run")
.arg("build")
.arg("--filter=@rivet-gg/actor-manager")
.current_dir(&project_root)
.status()
.await?;
ensure!(status.success(), "yarn build failed");

// Build manager using Rivet build script (not using tsup/turbo because this includes custom
// polyfill functionality)
build_backend_command_raw(CommandOpts {
task_path: "src/tasks/build/mod.ts",
input: json!({
Expand All @@ -38,7 +71,9 @@ async fn main() -> Result<()> {
})
.await?;

// Rebuild if SDK changes (in order to include manager dependencies)
println!("cargo:rerun-if-changed={}", sdk_path.display());

println!(
"cargo:rustc-env=ACTOR_SDK_DIST_PATH={}",
dist_path.display()
Expand Down Expand Up @@ -83,6 +118,8 @@ pub async fn build_backend_command_raw(opts: CommandOpts) -> Result<()> {
// Serialize command
let input_json = serde_json::to_string(&opts.input)?;

// Yarn install
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: empty 'Yarn install' comment should be removed since it's not followed by any code


// Run backend
let status = tokio::process::Command::new(deno.executable_path)
.args([
Expand Down
1 change: 0 additions & 1 deletion packages/toolchain/js-utils-embed/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use merkle_hash::MerkleTree;
use std::{
fs,
path::{Path, PathBuf},
process::Stdio,
};

#[tokio::main]
Expand Down
1 change: 0 additions & 1 deletion packages/toolchain/toolchain/src/tasks/deploy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use anyhow::*;
use rivet_api::{apis, models};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::Path;
use uuid::Uuid;

use crate::{
Expand Down
Loading