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

feat: Add e2e test for zarf injector #2956

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joonas
Copy link
Contributor

@joonas joonas commented Sep 1, 2024

Description

This adds an end-to-end test for Zarf Injector that can be run via cargo test.

A test run looks roughly something like this (added -- --nocapture to show the injector's output):

$ cargo test -- --nocapture
   Compiling zarf-injector v0.5.0 (/Users/joonas/dev/src/github.com/joonas/zarf2/src/injector)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 2.15s
     Running unittests src/main.rs (target/debug/deps/zarf_injector-2ae058ea9433f3a1)

running 1 test
Processing /var/folders/_c/r676d3w91pd8sccwkvs05t3h0000gn/T/t968b-0/zarf-init/zarf-payload-000
Processing /var/folders/_c/r676d3w91pd8sccwkvs05t3h0000gn/T/t968b-0/zarf-init/zarf-payload-001
Processing /var/folders/_c/r676d3w91pd8sccwkvs05t3h0000gn/T/t968b-0/zarf-init/zarf-payload-002
Processing /var/folders/_c/r676d3w91pd8sccwkvs05t3h0000gn/T/t968b-0/zarf-init/zarf-payload-003
Processing /var/folders/_c/r676d3w91pd8sccwkvs05t3h0000gn/T/t968b-0/zarf-init/zarf-payload-004
request: zarf-dev/doom-game/manifests/0.0.1
test test::test_integration ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.09s

My hope with this change was to make future refactoring cycles a little bit faster since there is a relatively fast local test (couple of seconds tops after the initial compile) for feedback.

Related Issue

Fixes #

Relates to #

Checklist before merging

Signed-off-by: Joonas Bergius <joonas@bergi.us>
@joonas joonas requested review from a team as code owners September 1, 2024 20:57
Copy link

netlify bot commented Sep 1, 2024

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 483fd09
🔍 Latest deploy log https://app.netlify.com/sites/zarf-docs/deploys/66d4d53e1bafa200084a2c37

@joonas
Copy link
Contributor Author

joonas commented Sep 1, 2024

for what it's worth, I tried to make sure that these changes would in no way impact the injector's binary size, and building it locally with cargo-zigbuild, it looks like the binaries are still under 1mb:

$ cargo zigbuild --release --target x86_64-unknown-linux-musl
$ stat -f '%z' target/x86_64-unknown-linux-musl/release/zarf-injector
1040992

$ cargo zigbuild --release --target aarch64-unknown-linux-musl
$ stat -f '%z' target/aarch64-unknown-linux-musl/release/zarf-injector
946224

Comment on lines +25 to +31
hex = { version = "0.4.3", default-features = false }
serde_json = { version = "1.0.113", default-features = false, features = [
"alloc",
] }
axum = { version = "0.7.5", features = ["tokio"] }
tokio = { version = "1.35.0", features = ["fs", "rt"] }
tokio-util = { version = "0.7.10", features = ["io"]}
tokio-util = { version = "0.7.10", features = ["io"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can revert these if that'd be desirable, just my local editor configuration

Comment on lines +65 to +68
let init_root =
std::env::var("ZARF_INJECTOR_INIT_ROOT").unwrap_or_else(|_| String::from("/zarf-init"));
let seed_root =
std::env::var("ZARF_INJECTOR_SEED_ROOT").unwrap_or_else(|_| String::from("/zarf-seed"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are necessary to make it possible to pass in a temporary directory location for testing purposes while still falling back to the default behavior when running as part of zarf init.

@joonas
Copy link
Contributor Author

joonas commented Sep 1, 2024

I'd be happy to include a GitHub Actions sample workflow for running this against Zarf Injector changes if that would be helpful, generally speaking it would probably look something like:

  1. Be triggered with path-based filter that is filtering for changes in src/injector/**
  2. Set the working directory to src/injector
  3. Run cargo test
  4. Potentially run cargo clippy (though that will fail initially, so maybe a future improvement)

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.

1 participant