-
Notifications
You must be signed in to change notification settings - Fork 73
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
DOP-4209 #958
DOP-4209 #958
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.
Okay, some of these comments are a little long, so please reach out if you have any questions!
repoName: string, | ||
projectName: string, | ||
baseUrl: string, | ||
buildDependencies: BuildDependencies, | ||
directory?: 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.
If we're not getting dependencies in this function anymore, can we rename this function? prepareBuild
could be fine by itself!
src/job/jobHandler.ts
Outdated
@throwIfJobInterupted() | ||
private async getBuildDependencies() { | ||
const buildDependencies = await this._repoBranchesRepo.getBuildDependencies(this.currJob.payload.repoName); | ||
const repoName = this.currJob.payload.repoName; | ||
const directory = this.currJob.payload.repoName === MONOREPO_NAME ? this.currJob.payload.directory : undefined; | ||
const buildDependencies = await this._repoBranchesRepo.getBuildDependencies(repoName, directory); | ||
if (!buildDependencies) return []; | ||
await this._logger.save(this._currJob._id, 'Identified Build dependencies'); | ||
return buildDependencies; | ||
} | ||
|
||
@throwIfJobInterupted() | ||
private async getAndBuildDependencies() { | ||
private async getAndDownloadBuildDependencies() { | ||
const repoName = this.currJob.payload.repoName; | ||
const directory = this.currJob.payload.repoName === MONOREPO_NAME ? this.currJob.payload.directory : undefined; | ||
const buildDependencies = await this.getBuildDependencies(); | ||
const commands = await downloadBuildDependencies(buildDependencies, this.currJob.payload.repoName); | ||
this._logger.save(this._currJob._id, commands.join('\n')); | ||
const commands = await downloadBuildDependencies(buildDependencies, this.currJob.payload.repoName, directory); | ||
await this._logger.save(this._currJob._id, `${commands.join('\n')}`); | ||
} |
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 can combine these again. The reason to separate is gone now, and also it would combine the redundancy of accessing the repoName and directory twice in quick succession.
README.md
Outdated
|
||
<<<<<<< HEAD | ||
`npm run debug -- -o 10gen -n 'cloud-docs'` | ||
======= | ||
`npm run debug -- -o 10gen -n cloud-docs` | ||
|
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.
nit: Make sure the merge finishes and gets rid of these characters
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.
Regarding the diff: The quotes are not necessary, but they are also not an issue. Either way is fine, but I would lean toward all the examples showing the same way for each input
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 noting here that this entire file has multiple unfinished merge flags to take care of!
@@ -19,7 +19,7 @@ export class WebhookEnvConstruct extends Construct { | |||
const ssmPrefix = getSsmPathPrefix(); | |||
const env = getEnv(); | |||
|
|||
const featureFlagMonorepoPath = StringParameter.valueFromLookup(this, `${ssmPrefix}/flag/monorepo_path`); | |||
const featureFlagMonorepoPath = StringParameter.valueFromLookup(this, `${ssmPrefix}/DOP-4127/flag/monorepo_path`); |
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 noting that this needs to be changed back before merge
@@ -50,7 +50,7 @@ export class WorkerEnvConstruct extends Construct { | |||
// doing this for the time being, but I think we don't need to necessarily retrieve this from ssm for feature branches, nor would we want to in that case | |||
const previewBuildEnabled = StringParameter.valueFromLookup(this, `${ssmPrefix}/flag/preview_build/enabled`); | |||
const featureFlagUpdatePages = StringParameter.valueFromLookup(this, `${ssmPrefix}/flag/update_pages`); | |||
const featureFlagMonorepoPath = StringParameter.valueFromLookup(this, `${ssmPrefix}/flag/monorepo_path`); | |||
const featureFlagMonorepoPath = StringParameter.valueFromLookup(this, `${ssmPrefix}/DOP-4127/flag/monorepo_path`); |
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.
Note to change back before merge
const commands: string[] = []; | ||
await Promise.all( | ||
buildDependencies.map(async (dependencyInfo) => { | ||
const repoDir = getRepoDir(repoName); | ||
const repoDir = directory ? getRepoDir(repoName, directory) : getRepoDir(repoName); |
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.
No need to do this conditional! The directory
argument can be undefined. You can simple state:
const repoDir = getRepoDir(repoName, directory);
await Promise.all( | ||
dependencyInfo.dependencies.map((dep) => { | ||
dependencyInfo.dependencies.map(async (dep) => { | ||
try { | ||
executeCliCommand({ | ||
command: 'curl', | ||
args: ['-SfL', dep.url, '-o', `${targetDir}/${dep.filename}`], | ||
args: ['--max-time', '10', '-SfL', dep.url, '-o', `${targetDir}/${dep.filename}`], | ||
options: options, | ||
}); | ||
} catch (error) { | ||
console.error( | ||
`ERROR! Could not curl ${dep.url} into ${targetDir}/${dep.filename}. Dependency information: `, | ||
dependencyInfo | ||
); | ||
return commands; | ||
} | ||
commands.push(`curl -SfL ${dep.url} -o ${targetDir}/${dep.filename}`); | ||
}) |
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.
Hmm, interesting thing here. I could be wrong, but I believe that because we're returning a static value (even though it's a Promise because of the async keyword) it can return before the executeCliCommand
function finishes.
I think this can be slightly changed to do what you're trying to do and cleaner too. If you take away the async
keyword and add return
keyword to the executeCliCommand
invocation that will ensure that the Promise.all waits for each Promise to finish. Then move the commands.push
line up into the try block before the return. Then you can completely delete the unused line return commands
. Doing this will ensure that the Node thread will not continue on until all of these commands have either finished or errored.
I have an example below.
Like this:
await Promise.all(
dependencyInfo.dependencies.map((dep) => {
try {
commands.push(`curl -SfL ${dep.url} -o ${targetDir}/${dep.filename}`);
return executeCliCommand({
command: 'curl',
args: ['--max-time', '10', '-SfL', dep.url, '-o', `${targetDir}/${dep.filename}`],
options: options,
});
} catch (error) {
console.error(
`ERROR! Could not curl ${dep.url} into ${targetDir}/${dep.filename}. Dependency information: `,
dependencyInfo
);
}
})
)
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.
These are all great points, @mmeigs. The one small nit with the example though is that we won't hit this catch block, I think. This is because we return the promise, but we don't await it, not giving the promise the opportunity to settle before the catch block can be entered.
I think we can add the async
back and do return await executeCliCommand...
so that it will wait for the promise to settle before returning.
This also has me thinking as well, do we want to do an allSettled
here maybe as well? That way, we can know all of the dependencies that are failing for whatever 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.
Testing this out with some incorrect curl links but this approach still doesn't seem to catch the error 😞
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.
Hmm, I wonder if doing return await executeCliCommand(...)
we try:
const cliResult = await executeCliCommand(...);
return cliResult;
in the try/catch? I wonder if return is sort of overwriting the await
in a sense
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 didn't work either 💔 i dropped a new ticket for this issue though!
We can ignore the failing |
@@ -63,36 +72,29 @@ export async function downloadBuildDependencies(buildDependencies: BuildDependen | |||
} | |||
commands.push(`mkdir -p ${targetDir}`); | |||
await Promise.all( |
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.
Note: I did not use allSettled
here because it seemed to not exist with this version of Javascript?
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 version of node are you using?
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.
v18.17.1!
I think I'm going to bump error logging in |
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 getting this working!
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.
LGTM!
DOP-4209
docs-monorepo/docs-mongodb-internal
was not building without makefiles for multiple reasons:repos_branches
did not take into consideration monorepo naming/directory structure, causing builds to just be pulling fromdocs-monorepo/cloud-docs
since that was the first monorepo entry to show up inrepos_branches
.These have since been fixed, however, and
docs-monorepo
projects should be able to build now! (shoutout to @branberry for the help!)