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(cheatcodes): add vm.foundryVersionAtLeast + vm.foundryVersionCmp to make it easier to write conditional version logic #9725

Open
zerosnacks opened this issue Jan 21, 2025 · 4 comments
Labels
A-cheatcodes Area: cheatcodes first issue A good way to start contributing T-feature Type: feature

Comments

@zerosnacks
Copy link
Member

zerosnacks commented Jan 21, 2025

Followup from #9683

vm.getFoundryVersion will now use the format forge 0.3.0-dev+b3d0002118.1737037945.debug

<cargo_version>-<tag>+<git_sha_short>.<unix_build_timestamp>.<profile>

We should provide a function that does the comparison directly like vm.versionAtLeast("1.2.3") and/or vm.versionTimestampAtLeast(unix)

Originally posted by @DaniPopes in #9683 (comment)

@github-project-automation github-project-automation bot moved this to Todo in Foundry Jan 21, 2025
@zerosnacks zerosnacks added T-feature Type: feature A-cheatcodes Area: cheatcodes T-blocked Type: blocked labels Jan 21, 2025
@zerosnacks zerosnacks changed the title feat(cheatcodes): add vm.versionAtLeast utility cheatcode to make it easier for users to write at-least conditional version logic feat(cheatcodes): add vm.versionAtLeast utility cheatcode to make it easier to write conditional version logic Jan 21, 2025
@zerosnacks zerosnacks changed the title feat(cheatcodes): add vm.versionAtLeast utility cheatcode to make it easier to write conditional version logic feat(cheatcodes): add vm.versionAtLeast to make it easier to write conditional version logic Jan 21, 2025
@zerosnacks zerosnacks added first issue A good way to start contributing and removed T-blocked Type: blocked labels Jan 21, 2025
@chiscookeke11
Copy link

I'd like to handle this task.

@DaniPopes
Copy link
Member

DaniPopes commented Jan 22, 2025

I think we want to prefix with foundry so foundryVersion

Another variation is foundryVersionCmp(string) returns(int) which returns -1, 0, 1 for less, equal, greater than; then you then can do <, <=, ==, >=, > with 0 to do the comparison

This is implemented as parsing the string input as semver, getting the Ordering from parsed.cmp(FOUNDRY_VERSION), and returning it as isize

@zerosnacks zerosnacks changed the title feat(cheatcodes): add vm.versionAtLeast to make it easier to write conditional version logic feat(cheatcodes): add vm.foundryVersionAtLeast to make it easier to write conditional version logic Jan 22, 2025
@zerosnacks zerosnacks changed the title feat(cheatcodes): add vm.foundryVersionAtLeast to make it easier to write conditional version logic feat(cheatcodes): add vm.foundryVersionAtLeast + vm.foundryVersionCmp to make it easier to write conditional version logic Jan 22, 2025
@sambacha
Copy link
Contributor

foundry does not build hermetically across OS's, setting a defined timestamp would fix the issue w.r.t. different binaries having different build timestamps but coming from the same commit

@wengDavo
Copy link

Could I take over this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes first issue A good way to start contributing T-feature Type: feature
Projects
Status: Todo
Development

No branches or pull requests

5 participants