Skip to content

Roll perf profiles update (update-perf-profile-2024-11-10-16-16) #12367

Roll perf profiles update (update-perf-profile-2024-11-10-16-16)

Roll perf profiles update (update-perf-profile-2024-11-10-16-16) #12367

name: Set PR Milestone
on:
pull_request:
types: [closed]
branches: [master, 1.*]
concurrency: set-bb-issues-milestone
jobs:
set-pr-milestone:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_NAME: ${{ github.event.repository.full_name }}
PR_NUMBER: ${{ github.event.number }}
name: "Set milestone on PR based on base branch"
run: |
readarray -t milestones < <(gh api /repos/brave/brave-core/milestones -q ".[] | .title")
if [[ "$GITHUB_BASE_REF" = "master" ]]; then
milestone_selector="Nightly"
else
milestone_selector="$GITHUB_BASE_REF"
fi
milestone=$(printf "%s\n" "${milestones[@]}" | grep -F "$milestone_selector")
gh pr edit "$PR_NUMBER" -R "$REPO_NAME" -m "$milestone"
set-brave-browser-issues-milestone:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
needs: set-pr-milestone
steps:
- env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
REPO_NAME: ${{ github.event.repository.full_name }}
PR_NUMBER: ${{ github.event.number }}
name: "Set milestone on related issues in brave-browser"
run: |
BB_ISSUE_PREFIX="https://github.com/brave/brave-browser/issues/"
BB_ISSUE_URL_REGEX='(http(s)?:\/\/)?github.com/brave/brave-browser/issues/\d+'
UPLIFT_PR_REGEX='uplift\s+(?:of)?:?\s+\K(#\d+)'
RESOLVE_ISSUE_REGEX="(?:resolv|fix|clos)(?:e|es|ed)?:?\s+<?\K(${BB_ISSUE_URL_REGEX})"
verlte() { printf '%s\n%s' "$1" "$2" | sort -C -V; }
normalize_issue_links() { sed "s@\sbrave\/brave-browser\#\([0-9]\+\)@ ${BB_ISSUE_PREFIX}\1@g"; }
pr_body=$(gh pr view "${PR_NUMBER}" -R "${REPO_NAME}" --json body --jq .body | normalize_issue_links)
readarray -t issues_pr < <(echo "${pr_body}" | grep -ioP "${RESOLVE_ISSUE_REGEX}" || :)
echo "Looking for any uplifted PRs"
readarray -t prs < <(echo "${pr_body}" | grep -ioP "${UPLIFT_PR_REGEX}" || :)
readarray -t issues_uplift_pr < <(echo "${prs[@]}" | xargs -n 1 -I{} gh pr view {} -R brave/brave-core --json body --jq ".body" | normalize_issue_links | grep -ioP "${RESOLVE_ISSUE_REGEX}")
readarray -t issues < <(printf "%s\n" "${issues_pr[@]}" "${issues_uplift_pr[@]}"| sort -u | sed '/^\s*$/d')
echo "Relevant issues detected:"
printf "%s\n" "${issues[@]}"
pr_milestone=$(gh pr view "${PR_NUMBER}" -R "${REPO_NAME}" --json milestone --jq .milestone.title)
for issue in "${issues[@]}"; do
issue_milestone=$(gh issue view "${issue}" --json milestone --jq .milestone.title)
if [[ -z "${issue_milestone}" ]] || verlte "${pr_milestone}" "${issue_milestone}"; then
echo "Setting ${issue} milestone to ${pr_milestone}"
gh issue edit "${issue}" -m "${pr_milestone}"
fi
done