-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fetch secrets from <workspace>/.continue/.env folder before <workspace>/.env #5461
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
fetch secrets from <workspace>/.continue/.env folder before <workspace>/.env #5461
Conversation
✅ Deploy Preview for continuedev canceled.
|
@uinstinct could you add tests for this as documentation and to prevent future regressions? |
jest.mock("../../util/paths.ts", () => ({ | ||
...jest.requireActual("../../util/paths"), | ||
getContinueDotEnv: jest.fn(), | ||
})); |
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.
there is some problem when am trying to mock a local file as jest is unable to resolve it. it seems like a problem with how jest is setup. I tried various ways to get it working. Currently none of these work.
Any idea what should I do to a mock?
(I need to mock utils/paths
for imported functions like getContinueDotEnv()
)
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.
@uinstinct have you checked some existing instances of jest.mock
we have in the codebase?
I understand most of them are for node packages but maybe they can point you in the right direction. If you are still stuck, let me know and I can try to pull this into the sprint next week.
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.
Thanks for replying Tomasz!
I had tried these actually but for some reason jest is unable to resolve it.
For alternative options, we can:
- use the filesystem env (problem: the test might affect the local users .env)
- use a conditional (
process.env.TEST
flag) insidegetContinueDotEnv
to produce a key value pair for testing
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.
Spent some more time debugging this. Looks like the module resolution was starting from core/test
folder since jest was declared as global in core/test/jest.setup-after-env.js
So, ../util/paths
would work but not ../../util/paths
.
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.
Okay. Tried both unstable_mockModule
and jest.mock('../util/paths')
both which resolve correctly but do not mock implementations for some reason.
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.
Update: this is a huge pain, I'm exploring migrating to Vitest 😆
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.
🥲 Agree!!!
BTW, can i help in some way? I have some experience with migrating jest to vitest.
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.
That would be great, actually! Do you think you'd be able to create a basic vitest setup? It could be on this branch, and it would be used to run LocalPlatformClient.test.ts. Once this proof of concept works we can migrate other tests to vitest.
This would also require adding an extra step here: https://github.com/continuedev/continue/blob/main/.github/workflows/pr_checks.yaml
Let me know what you think!
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.
implemented!
- vitest works nicely (and with mocks) 🥳
- added vitest running for LocalPlatformClient only in pr_check.yaml
Edit: Should I draft another PR to migrate core tests to vitest?
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.
Edit: Should I draft another PR to migrate core tests to vitest?
Yeah, that would be great. It's one of our more important tasks at the moment.
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.
Thanks! Great job and thanks for introducing vitest.
Edit: Should I draft another PR to migrate core tests to vitest?
I'd love that, it's very high on our priority list.
Description
Fetch secrets from /.continue/.env file before fetching from workspace .env
So now the order of fetching the first env file is
~/.continue/.env, <workspace>/.continue/.env, <workspace>/.env
https://discord.com/channels/1108621136150929458/1355378099004379248/1367363239792476211
Checklist
Screenshots
[ For visual changes, include screenshots. Screen recordings are particularly helpful, and appreciated! ]
Testing instructions