Skip to content

Conversation

@josephjclark
Copy link
Collaborator

@josephjclark josephjclark commented Nov 11, 2025

I am writing unit tests against the mix generate_workflow command. I am taking two projects, merging them, and comparing the results.

I've hit a fun problem on new nodes created in the source sandbox (ie, staging). Lightning generates new UUIDs for them in the target project. But I can't predict those UUIDs, so it's very hard to write compelling tests.

This PR allows me to explicitly pass a UUID mapping into the command. So if there's a new node called abc in the source, I want to assign it a UUID of xyz in the target:

mix lightning.generate_workflow staging.json main.json --uuid abc:xyz

Note that in tests I very rarely use actually UUIDs, so the command allows me to pass in fake UUIDs as strings or numbers.

I have deliberately not added a node to the changelog. I'm not sure it's relevant?

Closes #3964

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

Claude generated all the code over a series of commits, with some refactoring and design from myself.

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

@github-project-automation github-project-automation bot moved this to New Issues in v2 Nov 11, 2025
@josephjclark josephjclark marked this pull request as ready for review November 11, 2025 17:29
Copy link
Collaborator

@midigofrank midigofrank left a comment

Choose a reason for hiding this comment

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

@josephjclark this looks great. As it is, this looks like a fallback but I think it should be the first priority, almost as if the user specifies how they want their workflows/jobs to be mapped. What do you think?

@josephjclark
Copy link
Collaborator Author

Thanks @midigofrank. What are you envisioning by "make it priority"? What sort of changes would you imagine?

I think this is only needed when new nodes and edges are created in the source. Which is a common use-case but also not totally core.

If we want to broaden this up, we could explore a flag that enables seeded "uuids" which are just incrementing numbers. I use this approach all the time in the CLI, and it a least means the ids are predictable.

But tbh this approach here works great for me today and I wouldn't want to spend a lot of time anything more substantial. Not yet anyway :)

@midigofrank
Copy link
Collaborator

Aaah I see. I meant having it as the accumulator during the first step of mapping in the merge algorithm. Think of it as them being already mapped nodes

@josephjclark
Copy link
Collaborator Author

Maybe. I think I'd rather just merge it as-is. Given that it's a test util I think I prefer the idea that the implementation is out on the fringes. I also don't want to take a lot of resources on it, given that it works great from my point of view

Copy link
Collaborator

@midigofrank midigofrank left a comment

Choose a reason for hiding this comment

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

@josephjclark I have made 2 changes:

  1. I have renamed the variable to new_uuid_map because it's only used for new items
  2. Fixed the typespec warnings

source_id = String.trim(source_id)
target_id = String.trim(target_id)

# Support both string and integer keys by adding both forms
Copy link
Collaborator

Choose a reason for hiding this comment

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

@josephjclark by the way why do we need to add both keys in here? And why are we only parsing the source and not the target?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, it's actually this part that's failing in the CI. I'll have a look tomorrow

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is probably AI silliness that has not been properly validated by this silly human

I do need string and integer types, although maybe there's a better way I can handle this (like maybe my test code should be casting numbers to strings)

@josephjclark
Copy link
Collaborator Author

Thank you so much @midigofrank 🙏

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.67%. Comparing base (fcb972a) to head (3a9d740).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
lib/mix/tasks/merge_projects.ex 93.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3965   +/-   ##
=======================================
  Coverage   88.67%   88.67%           
=======================================
  Files         423      423           
  Lines       18926    18944   +18     
=======================================
+ Hits        16782    16798   +16     
- Misses       2144     2146    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@midigofrank midigofrank merged commit a6894c7 into main Nov 13, 2025
8 checks passed
@midigofrank midigofrank deleted the pass-uuid-map branch November 13, 2025 08:39
@github-project-automation github-project-automation bot moved this from New Issues to Done in v2 Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Sandboxes: when merging, how can we make UUID generation predictable?

3 participants