Skip to content
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(turbo-ignore): update to support vercel CI #1578

Merged
merged 10 commits into from
Jul 26, 2022
Merged

feat(turbo-ignore): update to support vercel CI #1578

merged 10 commits into from
Jul 26, 2022

Conversation

tknickman
Copy link
Member

Updated to turbo-ignore to be aware of the $VERCEL_GIT_PREVIOUS_SHA

@vercel
Copy link

vercel bot commented Jul 25, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
turbo-site ⬜️ Ignored (Inspect) Jul 26, 2022 at 6:57PM (UTC)

@@ -1,16 +1,15 @@
#!/usr/bin/env node
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting this whole package to TS will also be a part of my "more tests" work

packages/turbo-ignore/index.js Show resolved Hide resolved
Comment on lines 52 to 69
export function getComparison() {
if (process.env.VERCEL === "1") {
if (process.env.VERCEL_GIT_PREVIOUS_SHA) {
// use the commit SHA of the last successful deployment for this project / branch
console.log("\u226B Found previous deployment for project");
return process.env.VERCEL_GIT_PREVIOUS_SHA;
} else {
// this is either the first deploy of the project, or the first deploy for the branch
// either way - build it.
console.log(
`\u226B No previous deployments found for this project on "${process.env.VERCEL_GIT_COMMIT_REF}"`
);
console.log(`\u226B Proceeding with build...`);
process.exit(1);
}
}
return "HEAD^";
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change here

packages/turbo-ignore/index.js Outdated Show resolved Hide resolved
packages/turbo-ignore/package.json Outdated Show resolved Hide resolved
packages/turbo-ignore/utils.js Outdated Show resolved Hide resolved
packages/turbo-ignore/utils.js Outdated Show resolved Hide resolved
packages/turbo-ignore/utils.js Outdated Show resolved Hide resolved
packages/turbo-ignore/utils.js Outdated Show resolved Hide resolved
packages/turbo-ignore/utils.js Outdated Show resolved Hide resolved
packages/turbo-ignore/utils.js Outdated Show resolved Hide resolved
packages/turbo-ignore/utils.js Outdated Show resolved Hide resolved
packages/turbo-ignore/utils.js Outdated Show resolved Hide resolved
packages/turbo-ignore/tsconfig.json Outdated Show resolved Hide resolved
packages/turbo-ignore/src/utils.ts Outdated Show resolved Hide resolved
packages/turbo-ignore/package.json Show resolved Hide resolved
}
}

export function getTurboRoot(): string | null {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this take cwd as an argument?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't block on this. Also, this script runs from the project folder directory on PaaS's

packages/turbo-ignore/src/utils.ts Outdated Show resolved Hide resolved
packages/turbo-ignore/README.md Outdated Show resolved Hide resolved
packages/turbo-ignore/package.json Outdated Show resolved Hide resolved
"tsup": "^5.12.1"
}
"execa": "5.1.1",
"fs-extra": "^10.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're not using fs-extra?

Suggested change
"fs-extra": "^10.1.0",

console.error(
`\u226B Failed to parse JSON output from \`${command}\`.`
);
console.error(`\u226B Proceeding with build to be safe...`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.error(`\u226B Proceeding with build to be safe...`);
console.error(`\u226B Exiting with an error to indicate a build should be performed.`);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is impl detail. I prefer the original tbh

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

packages.length - 1
} dependencies`
);
console.log(`\u226B Proceeding with build...`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(`\u226B Proceeding with build...`);
console.log(`\u226B Exiting with an error to indicate a build should be performed.`);

} catch (e) {
console.error(`\u226B Failed to parse JSON output from \`${command}\`.`);
console.error(e);
console.error(`\u226B Proceeding with build to be safe...`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.error(`\u226B Proceeding with build to be safe...`);
console.error(`\u226B Exiting with an error to indicate a build should be performed.`);

console.log(
"\u226B This project and its dependencies are not affected"
);
console.log("\u226B Ignoring the change");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log("\u226B Ignoring the change");
console.log("\u226B This build can be ignored.");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the active voice here


try {
const parsed = JSON.parse(stdout);
if (parsed == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a TypeScript bug catch. 👍 JSON.parse(null)

jaredpalmer and others added 6 commits July 26, 2022 11:20
Co-authored-by: Nathan Hammond <nathan.hammond@vercel.com>
Co-authored-by: Nathan Hammond <nathan.hammond@vercel.com>
Co-authored-by: Nathan Hammond <nathan.hammond@vercel.com>
@nathanhammond nathanhammond added the pr: automerge Kodiak will merge these automatically after checks pass label Jul 26, 2022
@kodiakhq kodiakhq bot merged commit cc4fb4f into main Jul 26, 2022
@tknickman tknickman deleted the turbo_ignore branch July 26, 2022 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: automerge Kodiak will merge these automatically after checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants