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

chore: display warning to user if running nightly version #9683

Merged
merged 36 commits into from
Jan 21, 2025

Conversation

zerosnacks
Copy link
Member

@zerosnacks zerosnacks commented Jan 15, 2025

Motivation

Closes: #9676 + Closes #2212 (exposes SEMVER_VERSION) + Closes #5722

Three new version strings are exposed:

  • Short (-V)
  • Long (--version)
  • Semver (used for cheats, specific matching)

Short / long use the format as used by rustc / reth / solar

Updates: #8530 to use the new Foundry version format

On nightly builds - yields the warning:

pub const NIGHTLY_VERSION_WARNING_MESSAGE: &str =
    "This is a nightly build of Foundry. It is recommended to use the latest stable version. \
    Visit https://book.getfoundry.sh/announcements for more information. \n\
    To mute this warning set `FOUNDRY_DISABLE_NIGHTLY_WARNING` in your environment. \n";

If --silent or --json is passed the warning is muted

Solution

Creates a unified build script logic for the different binaries

Raises the warning right after global initialization of the shell as this is common logic for all binaries

Offers a user a way to mute the warning by setting FOUNDRY_DISABLE_NIGHTLY_WARNING in their shell

To test the nightly case:

PROFILE=release TAG_NAME=nightly make build

it will use the -nightly suffix:

forge Version: 0.3.1-nightly
Commit SHA: d6724dd503bedd961acc51102c4bcfb5159930d5
Build Timestamp: 2025-01-21T08:51:03.116597913Z (1737449463)
Build Profile: release
forge 0.3.1-nightly (d6724dd503 2025-01-21T08:51:03.116597913Z)

which raises

Warning: This is a nightly build of Foundry. It is recommended to use the latest stable version. Visit https://book.getfoundry.sh/announcements for more information. 
To mute this warning set `FOUNDRY_DISABLE_NIGHTLY_WARNING` in your environment. 
...

To test any other case (e.g. stable):

PROFILE=release TAG_NAME=stable make build

it will use the -stable suffix:

forge Version: 0.3.1-stable
Commit SHA: d6724dd503bedd961acc51102c4bcfb5159930d5
Build Timestamp: 2025-01-21T08:55:40.668257676Z (1737449740)
Build Profile: release
forge 0.3.1-stable (d6724dd503 2025-01-21T08:55:40.668257676Z)

Notice if you do not have a tag name set:

make build

it will use the -dev version suffix:

forge Version: 0.3.1-dev
Commit SHA: d6724dd503bedd961acc51102c4bcfb5159930d5
Build Timestamp: 2025-01-21T08:50:33.487130844Z (1737449433)
Build Profile: debug
forge 0.3.1-dev (d6724dd503 2025-01-21T08:50:33.487130844Z)

Note: I can't think of a good way to test this fully without actually creating a nightly build

Breaking changes

  • vm.getFoundryVersion will now use the format forge 0.3.0-dev+b3d0002118.1737037945.debug:
    /// Format: <cargo_version>-<tag>+<git_sha_short>.<unix_build_timestamp>.<profile>
    /// Sample output: 0.3.0-nightly+3cb96bde9b.1737036656.debug
    /// Note: Build timestamps may vary slightly across platforms due to separate CI jobs.
    /// For reliable version comparisons, use UNIX format (e.g., >= 1700000000)
    /// to compare timestamps while ignoring minor time differences.

as opposed to

    /// Format: <cargo_version>+<git_sha>+<build_timestamp>
    /// Sample output: 0.2.0+faa94c384+202407110019
    /// Note: Build timestamps may vary slightly across platforms due to separate CI jobs.
    /// For reliable version comparisons, use YYYYMMDD0000 format (e.g., >= 202407110000)
    /// to compare timestamps while ignoring minor time differences.

@zerosnacks zerosnacks self-assigned this Jan 15, 2025
@zerosnacks zerosnacks marked this pull request as ready for review January 15, 2025 15:33
@grandizzy
Copy link
Collaborator

grandizzy commented Jan 15, 2025

@zerosnacks wonder if this addresses #5722 too which basically requires a -debug label?

yash-atreya
yash-atreya previously approved these changes Jan 15, 2025
Copy link
Member

@yash-atreya yash-atreya left a comment

Choose a reason for hiding this comment

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

lgtm!

@zerosnacks
Copy link
Member Author

@zerosnacks wonder if this addresses #5722 too which basically requires a -debug label?

Good call, adding this - will postfix the profile as follows: 0.3.0-dev+ba03de0019.debug

@zerosnacks
Copy link
Member Author

@zerosnacks wonder if this addresses #5722 too which basically requires a -debug label?

Added in 92ba0d9

crates/cli/build.rs Outdated Show resolved Hide resolved
crates/common/src/version.rs Outdated Show resolved Hide resolved
crates/common/src/version.rs Outdated Show resolved Hide resolved
crates/common/src/version.rs Outdated Show resolved Hide resolved
crates/anvil/src/config.rs Outdated Show resolved Hide resolved
crates/cheatcodes/Cargo.toml Outdated Show resolved Hide resolved
crates/cli/Cargo.toml Outdated Show resolved Hide resolved
crates/common/Cargo.toml Outdated Show resolved Hide resolved
crates/common/src/version.rs Outdated Show resolved Hide resolved
crates/common/src/version.rs Outdated Show resolved Hide resolved
crates/common/src/version.rs Outdated Show resolved Hide resolved
@zerosnacks

This comment was marked as outdated.

crates/common/src/version.rs Outdated Show resolved Hide resolved
crates/cheatcodes/src/test.rs Outdated Show resolved Hide resolved
@@ -8,19 +8,38 @@ contract GetFoundryVersionTest is DSTest {
Vm constant vm = Vm(HEVM_ADDRESS);

function testGetFoundryVersion() public view {
// (e.g. 0.3.0-nightly+3cb96bde9b.1737036656.debug)
Copy link
Member

@DaniPopes DaniPopes Jan 16, 2025

Choose a reason for hiding this comment

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

if we're going to commit to a format that users want to parse themselves, maybe we should provide a function that does the comparison directly? Like vm.versionAtLeast("1.2.3") and/or vm.versionTimestampAtLeast(unix); I would prefer just the former for 1.0

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, can be done in a follow up imo

crates/common/src/version.rs Show resolved Hide resolved
crates/common/src/version.rs Outdated Show resolved Hide resolved
@zerosnacks zerosnacks requested a review from DaniPopes January 20, 2025 11:52
@zerosnacks zerosnacks dismissed DaniPopes’s stale review January 20, 2025 14:55

Feedback addressed

@zerosnacks
Copy link
Member Author

Updated description, performed additional manual tests and opened #9725 as a followup

Going to merge this so it is available in the next nightly

@zerosnacks zerosnacks merged commit 62147c8 into master Jan 21, 2025
22 checks passed
@zerosnacks zerosnacks deleted the zerosnacks/add-type-to-version branch January 21, 2025 09:29
@zerosnacks zerosnacks mentioned this pull request Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-likely-breaking Type: requires changes that can be breaking
Projects
Status: Ready For Review
4 participants