-
-
Notifications
You must be signed in to change notification settings - Fork 289
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: support .env.test to reuse env variables across the tests #6408
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a good idea!!!
packages/cli/package.json
Outdated
"test:sim:endpoints": "LODESTAR_PRESET=minimal node --loader ts-node/esm test/sim/endpoints.test.ts", | ||
"test:sim:deneb": "LODESTAR_PRESET=minimal node --loader ts-node/esm test/sim/deneb.test.ts", | ||
"test:sim:backup_eth_provider": "LODESTAR_PRESET=minimal node --loader ts-node/esm test/sim/backup_eth_provider.test.ts", | ||
"test:sim:multifork": "DOTENV_CONFIG_PATH=../../.env.test LODESTAR_PRESET=minimal node -r dotenv/config --loader ts-node/esm test/sim/multi_fork.test.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should LODESTAR_PRESET go into the .env?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we can add that there as well. Need to check if any other test file depend on other preset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Then let's definitely move that so we are using one pattern (ie and env file)
vitest.base.unit.config.ts
Outdated
@@ -1,6 +1,6 @@ | |||
import path from "node:path"; | |||
import {defineConfig} from "vitest/config"; | |||
const __dirname = new URL(".", import.meta.url).pathname; | |||
const currentDir = new URL(".", import.meta.url).pathname; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m partial to leaving this as __dirname
. I dont feel strongly about it but it’s sort of the “node way” to name that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I had that initially as __dirname
here and other places as well, but feel like a old pattern now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the rest of the codebase __dirname
is better, but no strong opinion here
Performance Report✔️ no performance regression detected Full benchmark results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It a bit counter intuitive to me to have .env files in source control. I am rather used to having those files to override locally and explicitly not have them tracked by git.
Why can't we just set the default image versions in scripts/run_e2e_env.sh
and allow to override them via env variables?
We could consider having dotenv module to override those but seems a bit overkill as there are not many envs and you can just add GETH_DOCKER_IMAGE=...
in front of the yarn command to achieve this easily if someone wants to use a different version than the default one.
I am also not in favor of keeping
Not now but if needed we can make this setup in a way that you can override those variables in |
But I like the de-duplication of setting the version which is much better than before Edit: It seems to be convention to have .env.test as part of source control So I guess we are good to go |
vitest.base.unit.config.ts
Outdated
@@ -1,6 +1,6 @@ | |||
import path from "node:path"; | |||
import {defineConfig} from "vitest/config"; | |||
const __dirname = new URL(".", import.meta.url).pathname; | |||
const currentDir = new URL(".", import.meta.url).pathname; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the rest of the codebase __dirname
is better, but no strong opinion here
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## unstable #6408 +/- ##
============================================
+ Coverage 60.14% 61.72% +1.57%
============================================
Files 407 553 +146
Lines 46512 57856 +11344
Branches 1551 1829 +278
============================================
+ Hits 27975 35711 +7736
- Misses 18505 22108 +3603
- Partials 32 37 +5 |
…r into nh/share-env-variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I am sorry I brought up the LODESTAR_PRESET
. Apologies!! I didn’t realize the amount of confusion it would insert because of how we use the two for different tests interchangeably. Thank you for the thoroughness in working through those challenges.
Just the two questions about the inserts and the update for getting the BASH dirname
"test:unit:minimal": "vitest --run --segfaultRetry 3 --dir test/unit/", | ||
"test:unit:mainnet": "LODESTAR_PRESET=mainnet vitest --run --dir test/unit-mainnet", | ||
"test:unit:minimal": "LODESTAR_PRESET=minimal vitest --run --segfaultRetry 3 --dir test/unit/", | ||
"test:unit:mainnet": "LODESTAR_PRESET=mainnet vitest --run --segfaultRetry 3 --dir test/unit-mainnet", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this segfaultRetry
was added. what does that do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was earlier added in minimal
preset and missing in mainnet
. It just check if tests fails with a segfault error, it tries to rerun it.
@@ -14,6 +14,7 @@ const {forkConfig} = defineSimTestConfig({ | |||
BELLATRIX_FORK_EPOCH: bellatrixForkEpoch, | |||
CAPELLA_FORK_EPOCH: capellaForkEpoch, | |||
runTillEpoch: Infinity, | |||
initialNodes: 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i noticed this was added. what does that do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It adjust the genesis delay for the e2e notes, without that default is a bit higher value, so tests take more time to wait for capella fork.
scripts/run_e2e_env.sh
Outdated
@@ -1,18 +1,19 @@ | |||
#!/bin/bash | |||
|
|||
DIR=$(dirname "$0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve seen this done like the below before.
DIR="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
It ensures that the directory is obtained correctly even if the script is executed from a different directory or via a symbolic link
@matthewkeil No problem at all. We had to clean up today or later anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet!! 🎸 I haven't run with the most recent changes but assuming it works. Although I noticed that CI was not happy. Not sure if that is related to these changes though.... A goal to shoot for is all green CI. If I can help I will be glad to lend a hand. Just point me in a direction and ill do my best
6b3522d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reapproving but asked in discord about such a big downgrade to make sure we are not going to run into issues
🎉 This PR is included in v1.16.0 🎉 |
Motivation
Reuse the env variables.
Description
.env.test
Steps to test or reproduce