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

Don't hit GitHub API for schema comparisons #933

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

blampe
Copy link
Contributor

@blampe blampe commented May 17, 2024

We don't need to query the GitHub API for the original schema because we already have it in git history.

The latest schema-tools supports reading from disk instead of fetching from GitHub. This changes the job to drop the original schema into a temporary location and use that for comparison.

actions/checkout gives us a shallow merge commit. To compute the original schema, we use git apply --reverse to construct the schema as it existed before our merge.

Requires a schema-tools release to work.

Fixes pulumi/schema-tools#64.

Copy link
Member

@danielrbradley danielrbradley left a comment

Choose a reason for hiding this comment

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

As of recently, we've stopped checking out the entire repository as this is a slow operation for some providers to do in every step. We need to ensure this change works with a shallow clone as downloading the whole git history is slower than fetching the single file.

@@ -553,12 +553,10 @@ export function CheckSchemaChanges(provider: string): Step {
if: "github.event_name == 'pull_request'",
name: "Check Schema is Valid",
run:
"git show ${{ github.event.repository.default_branch }}:provider/cmd/pulumi-resource-${{ env.PROVIDER }}/schema.json > ${{ runner.temp }}/schema.json;\n" +
Copy link
Member

Choose a reason for hiding this comment

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

Will this work when we only have a shallow clone of the repository? Does the shallow clone include the default_branch?

Copy link
Member

@danielrbradley danielrbradley left a comment

Choose a reason for hiding this comment

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

As an alternative, I'd suggest adding the complexity to the schema-tools to check if the base is available in git directly, then falling back to the github API if it's a shallow clone.

@blampe blampe marked this pull request as draft June 20, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

schema-tools exceed GitHub rate limit
2 participants