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

Fix removed jinja variable in build.script.content #1353

Merged
merged 4 commits into from
Jan 20, 2025

Conversation

hadim
Copy link
Contributor

@hadim hadim commented Jan 19, 2025

An attempt to fix #1335

See below:

# Working with this PR ✅
build:
  script:
    content:
      - ${{ PYTHON }} --version

# Working with this PR ✅
build:
  script:
    content: ${{ PYTHON }} --version

# Working before this PR ✅
build:
  script:
    - ${{ PYTHON }} --version

# Working before this PR ✅
build:
  script: ${{ PYTHON }} --version

This issue being that the jinja variables are removed from the string. So ${{ PYTHON }} --version becomes --version during the build.


Should I add test(s) for this? If yes then where?

…t.content` similar to what is done with `build.script`
@hadim
Copy link
Contributor Author

hadim commented Jan 19, 2025

Maybe for the record, I found this PR that introduced support for jinja variables in build.script: #894

@hadim
Copy link
Contributor Author

hadim commented Jan 19, 2025

I was trying to add a few tests for this but when I remove the fix of this PR, the test still passes, so I am confused. It seems like parsing is done correctly in that simple scenario but fails when using rattler-build.

#[cfg(test)]
mod tests {
    use super::*;
    use serde_yaml;

    #[test]
    fn test_script_content_sequence() {
        let script = Script {
            content: ScriptContent::Commands(vec!["${{ PYTHON }} --version".to_string()]),
            interpreter: Some("bash".to_string()),
            ..Default::default()
        };

        let yaml = serde_yaml::to_string(&script).unwrap();

        let expected_yaml = r#"interpreter: bash
content: ${{ PYTHON }} --version
"#;

        assert_eq!(yaml, expected_yaml);

        let parsed_script: Script = serde_yaml::from_str(&expected_yaml).unwrap();
        assert_eq!(parsed_script, script);
    }
}

@hadim
Copy link
Contributor Author

hadim commented Jan 19, 2025

I finally added more "high-level" tests in the rust-tests crate.

@wolfv wolfv merged commit 46a1efb into prefix-dev:main Jan 20, 2025
15 checks passed
@hadim hadim deleted the jinja_script_content branch January 20, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jinja variables are being removed in build.script.content
2 participants