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

Make more options variable-expanded #10

Merged
merged 1 commit into from
Nov 7, 2024
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ interval = 30
# - Any variables defined in runners.<runner_name>.config_variables
# - Any environment variables provided by gitlab-runner to this custom executor
[launch]
# Executable name or path, will NOT be variable-expanded
# Executable name or path, will be variable-expanded
executable = "sbatch"
# Arguments to pass to the executable, they will be variable-expanded
args = []
Expand Down Expand Up @@ -91,7 +91,7 @@ image_cache_dir = "$HOME/image_cache"
image_tmp_dir = "$HOME/image_tmp"
# Pull policy to use for images, will NOT be variable-expanded
pull_policy = "if-not-present"
# Path to the apptainer executable (may be relative to workdir or $PATH), will NOT be variable-expanded
# Path to the apptainer executable (may be relative to workdir or $PATH), will be variable-expanded
apptainer_executable = "apptainer"
# Mount AMD GPU devices, will be variable-expanded
gpu_amd = false
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct GitLabRunnerInstance {

#[derive(Debug, DocumentedFields, FieldNamesAsArray, Deserialize, Serialize)]
pub struct GitLabLaunchConfig {
/// Executable name or path, will NOT be variable-expanded
/// Executable name or path, will be variable-expanded
pub executable: String,
/// Arguments to pass to the executable, they will be variable-expanded
pub args: Vec<String>,
Expand Down Expand Up @@ -150,8 +150,8 @@ pub struct GitLabCustomExecutorConfigTemplate {
pub image_tmp_dir: Option<String>,
/// Pull policy to use for images, will NOT be variable-expanded
pub pull_policy: GitLabExecutorPullPolicy,
/// Path to the apptainer executable (may be relative to workdir or $PATH), will NOT be variable-expanded
pub apptainer_executable: PathBuf,
/// Path to the apptainer executable (may be relative to workdir or $PATH), will be variable-expanded
pub apptainer_executable: String,
#[serde(default = "false_bool_or_string")]
/// Mount AMD GPU devices, will be variable-expanded
pub gpu_amd: BoolOrString,
Expand Down
14 changes: 10 additions & 4 deletions src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ pub fn expand_runner_config_template(
.environment
.as_ref()
.map(|m| m.iter().map(|v| string_expand(v)).collect())
.transpose()?,
.transpose()
.context("environment")?,
executor: match &config.executor {
Executor::Custom {
custom:
Expand Down Expand Up @@ -143,14 +144,17 @@ pub fn expand_executor_config_template(
.transpose()
.context("image_tmp_dir")?,
pull_policy: executor.pull_policy,
apptainer_executable: executor.apptainer_executable.clone(),
apptainer_executable: string_expand(&executor.apptainer_executable)
.context("apptainer_executable")?
.into(),
gpu_amd: expand_to_bool(&executor.gpu_amd).context("gpu_amd")?,
gpu_nvidia: expand_to_bool(&executor.gpu_nvidia).context("gpu_nvidia")?,
mount: executor
.mount
.iter()
.map(|v| string_expand(v))
.collect::<anyhow::Result<Vec<_>>>()?,
.collect::<anyhow::Result<Vec<_>>>()
.context("mount")?,
builds_dir: string_expand(
executor
.builds_dir
Expand Down Expand Up @@ -195,7 +199,9 @@ pub fn expand_launch_config_template(
v.into_iter().map(|s| string_expand(s)).collect()
};
Ok(GitLabLaunchConfig {
executable: launch.executable.clone(),
executable: string_expand(&launch.executable)
.context("executable")?
.into(),
args: string_array_expand(&launch.args).context("args")?,
workdir: optional_string_expand(&launch.workdir).context("workdir")?,
stdin: optional_string_expand(&launch.stdin).context("stdin")?,
Expand Down