-
Notifications
You must be signed in to change notification settings - Fork 273
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
Custom garden dir path #823
Conversation
1819ed4
to
8daec3e
Compare
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 looks good, but requesting a few small changes + a couple of questions.
garden-service/src/cli/cli.ts
Outdated
if (this.fileWritersInitialized) { | ||
return | ||
} | ||
for (const config of FILE_WRITER_CONFIGS) { | ||
logger.writers.push( | ||
await FileWriter.factory({ | ||
level: logger.level, | ||
root: projectRoot, | ||
gardenDirPath, |
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 is a change in behaviour, right? Is it intentional?
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 you're right, there's a mistake there. However, we also store development and error logs under projectRoot/.garden/logs
so the gardenDirPath
is also needed there.
@@ -202,3 +209,7 @@ export async function prepareSystemServices( | |||
} | |||
} | |||
} | |||
|
|||
export function getSystemGardenDirPath(projectGardenDirPath: string) { |
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.
Feels unnecessary to break this out and export it, since it's used only once.
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.
Ah yes, this was originally used in more places. Forgot to clean up.
garden-service/src/cli/cli.ts
Outdated
@@ -283,7 +283,7 @@ export class GardenCli { | |||
|
|||
// Register log file writers. We need to do this after the Garden class is initialised because | |||
// the file writers depend on the project root. | |||
await this.initFileWriters(logger, garden.projectRoot) | |||
await this.initFileWriters(logger, garden.gardenDirPath) |
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.
If this is the intended change, the comment needs updating.
Also, we assume in at least a couple of places that the error.log
file, for example, gets written in the project root (look for references to ERROR_LOG_FILENAME
). We either need to track all those references down and update, or revert this particular 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.
Yeah you're right, this needs fixing, see my comment above.
garden-service/src/plugin-context.ts
Outdated
@@ -36,6 +38,12 @@ export const pluginContextSchema = Joi.object() | |||
projectRoot: Joi.string() | |||
.uri(<any>{ relativeOnly: true }) | |||
.description("The absolute path of the project root."), | |||
gardenDirPath: Joi.string() | |||
.uri(<any>{ relativeOnly: true }) |
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.
The relativeOnly
constraint isn't correct.
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.
Good catch. What about for the projectRoot
key above?
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.
Yep, same error 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.
Actually, my bad. I keep mixing these things up, this was fine as it was. But I don't think it actually matters here, this schema is more for documentation since we control the inputs directly.
}) | ||
|
||
describe("getExtSourcesDirName", () => { | ||
it("should return the relative path to the remote projects directory", () => { | ||
const dirName = getRemoteSourcesDirname("project") | ||
expect(dirName).to.equal(".garden/sources/project") | ||
expect(dirName).to.equal("sources/project") |
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.
Unsure if/how it really matters, but we should avoid hardcoding paths like this, and rather use join(...parts)
to make sure it works across platforms consistently.
Previously we hard coded the Garden dir path to `projectRoot/.garden`. With this change, it is possible to set a custom Garden dir path when initialising the Garden class. This is useful for system modules whose builds can now be stored at the project level.
8daec3e
to
a57a611
Compare
With this change, system module builds are stored at the project level. This way we can run several Garden processes at the same time without them all modifying the same system build directory, which can cause unexpected issues.
a57a611
to
33019b0
Compare
This PR contains two commits. The first is a refactor that allows setting a custom path for the project level Garden directory (i.e. the
.garden
directory). The second commit uses that ability when creating the system Garden class.From the commit message:
Previously we hard coded the Garden dir path to
projectRoot/.garden
.With this change, it is possible to set a custom Garden dir path when
initialising the Garden class. This is useful for system modules whose
builds can now be stored at the project level
The original motivation behind this is change is that integration tests were failing when they ran in parallel because different instances of Garden were modifying the same system level
.garden
directory at the same time.@thsig Could you please glance over the
build-dir.ts
changes. In particular this line: https://github.com/garden-io/garden/pull/823/files#diff-99aee768efe4263754433634f8cb56ebR130