[DENG-11139] Add CI workflow to generate schema diff#317
Conversation
|
Generated schema diff: 9ad40bb |
|
Generated schema diff: 620387f |
|
Generated schema diff: 44b53a1 |
| # the dst name encodes the revision, we should always be able to use the | ||
| # first 6 characters to find commit in the repository. | ||
| assert repo.rev_parse(dst.name[:6]) == repo.head.commit | ||
| assert repo.rev_parse(dst.name) == repo.head.commit |
There was a problem hiding this comment.
There is a hash collision with the current latest generated-schemas commit so switching this to the full hash. It doesn't need to be readable anyway
in m-p-s git cat-file -t b5327b:
error: short object ID b5327b is ambiguous
hint: The candidates are:
hint: b5327b512 commit 2026-05-15 - Auto-push from schema generation [ci skip]
hint: b5327b07a tree
fatal: Not a valid object name b5327b
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| # Start the diff branch from an empty tree so it doesn't have any history | ||
| git checkout --orphan "$DIFF_BRANCH" | ||
| git rm -rf . > /dev/null 2>&1 || true | ||
| git clean -fdx | ||
|
|
||
| # Commit 1: schemas generated from main | ||
| mkdir -p schema_out | ||
| cp -r /tmp/main-schemas/. schema_out/ | ||
| git add schema_out | ||
| git commit --allow-empty -m "PR #${PR_NUMBER}: generated schemas from main (${MAIN_SHA:0:8})" | ||
|
|
||
| # Commit 2: schemas generated from PR head | ||
| rm -rf schema_out | ||
| mkdir -p schema_out | ||
| cp -r /tmp/pr-schemas/. schema_out/ | ||
| git add -A schema_out | ||
| git commit --allow-empty -m "PR #${PR_NUMBER}: generated schemas from ${PR_HEAD_SHA:0:8}" | ||
|
|
||
| git push --force origin "$DIFF_BRANCH" | ||
|
|
||
| DIFF_COMMIT_SHA=$(git rev-parse HEAD) | ||
| echo "diff_commit_sha=$DIFF_COMMIT_SHA" >> "$GITHUB_OUTPUT" | ||
| { | ||
| echo "## Generated Schema Diff Branch" | ||
| echo "" | ||
| echo "Pushed to [\`$DIFF_BRANCH\`](https://github.com/${GITHUB_REPOSITORY}/tree/${DIFF_BRANCH})." | ||
| echo "" | ||
| echo "View this PR's schema changes: [commit ${DIFF_COMMIT_SHA:0:7}](https://github.com/${GITHUB_REPOSITORY}/commit/${DIFF_COMMIT_SHA})" | ||
| } >> "$GITHUB_STEP_SUMMARY" |
There was a problem hiding this comment.
If there are multiple PRs running can they overwrite each others changes on the branch?
There was a problem hiding this comment.
They get overwritten since the branch only ever contains the latest two commits, but it still works because it's a single push with both commits. The commits don't need to be on the branch to view the diff, it will just show This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://mozilla-hub.atlassian.net/browse/DENG-11139
Also noticed that this closes #216
Generates schemas using the PR branch and main if there are potential changes and then commits them to a new branch so the diff can be viewed since doing this manually is tedious. example
I decided to rely on the
added a commit that referenced this pull requestnotification instead of posting a comment each time to reduce noise.