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: cache global template build at initialization #6299

Merged
merged 8 commits into from
Nov 13, 2023

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Nov 13, 2023

Motivation

Faster tests

Solution

Build only once at global template initialization rather than per each test.

This requires that we also use a single Solc version for all tests, at least by default. Do that.

Comment on lines +79 to +87
// We are the first to acquire the lock:
// - initialize a new empty temp project;
// - run `forge init`;
// - run `forge build`;
// - copy it over to the global template;
// Ideally we would be able to initialize a temp project directly in the global template,
// but `TempProject` does not currently allow this: https://github.com/foundry-rs/compilers/issues/22

// Release the read lock and acquire a write lock, initializing the lock file.
Copy link
Member

Choose a reason for hiding this comment

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

ah yeah we should have thought about this much earlier lol

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that the static Lazy didn't work due to nextest running each test in a separate process

@DaniPopes
Copy link
Member Author

DaniPopes commented Nov 13, 2023

Solidity version used:

  • 0.5.17
  • 0.7.1
  • 0.8.10
  • 0.8.13
  • 0.8.15
  • 0.8.17
  • 0.8.23

Now down to:

  • 0.5.17 (can_test_pre_bytecode_hash)
  • 0.8.22 (OTHER_SOLC_VERSION)
  • 0.8.23 (SOLC_VERSION, default)

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

this is sick. the note about the global lock makes a ton of sense

@DaniPopes DaniPopes merged commit b3ea19a into master Nov 13, 2023
19 checks passed
@DaniPopes DaniPopes deleted the dani/test-global-cache branch November 13, 2023 20:50
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