Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/update_bindings_and_push_to_vulkan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ jobs:
RELEASE_VERSION: ${{ needs.versions.outputs.requested }}
run: |
set -euo pipefail
# A forced regeneration may also produce exactly the default branch.
# In that case there is no branch/PR to create or recover.
if [[ "$(git write-tree)" == "$(git rev-parse 'origin/master^{tree}')" ]]; then
echo 'Generated files already match master; no proposal needed.'
exit 0
fi
existing=$(gh pr list \
--repo "$DEPLOY_TARGET_REPO" \
--base master \
Expand Down
13 changes: 11 additions & 2 deletions scripts/test_publish_generated_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def race(repo, *args):


class PullRequestRecoveryTests(unittest.TestCase):
def run_step(self, existing):
def run_step(self, existing, unchanged=False):
workflow = (SCRIPT.parents[1] / '.github/workflows/'
'update_bindings_and_push_to_vulkan.yml').read_text()
step = workflow.split(' - name: Open pull request if missing\n', 1)[1]
Expand All @@ -139,14 +139,19 @@ def run_step(self, existing):
'if sys.argv[1:3] == ["pr", "list"]:\n'
' print(os.environ["GH_TEST_EXISTING"])\n')
gh.chmod(0o755)
fake_git = root / 'git'
fake_git.write_text('#!/usr/bin/env python3\nimport os, sys\n'
'print(os.environ["GH_TEST_TREE"] if sys.argv[1] == "write-tree" else "base")\n')
fake_git.chmod(0o755)
log = root / 'calls'
result = subprocess.run(['bash', '-c', shell], check=True,
capture_output=True, text=True,
env={**os.environ, 'PATH': str(root) + os.pathsep + os.environ['PATH'],
'GH_TEST_LOG': str(log), 'GH_TEST_EXISTING': existing,
'GH_TEST_TREE': 'base' if unchanged else 'candidate',
'BRANCH_NAME': BRANCH, 'DEPLOY_TARGET_REPO': 'fixture/module',
'RELEASE_VERSION': 'v1.4.366'})
return log.read_text().splitlines(), result.stdout
return log.read_text().splitlines() if log.exists() else [], result.stdout

def test_existing_pr_is_read_only(self):
calls, output = self.run_step('80')
Expand All @@ -157,6 +162,10 @@ def test_missing_pr_is_created_after_a_noop_push(self):
calls, _ = self.run_step('')
self.assertEqual(calls, ['pr list', 'pr create'])

def test_forced_regeneration_matching_master_does_not_create_a_pr(self):
calls, _ = self.run_step('', unchanged=True)
self.assertEqual(calls, [])


if __name__ == '__main__':
unittest.main()
Loading