-
Notifications
You must be signed in to change notification settings - Fork 83
chore: detect build systems #4725
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
Conversation
|
|
67e2a0a to
6821698
Compare
|
Maybe you can add this one for the detection as well? https://moonrepo.dev/docs/setup-workspace |
580b1b3 to
d3f0a88
Compare
lukasholzer
left a comment
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.
Can you maybe add some test cases that would reflect a monorepo setup like:
const cwd = mockFileSystem({
'frontend/WORKSPACE': '',
'frontend/BUILD.bazel': '',
'frontend/apps/my-app/BUILD.bazel': '',
})and the baseDirectory is set to frontend/apps/my-app
like in monorepos (where build systems are used) it's mostly a baseDirectory and you don't search in the repo root. This should test the look up functionality.
Currently you only test the happy path from the workspace root. But often we don't know the workspace root as the repo root does not need to be the workspace root.
The repo root can contain no reference to JS projects at all and is somewhere in the baseDirectory.
| 'packages/server/server.js': '', | ||
| }) | ||
|
|
||
| const buildSystems = await detectBuildSystems('packages/website', cwd) |
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 think the values that are passed here are absolute 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.
What we pass as arguments here makes no difference sincegetContext resolves the absolute paths.
build/packages/build-info/src/context.ts
Lines 36 to 44 in 34b80c6
| const { projectDir = cwd(), rootDir = '' } = config | |
| // Get the absolute dirs for both project and root | |
| // We resolve the projectDir from the rootDir | |
| const absoluteProjectDir = resolve(rootDir, projectDir) | |
| // If a relative absolute path is given we rely on cwd | |
| const absoluteRootDir = rootDir ? resolve(cwd(), rootDir) : undefined | |
| // We only pass through the root dir if it was provided and is actually different | |
| // from the project dir | |
| const validRootDir = absoluteRootDir && absoluteRootDir !== absoluteProjectDir ? absoluteRootDir : undefined |
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.
But inside get-build-info.ts we are passing different values (so the tests are run with wrong data that is not used in production) Therefore we should change it to reflect the reality.
await detectBuildSystems(join(cwd, 'packages/website'), cwd)| 'packages/server/server.js': '', | ||
| }) | ||
|
|
||
| const buildSystems = await detectBuildSystems('packages/website', cwd) |
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.
But inside get-build-info.ts we are passing different values (so the tests are run with wrong data that is not used in production) Therefore we should change it to reflect the reality.
await detectBuildSystems(join(cwd, 'packages/website'), cwd)
I don't understand what you mean by wrong data here. |
In your test the function getting called with the following parameters: const buildSystems = await detectBuildSystems('packages/website', cwd)
BUT in production it get's called with different data because there it get's called with absolute paths:
So your testcase does not reflect production data that's what I'm saying here |
lukasholzer
left a comment
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 good to me!

π Thanks for submitting a pull request! π
Summary
Fixes #928
For us to review and ship your PR efficiently, please perform the following steps:
we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
something that`s on fire π₯ (e.g. incident related), you can skip this step.
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)