Skip to content

Don't hit GitHub API for schema comparisons - #933

Draft
blampe wants to merge 3 commits into
masterfrom
blampe/schema-compare
Draft

Don't hit GitHub API for schema comparisons#933
blampe wants to merge 3 commits into
masterfrom
blampe/schema-compare

Conversation

@blampe

@blampe blampe commented May 17, 2024

Copy link
Copy Markdown
Contributor

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.

@danielrbradley danielrbradley left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread native-provider-ci/src/steps.ts Outdated
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
Copy Markdown
Contributor

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?

@danielrbradley danielrbradley left a comment

Copy link
Copy Markdown
Contributor

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