From 9a857275fb52e67237525b3838f54878ea315201 Mon Sep 17 00:00:00 2001 From: Jonathan Frey Date: Fri, 31 Jul 2026 10:03:40 +0200 Subject: [PATCH 1/5] remove travis --- .travis.yml | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2f540b3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ -language: rust - -matrix: - allow_failures: - - rust: nightly - fast_finish: true - -os: -- linux -- osx -- windows - -arch: -- amd64 -- arm64 - -script: - - cargo build --verbose --release; - -before_deploy: - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then mv target/release/t_renderer "target/release/t_renderer-$TRAVIS_TAG-$TRAVIS_OS_NAME"; fi - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then mv target/release/t_renderer "target/release/t_renderer-$TRAVIS_TAG-$TRAVIS_OS_NAME"; fi - - if [ "$TRAVIS_OS_NAME" = "windows" ]; then powershell Rename-Item "target\\release\\t_renderer.exe" -NewName "t_renderer-$TRAVIS_TAG-$TRAVIS_OS_NAME"; fi - -deploy: - provider: releases - api_key: - secure: r7KHEiBFuDCTPZcTYrzXZWk/80UEQ085avicgRpsurhoGqsOS2dl020Iyo7XbmzYLLnrWmXvdGf6k+C0F3yP6nOyyPef+8DVb0JmmJzRz05n+g0a4FWWQbEusKfb7nsPzLK6wtiphyCwfns3YE+BLGzak1whTTC6lpii0wfk6L8L+VnT1UzJYlUYHnBhZmOEixuxd55DCkOMwhMGLudAtmk1D6bJCynyUIngwCui2NxbFT4qz+o/Rmgs7nLahWOXnbLkeWXzWEatq62A5r0n4hfH/OsTVyJlOcpjl596ccVC313+v1EwAlODcEh3e2N9mBjzNtmF0XaBAkKwJyeqs5ubNKtFuu5LlBUbRcxMmSIRt/IunzPP/snA9I08iQaxbHcQkrhGTo0DXUoWEb7bBFZM7iOp0aK8S6F9+jvgGyow4YTwEsE/ZsAgcLXva4k+VDK9OuO7y+6Ybfzj/0kCkric15teeA5vzNCeJMJLV0LmLRukpGebwdzgBI9a5ywQ65egwkmZJMFbQXfm6b/+r7zkyclGCnG+Kh6K+AfFOirvbHh1TYdTq0oe/l4bDNmfPq7i0IEDpcs+NcLDnC+TxHBsegrloZrtNKOnmvCjn2F3mwwf88WiC/vz6Cqn2rzQUXHOb79LPJoGvZSZ3EjWGxoFJHmB72C19AlNC2wVCxk= - skip_cleanup: true - file_glob: true - file: target/release/t_renderer-* - on: - tags: true - # repo: acados/tera_renderer From ba2da724635f6273a2756952bb3dd7926091ae93 Mon Sep 17 00:00:00 2001 From: Jonathan Frey Date: Fri, 31 Jul 2026 11:23:22 +0200 Subject: [PATCH 2/5] Improve missing-context render diagnostics and update deprecated GitHub Actions runtimes --- .github/workflows/main.yml | 4 ++-- src/main.rs | 40 ++++++++++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ab75fb3..c3dec6c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Build run: | @@ -61,7 +61,7 @@ jobs: run: mv target/release/t_renderer${{ steps.ext.outputs.ext }} t_renderer${{ steps.tag.outputs.tag }}-${{ matrix.architecture }}${{ steps.ext.outputs.ext }} - name: Upload t_renderer Artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: t_renderer${{ steps.tag.outputs.tag }}-${{ matrix.architecture }}${{ steps.ext.outputs.ext }} path: t_renderer${{ steps.tag.outputs.tag }}-${{ matrix.architecture }}${{ steps.ext.outputs.ext }} diff --git a/src/main.rs b/src/main.rs index edbfc7c..6b771cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,25 @@ struct Args { out_file: String } +fn extract_key_with_prefix(msg: &str, prefix: &str) -> Option { + msg.split(prefix) + .nth(1) + .and_then(|s| s.split('`').next()) + .filter(|s| !s.is_empty()) + .map(String::from) +} + +fn extract_missing_context_key(render_error: &tera::Error) -> Option { + let detailed_error = format!("{:#}", render_error); + extract_key_with_prefix(&detailed_error, "Variable `") + .or_else(|| extract_key_with_prefix(&detailed_error, "Field `")) + .or_else(|| { + let debug_error = format!("{:?}", render_error); + extract_key_with_prefix(&debug_error, "Variable `") + .or_else(|| extract_key_with_prefix(&debug_error, "Field `")) + }) +} + fn main() -> io::Result<()> { // read command line arguments let args = Args::parse(); @@ -41,14 +60,21 @@ fn main() -> io::Result<()> { // println!("{}", contents); // Parse the string of data into serde_json::Value. - let v: serde_json::Value = serde_json::from_str(&contents)?; + let v: serde_json::Value = serde_json::from_str(&contents).map_err(|e| { + io::Error::new(io::ErrorKind::InvalidData, format!("Invalid JSON context: {}", e)) + })?; // Convert serde_json::Value to tera::Context - let ctx: Context = Context::from_serialize(&v).unwrap(); + let ctx: Context = Context::from_serialize(&v).map_err(|e| { + io::Error::new( + io::ErrorKind::InvalidData, + format!("Failed to build template context from JSON: {}", e), + ) + })?; let tera = match Tera::new(template_glob) { Ok(t) => t, Err(e) => { - println!("Parsing error(s): {}", e); + eprintln!("Template parsing error(s): {}", e); ::std::process::exit(1); } }; @@ -59,7 +85,13 @@ fn main() -> io::Result<()> { f_out.write_all(s.as_bytes())?; }, Err(e) => { - println!("Error: {}", e); + if let Some(missing_key) = extract_missing_context_key(&e) { + eprintln!( + "Error: missing context value `{}` required by template `{}`.", + missing_key, template_file + ); + } + eprintln!("Render error: {}", e); process::exit(1); } }; From 65ae4b473ecffc87d61515c0b38326fb6b805305 Mon Sep 17 00:00:00 2001 From: Jonathan Frey Date: Fri, 31 Jul 2026 12:05:54 +0200 Subject: [PATCH 3/5] actions: update macos-13 -> macos-14, window-2019 -> windows-2022 --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c3dec6c..686bfef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,9 +12,9 @@ jobs: include: - runs-on: ubuntu-22.04 architecture: linux-amd64 - - runs-on: macos-13 + - runs-on: macos-14 architecture: osx-amd64 - - runs-on: windows-2019 + - runs-on: windows-2022 architecture: windows-amd64 - runs-on: ubuntu-22.04-arm architecture: linux-arm64 From 81140a985ed74777a4c13fdda3989997a2237360 Mon Sep 17 00:00:00 2001 From: Jonathan Frey Date: Fri, 31 Jul 2026 12:06:12 +0200 Subject: [PATCH 4/5] bump to 0.2.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2c93a21..d50d939 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "t_renderer" -version = "0.2.0" +version = "0.2.1" authors = ["acados authors"] edition = "2018" From 74a84bf320ebaf75defb36786d3d89d9ba691418 Mon Sep 17 00:00:00 2001 From: Jonathan Frey Date: Fri, 31 Jul 2026 12:12:25 +0200 Subject: [PATCH 5/5] whitespace --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 6b771cd..f7813e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,7 @@ fn extract_missing_context_key(render_error: &tera::Error) -> Option { }) } -fn main() -> io::Result<()> { +fn main() -> io::Result<()> { // read command line arguments let args = Args::parse();