-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
packages/turbo-ignore/index.js
Outdated
@@ -1,16 +1,15 @@ | |||
#!/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.
Converting this whole package to TS will also be a part of my "more tests" work
packages/turbo-ignore/utils.js
Outdated
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^"; | ||
} |
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 the main change here
} | ||
} | ||
|
||
export function getTurboRoot(): string | null { |
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 we make this take cwd
as an argument?
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 wouldn't block on this. Also, this script runs from the project folder directory on PaaS's
packages/turbo-ignore/package.json
Outdated
"tsup": "^5.12.1" | ||
} | ||
"execa": "5.1.1", | ||
"fs-extra": "^10.1.0", |
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 we're not using fs-extra
?
"fs-extra": "^10.1.0", |
console.error( | ||
`\u226B Failed to parse JSON output from \`${command}\`.` | ||
); | ||
console.error(`\u226B Proceeding with build to be safe...`); |
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.
console.error(`\u226B Proceeding with build to be safe...`); | |
console.error(`\u226B Exiting with an error to indicate a build should be performed.`); |
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 this is impl detail. I prefer the original tbh
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.
Agreed
packages.length - 1 | ||
} dependencies` | ||
); | ||
console.log(`\u226B Proceeding with build...`); |
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.
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...`); |
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.
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"); |
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.
console.log("\u226B Ignoring the change"); | |
console.log("\u226B This build can be ignored."); |
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 like the active voice here
|
||
try { | ||
const parsed = JSON.parse(stdout); | ||
if (parsed == null) { |
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 looks like a TypeScript bug catch. 👍 JSON.parse(null)
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>
bd8f678
to
0a8e46a
Compare
Updated to turbo-ignore to be aware of the
$VERCEL_GIT_PREVIOUS_SHA