Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

EVG-20677 & EVG-20868: Make type.ts validation more robust #2038

Merged
merged 5 commits into from
Sep 18, 2023

Conversation

SupaJoon
Copy link
Contributor

@SupaJoon SupaJoon commented Sep 13, 2023

EVG-20677
EVG-20868

Description

EVG-20677 was solved by not erroring on code 128 from git merge-base --is-ancestor. All it means is that the commit has never been fetched by the developers git program.
EVG-20868 contains an overview of the rest of the code changes.
I made sure to fail the script only if types.ts is verified as stale. I pass the script for all other errors for the sake of developer productivity and also because this validation overlaps with check_codegen.
I used git mv for diff-local-schema-with-remote -> check-schema-and-codegen but GitHub didn't do a good job at lining up the diff 😬 .

@SupaJoon SupaJoon requested a review from a team September 13, 2023 21:01
@cypress
Copy link

cypress bot commented Sep 13, 2023

Passing run #12749 ↗︎

0 577 7 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

add doc link
Project: Spruce Commit: 09ec59dc0e
Status: Passed Duration: 17:25 💡
Started: Sep 18, 2023 3:07 PM Ended: Sep 18, 2023 3:24 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@@ -3,35 +3,35 @@ import path from "path";

export const getConfig = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I know this was here but do you know why this is exported twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first export is the util function and the second export is the output of the util function. Although it's not stated explicitly in the docs graphql-codegen --config codegen.ts needs a default export from codegen.ts with the parameters applied.

Comment on lines 14 to 29
/**
* Checks if a given domain can be resolved.
* @async
* @param domain - The domain name to check.
* @returns - Resolves to `true` if the domain can be resolved, `false` otherwise.
*/
export const canResolveDNS = (domain: string) =>
new Promise((resolve) => {
dns.lookup(domain, (err) => {
if (err) {
resolve(false);
} else {
resolve(true);
}
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary? We can avoid this request by just checking if the fetch request returned the same error.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea!

* @returns A Promise that resolves to the SHA of the latest commit.
* @throws {Error} When failed to fetch commits.
*/
export async function getLatestCommitFromRemote(): Promise<string> {
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 use arrow syntax for consistency?

return true;
} catch (error) {
process.chdir(originalDir);
if (error.status === 1 || error.status === 128) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be helpful to comment on what these statuses represent or extract them into named constants.

@SupaJoon SupaJoon requested a review from khelif96 September 14, 2023 16:49
@@ -64,6 +47,7 @@ export const checkIsAncestor = async (commit: string): Promise<boolean> => {
return true;
} catch (error) {
process.chdir(originalDir);
// Error status 1 and 128 means that the commit is not an anecestor and the user must fetch.
Copy link
Contributor

Choose a reason for hiding this comment

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

I discussed this offline but would love to see a reference to this here. Just so its easy to differentiate between what 1 and 128 means.

@SupaJoon SupaJoon added this pull request to the merge queue Sep 18, 2023
Merged via the queue into evergreen-ci:main with commit 7cb1622 Sep 18, 2023
2 checks passed
@SupaJoon SupaJoon deleted the EVG-20868 branch September 18, 2023 15:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants