Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CodeHealth] version_up command-line tool #27817

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cdesouza-chromium
Copy link
Collaborator

@cdesouza-chromium cdesouza-chromium commented Feb 26, 2025

This PR introduces a command line tool to assist with version upgrade tasks. This initial version supports the creation of the four basic changes necessary to get a new brave version building.

This script is capable of a) updating the version number for Chromium, b) perform basic conflict resolution, c) create the "Update Patches" change for the new version, d) create the "Updated strings" change.

This tool is being introduced as a starting point for making the daily "canary" tasks easier, as well as providing to provide more robust infra support for these tasks and for version bumps.

This tool is should be usuable both at CI and locally.

A basic run:

script/version_up.py --previous=origin/master --to=135.0.7035.1

Changes to .gitignore are being introduced as this local file is required when the tool has give up on conflict resolution and wait for the user to resolve them.

Resolves brave/brave-browser#44244

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@cdesouza-chromium cdesouza-chromium force-pushed the version-up-tool branch 2 times, most recently from dce6c5b to 7534f41 Compare February 26, 2025 14:07
@cdesouza-chromium cdesouza-chromium force-pushed the version-up-tool branch 4 times, most recently from 176bfc8 to a7bfafc Compare February 26, 2025 14:18
@cdesouza-chromium cdesouza-chromium force-pushed the version-up-tool branch 2 times, most recently from b770f9c to f19adad Compare February 26, 2025 17:26
@cdesouza-chromium cdesouza-chromium added the CI/skip Do not run CI builds (except noplatform) label Feb 26, 2025
@cdesouza-chromium
Copy link
Collaborator Author

Setting CI/skip label as we only need to run no-platform in this PR.

@cdesouza-chromium cdesouza-chromium force-pushed the version-up-tool branch 2 times, most recently from 6db60e8 to 2c8dc92 Compare February 27, 2025 15:26
import json
from pathlib import Path
import re
import subprocess
Copy link
Contributor

Choose a reason for hiding this comment

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

reported by reviewdog 🐶
[semgrep] Consider possible security implications associated with subprocess module.


Source: https://semgrep.dev/r/gitlab.bandit.B404


Cc @thypon @kdenhartog

_run_git('add', '-u', '*.patch')
"""
cmd = ['git'] + list(cmd)
return subprocess.check_output(cmd).strip().decode('utf-8')
Copy link
Contributor

Choose a reason for hiding this comment

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

reported by reviewdog 🐶
[semgrep] Python possesses many mechanisms to invoke an external executable. However,
doing so may present a security issue if appropriate care is not taken to
sanitize any user provided or variable input. This plugin test is part of a
family of tests built to check for process spawning and warn appropriately.
Specifically, this test looks for the spawning of a subprocess without the
use of a command shell. This type of subprocess invocation is not
vulnerable to shell injection attacks, but care should still be taken to
ensure validity of input.


Source: https://semgrep.dev/r/gitlab.bandit.B603


Cc @thypon @kdenhartog

@mkarolin mkarolin requested review from emerick and mkarolin February 27, 2025 16:08
text=True,
check=False)

# This is a regex to match the json output of the patches that failed to apply. No test was conduct regarding inner arrays.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really clear about this comment - it says that the pattern is to match failures, but then if it doesn't match anything we print 'No patches to apply'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This regex is merely used to check if JSON array list was produced because --print-patch-failures-in-json doesn't always produce a JSON summary, if nothing failed to apply.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure on the script name itself. Maybe we can use something more descriptive like chromium_version_update.py?

Copy link
Member

@goodov goodov Feb 28, 2025

Choose a reason for hiding this comment

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

I'd also recommend moving this script into //brave/tools/cr_rebase or some other dir in //brave/tools/.

we should stop adding new stuff into //brave/script, it's already a pile of everything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll leave this thread open for now to see if any more suggestions are provided.

This PR introduces a command line tool to assist with version upgrade
tasks. This initial version supports the creation of the four basic
changes necessary to get a new brave version building.

This script is capable of a) updating the version number for Chromium,
b) perform basic conflict resolution, c) create the "Update Patches"
change for the new version, d) create the "Updated strings" change.

This tool is being introduced as a starting point for making the daily
"canary" tasks easier, as well as providing to provide more robust infra
support for these tasks and for version bumps.

This tool is should be usuable both at CI and locally.

A basic run:

```
script/version_up.py --previous=origin/master --to=135.0.7035.1
```

Changes to `.gitignore` are being introduced as this local file is
required when the tool has give up on conflict resolution and wait for
the user to resolve them.

Resolves brave/brave-browser#44244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/skip Do not run CI builds (except noplatform) needs-security-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Basic command-line util for daily Chromium upgrades
5 participants