-
Notifications
You must be signed in to change notification settings - Fork 523
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: Windows Support #429
base: 3.12
Are you sure you want to change the base?
Conversation
- Add Windows development instructions - Refactor links to the bottom - Fix formatting, grammar, and punctuation
Remove testing connection from local address, since this test could fail depending on firewall configuration
Note: |
@JeremyEastham please also make sure to run the tests with your modifications via github actions so that the failing PR check passes. |
Tests are failing now because I renamed |
try { | ||
hello(inetAddress.getHostAddress(), "3567"); | ||
if (!inetAddress.getHostAddress().equals("127.0.0.1")) { | ||
fail(); | ||
} | ||
} catch (ConnectException ignored) { | ||
} | ||
|
||
Utils.reset(); | ||
|
||
Utils.setValueInConfig("host", "\"127.0.0.1\""); | ||
hello("localhost", "3567"); | ||
hello("127.0.0.1", "3567"); | ||
try { | ||
hello(inetAddress.getHostAddress(), "3567"); | ||
if (!inetAddress.getHostAddress().equals("127.0.0.1")) { | ||
fail(); | ||
} | ||
} catch (ConnectException ignored) { | ||
} |
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.
Why are we removing these tests cases?
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.
This test was failing because the core was not visible to any of my local IP addresses when hosted on localhost due to my firewall settings. This may also be related to how Windows handles localhost addresses, but documentation is sparse on this issue.
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 see. I would require these tests to be there.. Maybe we can change the code here to not run if the OS is windows?
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 thought about that, but wouldn't the situation be similar on other operating systems as well? If settings are strict (as they probably should be), access to localhost servers would not be visible to LAN addresses.
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 has more or less worked with all linux based systems, mac, CICD, GitHub action and everyone in our dev team.. so i don't think it's too much of a problem. I just want this to also run in CICD / GH action pipeline. It would be OK to have them skipped in local dev env.
String find = "\r?\n#?\\s*" + Pattern.quote(key) + ":.*\r?\n"; | ||
String replace = newLine + key + ": " + value + newLine; |
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.
Do we need to change the regex expression? The older one worked just fine. Did the older one cause issues in windows?
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, this change is necessary.
Old Regex: "\n((#\\s)?)" + key + "(:|((:\\s).+))\n"
New Regex: "\r?\n#?\\s*" + Pattern.quote(key) + ":.*\r?\n"
Issues with the Old Regex:
- It used
\n
instead of\r?\n
, which did not match Windows line endings (\r\n
) - It only matched comments with a single whitespace character after it
- It did not match non-commented keys with leading whitespace
- It was also much harder to read due to unnecessary group nesting and the unnecessary
|
operator - It did not quote the key, so any regex characters in the key would make it fail
When reviewing this, I actually noticed one issue with the New Regex. It did not match commented lines with leading whitespace. I have committed this change.
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. So this change would be required in the plugins repos as well. Since they too have a similar function in there.
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, I see. I was thinking that the plugin repos called io.supertokens.test.Utils.commentConfigValue()
and io.supertokens.test.Utils.setValueInConfig()
directly.
I was also thinking about renaming setValueInConfig()
to setConfigValue()
to match commentConfigValue()
. If I rename all references in supertokens-core
, will any change be needed in other repositories?
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.
You should change them in the plugin repos too, just to be consistent.
Summary of Change
Trying to contribute to this project has been a challenge to set up on Windows. The purpose of this PR is to streamline the project setup process for other developers that use Windows on their development machine. I have fixed a number of Windows-specific bugs and added extensive Windows development setup instructions to
CONTRIBUTING.md
(for both Git Bash and WSL2).Before starting work on this PR, only 87% of tests were passing when run on Windows via Git Bash. I chose to use Git Bash because it uses the native Windows version of Java at runtime, while still being able to execute the bash scripts in
supertokens-root
. It was important to me that the native Windows version of Java was used so that I could make sure that all core functionality remained intact when the core was run on a Windows machine. Many of the tests were failing due to bugs inUtils.java
, which did not useSystem.lineSeparator()
correctly when mocking config values. Additionally, a few tests compared exception message strings that were not identical cross-platform.Related Issues
(no related issues)
Test Plan
I have removed a portion of
WebserverTest.differentHostNameTest()
. This test was failing because the core was not visible to any of my local IP addresses when hosted onlocalhost
due to my firewall settings. Thus, it was not an issue with the code, but instead, an issue with the test. This may be related to how Windows handleslocalhost
addresses, but documentation is sparse on this issue.The purpose of this PR is not to add functionality, so no tests have been added.
Documentation Changes
(no changes needed)
Checklist for important updates
coreDriverInterfaceSupported.json
file has been updated (if needed)pluginInterfaceSupported.json
file has been updated (if needed)build.gradle
build.gradle
, please make sure to add them inimplementationDependencies.json
.git tag
) in the formatvX.Y.Z
, and then find the latest branch (git branch --all
) whoseX.Y
is greater than the latest released tag.Remaining TODOs for this PR
CONTRIBUTING.md
if neededCONTRIBUTING.md
are dependent on these run configurations existing./startTestEnv
instead of./startTestingEnv
which is included in this PR