-
-
Notifications
You must be signed in to change notification settings - Fork 5
Add Windows Support to Performance Wesley's Test Runner #45
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
base: main
Are you sure you want to change the base?
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.
Overall I think my biggest issue is that this does a ton of non-windows support things. It makes it difficulty to follow what is for the stated goal and what is refactors (maybe some good and worthy ones, but hard to tell all mixed together). I think most of my comments are about that, but I probably have a few nitpicks as well once we can get a PR that does just the one thing.
@@ -1,3 +1,5 @@ | |||
#!/usr/bin/env node |
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 file is not intended to be called directly. I see how it is paired with removing the .sh
file but that is not going to work for this. Take a look at how npm
does this, I would prefer we take a similar approach: https://github.com/npm/cli/tree/latest/bin
Specifically because I want to be able to pass flags to node, and you cannot do that without a wrapper script.
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 didn't want to break Unix while ensuring Windows compatibility. It's good that I learned this. I'll remove this line.
main().catch((error) => { | ||
console.error('CLI error:', error.message); | ||
process.exit(1); | ||
}); |
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 am not clear on how these changes in resolve windows compatibility. Can you help me understand them better?
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's not directly Windows compatibility change, but to understand problems helped me to catch errors.
}, | ||
"bin": { | ||
"expf": "./bin/expf.sh" | ||
"expf": "./bin/expf.mjs" |
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.
Just commenting here to connect the dots to the other comment. We need to keep entry scripts that allow specifying node options. We may not need something as complicated as what npm
does, but we at least need to keep the shell script wrappers.
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.
May I don't understand this perfectly. when we put sh file to bin, is that someway npm handles it?
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.
All npm
and the various package managers do is create links from node_modules/.bin/expf -> node_modules/@expressjs/perf-cli/bin/expf.sh
. So it can be any type of executable.
@@ -0,0 +1,2 @@ | |||
.dd_key | |||
.do_key |
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 removed these, must need to rebase this branch?
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'll
EOF | ||
RUN npm install -g @mmarchini/observe@^3.0.0 && \ | ||
chown -R node:node /usr/local/lib/node_modules && \ | ||
chown -R node:node /usr/local/bin/observe |
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.
IIRC I did this because there is an error mode that makes this form harder to debug. Is this required for windows compat 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.
From mine bash knownledge, it's for doing multi-line command execution in one time, so should not difference in runtime. but if causes an error ofc we can use EOF.
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 is not that it causes an error. IIRC I broke them apart because when there is an error the message is harder to read and debug.
@@ -1,76 +1,51 @@ | |||
import { execFile } from 'node:child_process'; |
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 file reads as a set of refactors, not things that are needed for windows compat. Can you help me follow what the goal is with these changes?
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.
Looks some of caused because of wrong conflict selection, like imports, in the other additions are mostly for logging. Need to fixed.
@@ -0,0 +1,129 @@ | |||
#!/usr/bin/env node |
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.
Honestly it was files like this that I expected to see, would you be able to extract just the changes that make the local file stuff use JS instead of bash into a new PR? That would really help make this stuff easier to review and land.
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 can try in a new branch with re-fix windows compatibility with current codes with just change most less code, like core sh files to js that not in docker.
const execAsync = async (cmd, opts) => { | ||
console.log(`Executing: ${cmd}`); | ||
return promisify(exec)(cmd, opts); | ||
}; |
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 function is unnecessary. Just wrap exec once at the top level.
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 agree, that's is just for more logging to better understand problems and fix them.
} else { | ||
// Linux - usually runs as a service | ||
try { | ||
await execAsync('sudo systemctl start docker'); |
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.
We should not ever call sudo
. I get what you are doing here, but if the script does not have the ability to start docker without sudo then we should not start it ourselves.
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's a good point that I don't thought before, we should not use sudo.
@@ -0,0 +1,366 @@ | |||
#!/usr/bin/env node |
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 file does not need to be re-written. The container is always linux and thus everything going on in that container will be cross-system compatible.
If you want to make the case that bash is harder to deal with than JS, then lets discuss that in a thread dedicated to the topic, but I would like to see a PR that is JUST the changes that add windows compatibility.
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.
Actually the core reason why I made replaced all sh files to js one is a full convertion, but when I look now, I saw this is unnecessary. Only required sh files changes enought as you said.
As I said in the meeting, I agree with you. I was inspired by your approach in the CI-based perf-runner, but I solved problems.
I briefly reviewed your comments. Some of looking caused when I tried to resolve some conflicts, some of which were my fault. However, when I have more flexible time, I would like to review each comment thoroughly. These are just my thoughts. |
Summary
This PR adds Windows compatibility to the performance test runner script. Previously, the runner relied on Unix-specific shell commands, which prevented it from working on Windows. The following changes ensure the runner works cross-platform