-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
test: Add cherry-picks section to RC build comment, update Slack message #29772
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
Open
sleepytanya
wants to merge
6
commits into
main
Choose a base branch
from
mcrm-63-add-changelog
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5a77251
Add CP section, update Slack link
sleepytanya 8fbd53d
Remove shell interpolation
sleepytanya 75e01cb
Remove dead Slack code
sleepytanya be35f59
Merge branch 'main' into mcrm-63-add-changelog
sleepytanya 1393408
Fix merge-base
sleepytanya cfabf44
Fix failure reporting
sleepytanya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| /** | ||
| * Extracts commits from release branch and builds collapsible markdown section. | ||
| */ | ||
|
|
||
| import { execSync } from 'child_process'; | ||
|
|
||
| const REPO_URL = process.env.GITHUB_REPOSITORY | ||
| ? `https://github.com/${process.env.GITHUB_REPOSITORY}` | ||
| : 'https://github.com/MetaMask/metamask-mobile'; | ||
|
|
||
| const SKIP_CI_BUMP_VERSION_SUBJECT = /^\[skip ci\] Bump version number to/; | ||
|
|
||
| function getMergeBase(headRef: string, baseRef: string): string | null { | ||
| try { | ||
| const out = execSync(`git merge-base ${headRef} ${baseRef}`, { | ||
Check warningCode scanning / CodeQL Indirect uncontrolled command line Medium
This command depends on an unsanitized
environment variable Error loading related location Loading This command depends on an unsanitized environment variable Error loading related location Loading |
||
|
cursor[bot] marked this conversation as resolved.
Outdated
|
||
| encoding: 'utf8', | ||
| stdio: ['ignore', 'pipe', 'pipe'], | ||
| }); | ||
| return out.trim() || null; | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| function getAncestryPathCommits( | ||
| mergeBaseHash: string, | ||
| headRef: string, | ||
| ): { hash: string; subject: string }[] { | ||
| try { | ||
| const out = execSync( | ||
| `git log --ancestry-path ${mergeBaseHash}..${headRef} --pretty=format:%h\t%s`, | ||
Check warningCode scanning / CodeQL Indirect uncontrolled command line Medium
This command depends on an unsanitized
environment variable Error loading related location Loading |
||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }, | ||
| ); | ||
|
|
||
| if (!out.trim()) return []; | ||
|
|
||
| return out | ||
| .trim() | ||
| .split('\n') | ||
| .filter((line) => { | ||
| const tab = line.indexOf('\t'); | ||
| const subject = tab >= 0 ? line.slice(tab + 1) : line; | ||
| return !SKIP_CI_BUMP_VERSION_SUBJECT.test(subject.trim()); | ||
| }) | ||
| .map((line) => { | ||
| const tab = line.indexOf('\t'); | ||
| return { | ||
| hash: tab >= 0 ? line.slice(0, tab) : '', | ||
| subject: tab >= 0 ? line.slice(tab + 1) : line, | ||
| }; | ||
| }); | ||
| } catch { | ||
| return []; | ||
| } | ||
| } | ||
|
|
||
| function formatSubjectWithPrLinks(subject: string): string { | ||
| return subject | ||
| .replace(/\(#(\d+)\)/g, (_, n) => `([#${n}](${REPO_URL}/pull/${n}))`) | ||
| .replace(/(^|\s)#(\d+)\b/g, (_, lead, n) => `${lead}[#${n}](${REPO_URL}/pull/${n})`); | ||
| } | ||
|
|
||
| export function extractCherryPicks(): { hash: string; subject: string }[] { | ||
| const baseRef = process.env.MERGE_BASE_REF ?? 'origin/main'; | ||
| const headRef = (process.env.HEAD_REF ?? '').trim() || 'HEAD'; | ||
|
|
||
| const mergeBase = getMergeBase(headRef, baseRef); | ||
|
sleepytanya marked this conversation as resolved.
|
||
| if (!mergeBase) { | ||
| console.log('[cherry-picks] Could not resolve merge-base'); | ||
| return []; | ||
| } | ||
|
|
||
| const commits = getAncestryPathCommits(mergeBase, headRef); | ||
| console.log(`[cherry-picks] Found ${commits.length} commit(s)`); | ||
| return commits; | ||
| } | ||
|
|
||
| export function buildCherryPicksSection( | ||
| commits: { hash: string; subject: string }[], | ||
| ): string { | ||
| if (commits.length === 0) return ''; | ||
|
|
||
| const lines: string[] = [ | ||
| '<a id="cherry-picks"></a>', | ||
| '### :cherries: What\'s in this RC\n', | ||
| '<details>', | ||
| `<summary>${commits.length} commit(s) in this release</summary>\n`, | ||
| '| Commit | Description |', | ||
| '| :--- | :--- |', | ||
| ]; | ||
|
|
||
| for (const commit of commits) { | ||
| const linkedSubject = formatSubjectWithPrLinks(commit.subject); | ||
| const commitLink = `[\`${commit.hash}\`](${REPO_URL}/commit/${commit.hash})`; | ||
| lines.push(`| ${commitLink} | ${linkedSubject} |`); | ||
| } | ||
|
|
||
| lines.push('\n</details>\n'); | ||
| return lines.join('\n'); | ||
| } | ||
|
|
||
| export function buildCherryPicksFailureSection(error?: string): string { | ||
| let section = `<a id="cherry-picks"></a> | ||
| ### :cherries: What's in this RC | ||
|
|
||
| _Could not extract commit list._`; | ||
|
|
||
| if (error) { | ||
| section += `\n\n<details>\n<summary>Details</summary>\n\n${error}\n\n</details>`; | ||
| } | ||
|
|
||
| return section + '\n'; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.