Skip to content

Commit d40ab2d

Browse files
committed
add bypass and fix nits for upgrade-script-check.sh
1 parent a9f2905 commit d40ab2d

File tree

3 files changed

+73
-28
lines changed

3 files changed

+73
-28
lines changed

buildkite/scripts/archive/upgrade-script-check.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
# upgrade-script-check.sh [OPTIONS]
1111
#
1212
# OPTIONS:
13-
# -m, --mode MODE Execution mode: 'default' or 'verbose' (default: default)
14-
# default: Returns exit code 0/1 without error messages
15-
# verbose: Prints error messages and fails with descriptive output
16-
# -b, --branch BRANCH Target branch for comparison (default: develop)
17-
# -h, --help Show this help message
13+
# -m, --mode MODE Execution mode: 'default' or 'verbose' (default: default)
14+
# default: Returns exit code 0/1 without error messages
15+
# verbose: Prints error messages and fails with descriptive output
16+
# -b, --comparison-branch BRANCH Target branch for comparison (default: develop)
17+
# -h, --help Show this help message
1818
#
1919
# EXIT CODES:
2020
# 0: Success (no schema changes or upgrade script exists)
@@ -43,7 +43,7 @@ parse_args() {
4343
fi
4444
shift 2
4545
;;
46-
-b|--branch)
46+
-b|--comparison-branch)
4747
BRANCH="$2"
4848
shift 2
4949
;;
@@ -93,7 +93,7 @@ has_changes() {
9393
fi
9494
}
9595

96-
has_changes_in_in_git() {
96+
has_changes_in_git() {
9797
local file="$1"
9898
if ! check_file_exists "$file"; then
9999
return 1
@@ -155,6 +155,12 @@ main() {
155155

156156
# If schema files changed, verify upgrade script exists
157157
if [[ "$schema_changed" == "true" ]]; then
158+
159+
if ./buildkite/scripts/git/check-bypass.sh "!ci-bypass-upgrade-script-check"; then
160+
echo "⏭️ Skipping upgrade script check as PR is bypassed"
161+
exit 0
162+
fi
163+
158164
# Check that all required scripts exist
159165
for script_path in "${scripts[@]}"; do
160166
if ! check_file_exists "$script_path"; then
@@ -167,7 +173,7 @@ main() {
167173
fi
168174

169175
# Check if the upgrade script itself has changes
170-
if has_changes_in_in_git "$script_path"; then
176+
if has_changes_in_git "$script_path"; then
171177
if [[ "$MODE" == "verbose" ]]; then
172178
echo "✓ Upgrade script has been modified: $script_path"
173179
fi

buildkite/scripts/changelog.sh

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -eou pipefail
4+
35
# This script checks if a changelog entry is required for a given pull request.
46
# It compares the current commit with the base branch of the pull request and looks for changes
57
# in the specified trigger files. If changes are found, it checks if the required changelog entry
@@ -20,9 +22,6 @@ BASE_PATH=""
2022
CHANGELOG_FILE=""
2123
# List of users who can bypass the changelog check by commenting !ci-bypass-changelog
2224
# separated by space
23-
GITHUB_USERS_ELIGIBLE_FOR_BYPASS="amc-ie deepthiskumar Trivo25 45930 SanabriaRusso nicc georgeee dannywillems cjjdespres"
24-
25-
BYPASS_PHRASE="!ci-bypass-changelog"
2625

2726
PIPELINE_SLUG="mina-o-1-labs"
2827

@@ -75,23 +74,7 @@ if [[ ! "$BUILDKITE_PULL_REQUEST_BASE_BRANCH" ]]; then
7574
exit 1
7675
fi
7776

78-
# Check if PR is bypassed by a !ci-bypass-changelog comment
79-
pip install -r scripts/github/github_info/requirements.txt
80-
81-
COMMENTED_CODE=0
82-
(python3 scripts/github/github_info is_pr_commented --comment "$BYPASS_PHRASE" \
83-
--by $GITHUB_USERS_ELIGIBLE_FOR_BYPASS --pr "$BUILDKITE_PULL_REQUEST") \
84-
|| COMMENTED_CODE=$?
85-
86-
if [[ "$COMMENTED_CODE" == 0 ]]; then
87-
echo "⏭️ Skipping run as PR is bypassed"
88-
exit 0
89-
elif [[ "$COMMENTED_CODE" == 1 ]]; then
90-
echo "⚙️ PR is not bypassed. Proceeding with changelog check..."
91-
else
92-
echo "❌ Failed to check PR for being eligible for changelog check bypass"
93-
exit 1
94-
fi
77+
./buildkite/scripts/git/check-bypass.sh "!ci-bypass-changelog"
9578

9679
REMOTE_BRANCH="origin/${BUILDKITE_PULL_REQUEST_BASE_BRANCH}"
9780

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
3+
# Git Bypass Check Script
4+
#
5+
# This script checks if a pull request has been bypassed for certain CI checks
6+
# by authorized users through GitHub comments.
7+
#
8+
# DESCRIPTION:
9+
# Verifies if a PR contains a bypass comment (e.g., !ci-bypass-changelog)
10+
# made by users who are eligible to bypass CI checks. Uses a Python script
11+
# to interact with GitHub API and check for the presence of bypass comments.
12+
#
13+
# USAGE:
14+
# ./check-bypass.sh <bypass_phrase>
15+
#
16+
# ARGUMENTS:
17+
# bypass_phrase - The comment phrase to look for (e.g., "!ci-bypass-changelog")
18+
#
19+
# ENVIRONMENT VARIABLES:
20+
# BUILDKITE_PULL_REQUEST - Pull request number (set by Buildkite)
21+
#
22+
# EXIT CODES:
23+
# 0 - PR is bypassed, skip the check
24+
# 1 - Error occurred during bypass check
25+
# (continues execution if PR is not bypassed)
26+
#
27+
# DEPENDENCIES:
28+
# - Python 3
29+
# - pip packages from scripts/github/github_info/requirements.txt
30+
# - scripts/github/github_info Python module
31+
#
32+
# AUTHORIZED USERS:
33+
# Only users listed in GITHUB_USERS_ELIGIBLE_FOR_BYPASS can bypass checks
34+
35+
GITHUB_USERS_ELIGIBLE_FOR_BYPASS="amc-ie deepthiskumar Trivo25 45930 SanabriaRusso nicc georgeee dannywillems cjjdespres"
36+
37+
BYPASS_PHRASE=$1
38+
39+
40+
# Check if PR is bypassed by a !ci-bypass-changelog comment
41+
pip install -r scripts/github/github_info/requirements.txt
42+
43+
COMMENTED_CODE=0
44+
(python3 scripts/github/github_info is_pr_commented --comment "$BYPASS_PHRASE" \
45+
--by $GITHUB_USERS_ELIGIBLE_FOR_BYPASS --pr "$BUILDKITE_PULL_REQUEST") \
46+
|| COMMENTED_CODE=$?
47+
48+
if [[ "$COMMENTED_CODE" == 0 ]]; then
49+
echo "⏭️ Skipping run as PR is bypassed"
50+
exit 0
51+
elif [[ "$COMMENTED_CODE" == 1 ]]; then
52+
echo "⚙️ PR is not bypassed. Proceeding with changelog check..."
53+
else
54+
echo "❌ Failed to check PR for being eligible for changelog check bypass"
55+
exit 1
56+
fi

0 commit comments

Comments
 (0)