Skip to content

Commit

Permalink
fix: Install proto with Rust instead of our scripts. (#1235)
Browse files Browse the repository at this point in the history
* Pull in new installer.

* Remove logging.

* Update changelog.

* Update docs.

* Bump version.

* Fix changelog.
  • Loading branch information
milesj authored Dec 18, 2023
1 parent 2d8d3ed commit 9724e7d
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
if: ${{ runner.os == 'Linux' }}
with:
auto-install: true
proto-version: '0.25.2' # Keep in sync
proto-version: '0.25.3' # Keep in sync
- uses: mozilla-actions/[email protected]
- name: Checking coverage status
id: coverage
Expand Down
9 changes: 9 additions & 0 deletions .yarn/versions/e8273a99.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
releases:
"@moonrepo/cli": patch
"@moonrepo/core-linux-arm64-gnu": patch
"@moonrepo/core-linux-arm64-musl": patch
"@moonrepo/core-linux-x64-gnu": patch
"@moonrepo/core-linux-x64-musl": patch
"@moonrepo/core-macos-arm64": patch
"@moonrepo/core-macos-x64": patch
"@moonrepo/core-windows-x64-msvc": patch
52 changes: 34 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/core/action-pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ console = { workspace = true }
miette = { workspace = true }
num_cpus = "1.16.0"
proto_core = { workspace = true }
proto_installer = "0.1.0"
rustc-hash = { workspace = true }
serde = { workspace = true }
starbase_styles = { workspace = true }
Expand Down
47 changes: 13 additions & 34 deletions crates/core/action-pipeline/src/actions/sync_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ use moon_action_context::ActionContext;
use moon_actions::{sync_codeowners, sync_vcs_hooks};
use moon_common::consts::PROTO_CLI_VERSION;
use moon_logger::debug;
use moon_process::Command;
use moon_project_graph::ProjectGraph;
use moon_terminal::{print_checkpoint, Checkpoint};
use moon_utils::is_test_env;
use moon_workspace::Workspace;
use proto_core::{download_from_url_to_file, is_offline, ProtoError};
use proto_core::{is_offline, ProtoError};
use proto_installer::{determine_triple, download_release, unpack_release};
use starbase_styles::color;
use starbase_utils::fs;
use std::env;
use std::sync::Arc;
use tokio::sync::RwLock;
Expand Down Expand Up @@ -95,41 +94,21 @@ async fn install_proto(workspace: &Workspace) -> miette::Result<()> {
return Err(ProtoError::InternetConnectionRequired.into());
}

let script_name = if cfg!(windows) {
"proto.ps1"
} else {
"proto.sh"
};
let script_path = workspace.proto_env.temp_dir.join(script_name);
let script_url = format!("https://moonrepo.dev/install/{script_name}");

// Download the install script
debug!("Downloading from {}", script_url);

download_from_url_to_file(
&script_url,
&script_path,
workspace.proto_env.get_plugin_loader()?.get_client()?,
)
.await?;
let target_triple = determine_triple()?;

fs::update_perms(&script_path, None)?;
debug!("Downloading proto archive ({})", target_triple);

// Install using the official script
debug!("Executing install script {}", script_path.display());
let result = download_release(
&target_triple,
PROTO_CLI_VERSION,
&workspace.proto_env.temp_dir,
|_, _| {},
)
.await?;

let mut cmd = Command::new(script_path);
let mut cmd = cmd
.arg(PROTO_CLI_VERSION)
.env("PROTO_INSTALL_DIR", &install_dir)
.env("PROTO_DEBUG", "true")
.create_async();
debug!("Unpacking archive and installing proto");

if env::var("MOON_DEBUG_PROTO_INSTALL").is_ok() {
cmd.exec_stream_output().await?;
} else {
cmd.exec_capture_output().await?;
}
unpack_release(result, &install_dir, &workspace.proto_env.tools_dir)?;

debug!("Successfully installed proto!");

Expand Down
2 changes: 1 addition & 1 deletion nextgen/common/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ pub const CONFIG_PROJECT_FILENAME: &str = "moon.yml";

pub const CONFIG_TEMPLATE_FILENAME: &str = "template.yml";

pub const PROTO_CLI_VERSION: &str = "0.25.2";
pub const PROTO_CLI_VERSION: &str = "0.25.3";
12 changes: 12 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
- More accurately monitors signals (ctrl+c) and shutdowns.
- Tasks can now be configured with a timeout.

## Unreleased

#### 🚀 Updates

- Updated the proto installation step to download, unpack, and install using Rust, instead of
relying on our Bash/PowerShell scripts. This should remove the requirement that openssl, tar, and
other environment tools must exist.

#### ⚙️ Internal

- Updated proto to v0.25.3.

## 1.18.3

#### 🐞 Fixes
Expand Down
4 changes: 4 additions & 0 deletions website/docs/proto/commands/list-remote.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ $ proto list-remote node
### Arguments

- `<tool>` - Type of tool.

### Options

- `--aliases` - Include aliases in the list.
4 changes: 4 additions & 0 deletions website/docs/proto/commands/list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ $ proto list node
### Arguments

- `<tool>` - Type of tool.

### Options

- `--aliases` - Include aliases in the list.
3 changes: 3 additions & 0 deletions website/docs/proto/commands/outdated.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ node - current version 20.7.0 (via 20.7.0), latest version 20.8.0, update availa
### Options

- `--json` - Print the list in JSON format.
- `--include-global` - Include versions from the global `~/.proto/.prototools` file.
- `--latest` - Check for the latest available version, ignoring any version requirements, ranges, or
constraints.
- `--only-local` - Only check versions from the local `.prototools` file, instead of aggregating
parents.
- `--update` - Update the local `.prototools` file with newer versions if available.

0 comments on commit 9724e7d

Please sign in to comment.