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

test: Vendor kcl-samples and add simulation tests for them #5460

Draft
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

jtran
Copy link
Collaborator

@jtran jtran commented Feb 21, 2025

Overview

  • kcl-samples is now copied in public/kcl-samples. We omit screenshots and step output files.
  • ZMA uses these files when opening samples.
  • We now run simulation tests on them, including generating other outputs like the AST, artifact graph, and operations.

To Do

  • Artifact graph output shouldn't be non-deterministic for multi-axis-robot and walkie-talkie.
  • Show which sample failed when there's a test failure.
    thread 'tokio-runtime-worker' panicked at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/insta-1.42.1/src/runtime.rs:679:13:
    snapshot assertion for 'artifact_graph_flowchart' failed in line 235
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    thread 'tokio-runtime-worker' panicked at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/insta-1.42.1/src/runtime.rs:679:13:
    snapshot assertion for 'artifact_graph_flowchart' failed in line 235
    
  • We shouldn't run all of e2e tests when only kcl-samples changes.

Implementation

yarn fetch:samples downloads kcl-samples. @pierremtb implemented this and the ZMA integration.

yarn install is decoupled from fetching kcl-samples. It's part of the dev workflow that shouldn't force people to update kcl-samples if they don't want to.

Since Rust doesn't (out of the box) have a nice way to generate many tests, I made a single test for each parse, unparse, and kcl_test_execute. kcl_test_execute et al run on all KCL samples in a single Rust test. I chose this because the alternative is that we'd need an explicit list of samples in a .rs file to change every time the list of KCL samples changed, which seemed inconvenient. We could change this in the future pretty easily if we like.

Because of the chosen Rust module structure, just commands work.

just run-sim-test kcl_samples

You can also run a single one by filtering to a test prefix:

KCL_SAMPLES_ONLY=gear just run-sim-test kcl_samples

Future Work

I think that it would be nicer if modeling-app were the source of truth for kcl-samples, and we had a CI action that made a PR to the kcl-samples repo. We already use this approach for the OpenAPI specs. But, in my opinion, this PR is better than what we currently do, which is let bugs reach production.

Copy link

qa-wolf bot commented Feb 21, 2025

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

Copy link

vercel bot commented Feb 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Feb 27, 2025 11:38pm

@jessfraz
Copy link
Contributor

jessfraz commented Feb 22, 2025

why not a submodule? its easier in my head than curling it all the time and when we update we just update the submodule plus dependabot could do that for us and we get auto tests thats kinda cool

also helps diffs etc

@jessfraz
Copy link
Contributor

also if its a submodule people cant change individual files out of band of the og repo

@jtran
Copy link
Collaborator Author

jtran commented Feb 24, 2025

why not a [git] submodule?

We'd like the source of truth of kcl-samples to be in modeling-app. Supposedly @jgomez720 and @nicboone8 agreed to this under the condition that changes to only kcl-samples don't run the full modeling-app e2e test suite. A git submodule would be a step backwards.

@jtran jtran force-pushed the jtran/vendor-kcl-samples branch from 9f8706a to cff246e Compare February 26, 2025 22:55
@jtran jtran force-pushed the jtran/vendor-kcl-samples branch from 26ad4c1 to 6e296e1 Compare February 27, 2025 05:24
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.

3 participants