Skip to content

Commit

Permalink
Clarify cr version check statuses and add call to action (brave#25376)
Browse files Browse the repository at this point in the history
Update statuses and step description to be clearer.
  • Loading branch information
goodov authored Aug 29, 2024
1 parent 46e4713 commit 15d7522
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/compare-chromium-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@ jobs:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_SHA: ${{ github.event.pull_request.head.sha }}
steps:
- run: |
# Comparing Chromium versions between the PR branch and the target branch
- name: Check if CI and merge are allowed based on the Chromium version in the target branch
run: |
shopt -s inherit_errexit
set -eEo pipefail
chromium_ver() { curl -fsS "https://raw.githubusercontent.com/${GITHUB_REPOSITORY:?}/${1:?}/package.json"|jq -r .config.projects.chrome.tag; }
pr_ver="$(chromium_ver "${PR_SHA:?}")"
target_ver="$(chromium_ver "${GITHUB_BASE_REF:?}")"
pfx="Target branch Chromium version"
status() { echo "::${1:?}::${2:?}"; echo "$2" >"${GITHUB_STEP_SUMMARY:?}"; }
status() { echo "::${1:?}::${2:?}"; echo "$2" >>"${GITHUB_STEP_SUMMARY:?}"; }
label() { gh pr edit "${PR_NUMBER:?}" -R "${GITHUB_REPOSITORY:?}" "--${1:?}-label" chromium-version-mismatch >/dev/null; }
success() { status notice "${pfx:?} ${1:?}: CI ✅ | Merge ✅"; label remove; }
success() { status notice "${1:?}: CI ✅ | Merge ✅"; label remove; }
failure() {
case "${1:?}" in runci) ci=✅; label remove;; *) ci=🚫; label add;; esac
status error "${pfx:?} ${2:?}: CI $ci | Merge 🚫"
status error "${2:?}: CI $ci | Merge 🚫"
status error "Please rebase."
exit 2
}
echo "::notice::PR branch: ${pr_ver:?}, target branch: ${target_ver:?}"
if [[ "$pr_ver" == "$target_ver" ]]; then
success match
success "Chromium version full match"
elif [[ "$(sort -V <<<"$target_ver"$'\n'"$pr_ver"|tail -n1)" == "$pr_ver" ]]; then
success older
success "Chromium version is newer in the PR"
elif [[ "${pr_ver%%.*}" == "${target_ver%%.*}" ]]; then
failure runci "major match only"
failure runci "Chromium version partial match"
else
failure blockci mismatch
failure blockci "Chromium version mismatch"
fi

0 comments on commit 15d7522

Please sign in to comment.