Skip to content

[DENG-11139] Add CI workflow to generate schema diff#317

Merged
BenWu merged 4 commits into
mainfrom
benwu/diff-changes
May 19, 2026
Merged

[DENG-11139] Add CI workflow to generate schema diff#317
BenWu merged 4 commits into
mainfrom
benwu/diff-changes

Conversation

@BenWu

@BenWu BenWu commented May 14, 2026

Copy link
Copy Markdown
Collaborator

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 request notification instead of posting a comment each time to reduce noise.

@github-actions

Copy link
Copy Markdown

Generated schema diff: 9ad40bb

github-actions Bot added a commit that referenced this pull request May 15, 2026
github-actions Bot added a commit that referenced this pull request May 15, 2026
@github-actions

Copy link
Copy Markdown

Generated schema diff: 620387f

@github-actions

Copy link
Copy Markdown

Generated schema diff: 44b53a1

github-actions Bot added a commit that referenced this pull request May 15, 2026
github-actions Bot added a commit that referenced this pull request May 15, 2026
github-actions Bot added a commit that referenced this pull request May 15, 2026
# 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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

@BenWu BenWu marked this pull request as ready for review May 15, 2026 16:47
github-actions Bot added a commit that referenced this pull request May 15, 2026
github-actions Bot added a commit that referenced this pull request May 15, 2026
@BenWu BenWu requested a review from scholtzan May 15, 2026 16:56
github-actions Bot added a commit that referenced this pull request May 15, 2026
github-actions Bot added a commit that referenced this pull request May 15, 2026
@BenWu BenWu changed the title Add CI workflow to generate schema diff [DENG-11139] Add CI workflow to generate schema diff May 15, 2026
Comment on lines +132 to +163
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"

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.

If there are multiple PRs running can they overwrite each others changes on the branch?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

@BenWu BenWu requested a review from scholtzan May 15, 2026 22:07
@BenWu BenWu merged commit 566ecf8 into main May 19, 2026
7 checks passed
@BenWu BenWu deleted the benwu/diff-changes branch May 19, 2026 19:08
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.

Show a diff of any changes to generated schemas

2 participants