Skip to content

Commit

Permalink
new: Enable Pkl without an experiment. (#1804)
Browse files Browse the repository at this point in the history
* Remove restrictions.

* Fix tests.

* Add pkl docs.

* Update labels.
  • Loading branch information
milesj committed Feb 2, 2025
1 parent f84e66b commit 7146dbf
Show file tree
Hide file tree
Showing 33 changed files with 294 additions and 154 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#### 🚀 Updates

- Updated Pkl (`.pkl`) based configuration to always be enabled, and is no longer hidden behind an
experimental flag.
- Added official documentation: https://moonrepo.dev/docs/guides/pkl-config
- Updated our unstable remote service (Bazel RE API) with new functionality:
- You can now use `http(s)` protocols for gRPC servers, instead of just `grpc(s)`.
- Added an `unstable_remote.api` setting, which can be used to inform the server's API format.
Expand Down
13 changes: 6 additions & 7 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ clap = { version = "4.5.27", default-features = false, features = [
"std",
"error-context",
] }
clap_complete = "4.5.42"
clap_complete = "4.5.43"
compact_str = { version = "0.8.1", default-features = false, features = [
"serde",
] }
Expand Down Expand Up @@ -55,13 +55,13 @@ reqwest = { version = "0.12.12", default-features = false, features = [
] }
rustc-hash = "2.1.0"
scc = "2.2.5"
schematic = { version = "0.17.10", default-features = false, features = [
schematic = { version = "0.17.11", default-features = false, features = [
"schema",
] }
serial_test = "3.2.0"
semver = "1.0.25"
serde = { version = "1.0.215", features = ["derive"] }
serde_json = "1.0.137"
serde_json = "1.0.138"
serde_yml = "0.0.12"
sha2 = "0.10.8"
starbase = { version = "0.9.9" }
Expand Down
1 change: 0 additions & 1 deletion crates/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ starbase_events = { workspace = true }
starbase_shell = { workspace = true }
starbase_styles = { workspace = true }
starbase_utils = { workspace = true, features = ["editor-config"] }
system_env = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
Expand Down
13 changes: 0 additions & 13 deletions crates/app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,6 @@ pub struct Cli {
)]
pub dump: bool,

#[arg(
long = "experimentPklConfig",
global = true,
env = "MOON_EXPERIMENT_PKL_CONFIG",
help = "Enable support for the Pkl (.pkl) configuration format",
help_heading = "Experiments"
)]
pub experiment_pkl: bool,

#[arg(
long,
global = true,
Expand Down Expand Up @@ -351,9 +342,5 @@ impl Cli {
env::set_var("EXTISM_MEMDUMP", "wasm-plugin.mem");
env::set_var("EXTISM_COREDUMP", "wasm-plugin.core");
}

if self.experiment_pkl {
env::set_var("MOON_EXPERIMENT_PKL_CONFIG", "true");
}
}
}
8 changes: 0 additions & 8 deletions crates/app/src/app_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ pub enum AppError {
#[error("Unable to determine your current working directory.")]
MissingWorkingDir,

#[diagnostic(code(app::pkl_required))]
#[error(
"Pkl configuration requires the {} binary to be installed and available.\nLearn more: {}",
"pkl".style(Style::Shell),
"https://pkl-lang.org/main/current/pkl-cli/index.html".style(Style::Url)
)]
PklRequired,

#[diagnostic(code(app::extensions::unknown_id))]
#[error(
"The extension {} does not exist. Configure the {} setting in {} and try again.",
Expand Down
2 changes: 0 additions & 2 deletions crates/app/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,6 @@ impl AppSession for CliSession {
analyze::validate_version_constraint(constraint, &self.cli_version)?;
}

analyze::check_pkl_install()?;

if self.requires_workspace_setup() {
let cache_engine = self.get_cache_engine()?;

Expand Down
11 changes: 1 addition & 10 deletions crates/app/src/systems/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::app_error::AppError;
use moon_actions::utils::should_skip_action;
use moon_bun_platform::BunPlatform;
use moon_cache::CacheEngine;
use moon_common::{consts::PROTO_CLI_VERSION, is_test_env, path::exe_name, supports_pkl_configs};
use moon_common::{consts::PROTO_CLI_VERSION, is_test_env, path::exe_name};
use moon_config::{BunConfig, PlatformType, ToolchainConfig};
use moon_console::{Checkpoint, Console};
use moon_deno_platform::DenoPlatform;
Expand Down Expand Up @@ -34,15 +34,6 @@ pub fn validate_version_constraint(constraint: &VersionReq, version: &Version) -
Ok(None)
}

#[instrument]
pub fn check_pkl_install() -> AppResult {
if supports_pkl_configs() && system_env::find_command_on_path("pkl").is_none() {
return Err(AppError::PklRequired.into());
}

Ok(None)
}

#[instrument(skip_all)]
pub async fn install_proto(
console: &Console,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Runs in CI: Yes

INPUTS

- .moon/*.yml
- .moon/*.{pkl,yml}
- tasks/**/*
2 changes: 1 addition & 1 deletion crates/cli/tests/snapshots/task_test__shows_inputs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ Runs in CI: Yes

INPUTS

- .moon/*.yml
- .moon/*.{pkl,yml}
- tasks/tests/**/*
2 changes: 1 addition & 1 deletion crates/cli/tests/snapshots/task_test__shows_outputs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Runs in CI: Yes

INPUTS

- .moon/*.yml
- .moon/*.{pkl,yml}
- tasks/**/*

OUTPUTS
Expand Down
14 changes: 0 additions & 14 deletions crates/common/src/helpers.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
pub mod consts;
#[cfg(not(target_arch = "wasm32"))]
mod env;
mod helpers;
mod id;
mod macros;
pub mod path;
pub mod serde;

#[cfg(not(target_arch = "wasm32"))]
pub use env::*;
pub use helpers::*;
pub use id::*;
pub use starbase_styles::*;
36 changes: 5 additions & 31 deletions crates/config/src/config_finder.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
use moon_common::consts::CONFIG_DIRNAME;
use moon_common::supports_pkl_configs;
use schematic::ConfigError;
use std::fs;
use std::path::{Path, PathBuf};

#[derive(Clone, Debug)]
pub struct ConfigFinder {
pkl: bool,
}

impl Default for ConfigFinder {
fn default() -> Self {
Self {
pkl: supports_pkl_configs(),
}
}
}
#[derive(Clone, Debug, Default)]
pub struct ConfigFinder;

impl ConfigFinder {
pub fn with_pkl() -> Self {
Self { pkl: true }
}

pub fn get_project_files(&self, project_root: &Path) -> Vec<PathBuf> {
self.get_project_file_names()
.into_iter()
Expand Down Expand Up @@ -90,24 +75,13 @@ impl ConfigFinder {
}

label.push_str(name);

if self.pkl {
label.push_str(".{plk,yml}");
} else {
label.push_str(".yml");
}
label.push_str(".{pkl,yml}");

label
}

pub fn get_file_names(&self, name: &str) -> Vec<String> {
let mut files = vec![format!("{name}.yml")];

if self.pkl {
files.push(format!("{name}.pkl"));
}

files
vec![format!("{name}.yml"), format!("{name}.pkl")]
}

pub fn get_from_dir(&self, dir: PathBuf) -> miette::Result<Vec<PathBuf>> {
Expand Down Expand Up @@ -137,7 +111,7 @@ impl ConfigFinder {
// so avoid failing when trying to parse it as a config
if path
.extension()
.is_some_and(|ext| ext == "yml" || ext == "yaml" || self.pkl && ext == "pkl")
.is_some_and(|ext| ext == "yml" || ext == "yaml" || ext == "pkl")
{
files.push(path);
}
Expand Down
6 changes: 0 additions & 6 deletions crates/config/src/config_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ pub struct ConfigLoader {
}

impl ConfigLoader {
pub fn with_pkl() -> Self {
Self {
finder: ConfigFinder::with_pkl(),
}
}

pub fn create_project_loader<P: AsRef<Path>>(
&self,
project_root: P,
Expand Down
2 changes: 2 additions & 0 deletions crates/config/src/inherited_tasks_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ impl InheritedTasksManager {

let name = if valid_names.iter().any(|n| n == name) {
"*"
} else if let Some(stripped_name) = name.strip_suffix(".yaml") {
stripped_name
} else if let Some(stripped_name) = name.strip_suffix(".yml") {
stripped_name
} else if let Some(stripped_name) = name.strip_suffix(".pkl") {
Expand Down
2 changes: 1 addition & 1 deletion crates/config/tests/inherited_tasks_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ mod task_manager {
#[test]
fn loads_pkl() {
let config = test_config(locate_fixture("pkl"), |path| {
ConfigLoader::with_pkl().load_tasks_config_from_path(path.join(".moon/tasks.pkl"))
ConfigLoader::default().load_tasks_config_from_path(path.join(".moon/tasks.pkl"))
});

assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion crates/config/tests/project_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ workspace:
#[allow(deprecated)]
fn loads_pkl() {
let config = test_config(locate_fixture("pkl"), |path| {
ConfigLoader::with_pkl().load_project_config(path)
ConfigLoader::default().load_project_config(path)
});

assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion crates/config/tests/template_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ variables:
#[test]
fn loads_pkl() {
let config = test_config(locate_fixture("pkl"), |path| {
ConfigLoader::with_pkl().load_template_config(path)
ConfigLoader::default().load_template_config(path)
});

assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion crates/config/tests/toolchain_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ typescript:
fn loads_pkl() {
let mut config = test_config(locate_fixture("pkl"), |path| {
let proto = ProtoConfig::default();
ConfigLoader::with_pkl().load_toolchain_config(path, &proto)
ConfigLoader::default().load_toolchain_config(path, &proto)
});

assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion crates/config/tests/workspace_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ extensions:
#[test]
fn loads_pkl() {
let config = test_config(locate_fixture("pkl"), |path| {
ConfigLoader::with_pkl().load_workspace_config(path)
ConfigLoader::default().load_workspace_config(path)
});

assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions crates/project-graph/tests/project_graph_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ mod project_graph {
assert_eq!(
task.input_globs,
FxHashSet::from_iter([
WorkspaceRelativePathBuf::from(".moon/*.yml"),
WorkspaceRelativePathBuf::from(".moon/*.{pkl,yml}"),
WorkspaceRelativePathBuf::from("project/global.*")
])
);
Expand Down Expand Up @@ -737,7 +737,7 @@ mod project_graph {
assert_eq!(
task.input_globs,
FxHashSet::from_iter([
WorkspaceRelativePathBuf::from(".moon/*.yml"),
WorkspaceRelativePathBuf::from(".moon/*.{pkl,yml}"),
WorkspaceRelativePathBuf::from("tasks/file.*"),
])
);
Expand Down
8 changes: 2 additions & 6 deletions crates/task-builder/src/tasks_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::tasks_builder_error::TasksBuilderError;
use moon_common::path::{is_root_level_source, WorkspaceRelativePath};
use moon_common::{color, supports_pkl_configs, Id};
use moon_common::{color, Id};
use moon_config::{
is_glob_like, InheritedTasksConfig, InputPath, ProjectConfig,
ProjectWorkspaceInheritedTasksConfig, TaskArgs, TaskConfig, TaskDependency,
Expand Down Expand Up @@ -722,11 +722,7 @@ impl<'proj> TasksBuilder<'proj> {
.map(|dep| (*dep).to_owned())
.collect::<Vec<_>>();

global_inputs.push(InputPath::WorkspaceGlob(".moon/*.yml".into()));

if supports_pkl_configs() {
global_inputs.push(InputPath::WorkspaceGlob(".moon/*.pkl".into()));
}
global_inputs.push(InputPath::WorkspaceGlob(".moon/*.{pkl,yml}".into()));

if let Some(env_files) = &options.env_files {
global_inputs.extend(env_files.to_owned());
Expand Down
Loading

0 comments on commit 7146dbf

Please sign in to comment.