Skip to content

Commit 6d3d43b

Browse files
authored
Merge pull request #4 from dsp-testing/update-v2.1.9-8aff92c5
Merge main into releases/v2
2 parents 1ed1437 + 5c7e3cc commit 6d3d43b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+285
-116
lines changed

.github/update-release-branch.py

+35-18
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@
1919
# Value of the mode flag for a v2 release
2020
V2_MODE = 'v2-release'
2121

22+
SOURCE_BRANCH_FOR_MODE = { V1_MODE: 'releases/v2', V2_MODE: 'main' }
23+
TARGET_BRANCH_FOR_MODE = { V1_MODE: 'releases/v1', V2_MODE: 'releases/v2' }
24+
2225
# Name of the remote
2326
ORIGIN = 'origin'
2427

2528
# Runs git with the given args and returns the stdout.
26-
# Raises an error if git does not exit successfully.
27-
def run_git(*args):
29+
# Raises an error if git does not exit successfully (unless passed
30+
# allow_non_zero_exit_code=True).
31+
def run_git(*args, allow_non_zero_exit_code=False):
2832
cmd = ['git', *args]
2933
p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
30-
if (p.returncode != 0):
34+
if not allow_non_zero_exit_code and p.returncode != 0:
3135
raise Exception('Call to ' + ' '.join(cmd) + ' exited with code ' + str(p.returncode) + ' stderr:' + p.stderr.decode('ascii'))
3236
return p.stdout.decode('ascii')
3337

@@ -36,7 +40,9 @@ def branch_exists_on_remote(branch_name):
3640
return run_git('ls-remote', '--heads', ORIGIN, branch_name).strip() != ''
3741

3842
# Opens a PR from the given branch to the target branch
39-
def open_pr(repo, all_commits, source_branch_short_sha, new_branch_name, source_branch, target_branch, conductor, is_v2_release, labels):
43+
def open_pr(
44+
repo, all_commits, source_branch_short_sha, new_branch_name, source_branch, target_branch,
45+
conductor, is_v2_release, labels, conflicted_files):
4046
# Sort the commits into the pull requests that introduced them,
4147
# and any commits that don't have a pull request
4248
pull_requests = []
@@ -81,6 +87,10 @@ def open_pr(repo, all_commits, source_branch_short_sha, new_branch_name, source_
8187

8288
body.append('')
8389
body.append('Please review the following:')
90+
if len(conflicted_files) > 0:
91+
body.append(' - [ ] You have amended the merge commit appearing in this branch to resolve ' +
92+
'the merge conflicts in the following files:')
93+
body.extend([f' - [ ] `{file}`' for file in conflicted_files])
8494
body.append(' - [ ] The CHANGELOG displays the correct version and date.')
8595
body.append(' - [ ] The CHANGELOG includes all relevant, user-facing changes since the last release.')
8696
body.append(' - [ ] There are no unexpected commits being merged into the ' + target_branch + ' branch.')
@@ -191,8 +201,10 @@ def main():
191201
type=str,
192202
required=True,
193203
choices=[V2_MODE, V1_MODE],
194-
help=f"Which release to perform. '{V2_MODE}' uses main as the source branch and v2 as the target branch. " +
195-
f"'{V1_MODE}' uses v2 as the source branch and v1 as the target branch."
204+
help=f"Which release to perform. '{V2_MODE}' uses {SOURCE_BRANCH_FOR_MODE[V2_MODE]} as the source " +
205+
f"branch and {TARGET_BRANCH_FOR_MODE[V2_MODE]} as the target branch. " +
206+
f"'{V1_MODE}' uses {SOURCE_BRANCH_FOR_MODE[V1_MODE]} as the source branch and " +
207+
f"{TARGET_BRANCH_FOR_MODE[V1_MODE]} as the target branch."
196208
)
197209
parser.add_argument(
198210
'--conductor',
@@ -203,14 +215,8 @@ def main():
203215

204216
args = parser.parse_args()
205217

206-
if args.mode == V2_MODE:
207-
source_branch = 'main'
208-
target_branch = 'v2'
209-
elif args.mode == V1_MODE:
210-
source_branch = 'v2'
211-
target_branch = 'v1'
212-
else:
213-
raise ValueError(f"Unexpected value for release mode: '{args.mode}'")
218+
source_branch = SOURCE_BRANCH_FOR_MODE[args.mode]
219+
target_branch = TARGET_BRANCH_FOR_MODE[args.mode]
214220

215221
repo = Github(args.github_token).get_repo(args.repository_nwo)
216222
version = get_current_version()
@@ -246,10 +252,15 @@ def main():
246252
# Create the new branch and push it to the remote
247253
print('Creating branch ' + new_branch_name)
248254

255+
# The process of creating the v1 release can run into merge conflicts. We commit the unresolved
256+
# conflicts so a maintainer can easily resolve them (vs erroring and requiring maintainers to
257+
# reconstruct the release manually)
258+
conflicted_files = []
259+
249260
if args.mode == V1_MODE:
250-
# If we're performing a backport, start from the v1 branch
251-
print(f'Creating {new_branch_name} from the {ORIGIN}/v1 branch')
252-
run_git('checkout', '-b', new_branch_name, f'{ORIGIN}/v1')
261+
# If we're performing a backport, start from the target branch
262+
print(f'Creating {new_branch_name} from the {ORIGIN}/{target_branch} branch')
263+
run_git('checkout', '-b', new_branch_name, f'{ORIGIN}/{target_branch}')
253264

254265
# Revert the commit that we made as part of the last release that updated the version number and
255266
# changelog to refer to 1.x.x variants. This avoids merge conflicts in the changelog and
@@ -274,7 +285,12 @@ def main():
274285
print(' Nothing to revert.')
275286

276287
print(f'Merging {ORIGIN}/{source_branch} into the release prep branch')
277-
run_git('merge', f'{ORIGIN}/{source_branch}', '--no-edit')
288+
# Commit any conflicts (see the comment for `conflicted_files`)
289+
run_git('merge', f'{ORIGIN}/{source_branch}', allow_non_zero_exit_code=True)
290+
conflicted_files = run_git('diff', '--name-only', '--diff-filter', 'U').splitlines()
291+
if len(conflicted_files) > 0:
292+
run_git('add', '.')
293+
run_git('commit', '--no-edit')
278294

279295
# Migrate the package version number from a v2 version number to a v1 version number
280296
print(f'Setting version number to {version}')
@@ -317,6 +333,7 @@ def main():
317333
conductor=args.conductor,
318334
is_v2_release=args.mode == V2_MODE,
319335
labels=['Update dependencies'] if args.mode == V1_MODE else [],
336+
conflicted_files=conflicted_files
320337
)
321338

322339
if __name__ == '__main__':

.github/workflows/__analyze-ref-input.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__debug-artifacts.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__extractor-ram-threads.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__go-custom-queries.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__go-custom-tracing-autobuild.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__go-custom-tracing.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__javascript-source-root.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__ml-powered-queries.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__multi-language-autodetect.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__packaging-config-inputs-js.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__packaging-config-js.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__packaging-inputs-js.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__remote-config.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__rubocop-multi-language.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__split-workflow.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__test-autobuild-working-dir.yml

+67
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__test-local-codeql.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__test-proxy.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__test-ruby.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/__unset-environment.yml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)