Skip to content

Commit e12dfd6

Browse files
authored
Merge pull request #17734 from MinaProtocol/dkijania/archive_compatibility_test
[HF] test upgrade script on devnet
2 parents 525eae3 + 5e3b827 commit e12dfd6

File tree

8 files changed

+264
-66
lines changed

8 files changed

+264
-66
lines changed

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

Lines changed: 71 additions & 13 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)
@@ -28,7 +28,7 @@
2828
set -euo pipefail
2929

3030
MODE="default"
31-
BRANCH="develop"
31+
COMPARISION_BRANCH="develop"
3232
REPO_ROOT="$(git rev-parse --show-toplevel)"
3333

3434
# Parse command line arguments
@@ -43,8 +43,8 @@ parse_args() {
4343
fi
4444
shift 2
4545
;;
46-
-b|--branch)
47-
BRANCH="$2"
46+
-b|--comparison-branch)
47+
COMPARISION_BRANCH="$2"
4848
shift 2
4949
;;
5050
-h|--help)
@@ -80,18 +80,53 @@ has_changes() {
8080
fi
8181

8282
# Fetch latest branch to ensure accurate comparison
83-
git fetch origin "$BRANCH" >/dev/null 2>&1 || {
83+
git fetch origin "$COMPARISION_BRANCH" >/dev/null 2>&1 || {
84+
echo "Error: Failed to fetch origin/$COMPARISION_BRANCH" >&2
85+
exit 1
86+
}
87+
88+
# Check if file has differences
89+
if ! git diff --quiet "origin/$COMPARISION_BRANCH" -- "$REPO_ROOT/$file" 2>/dev/null; then
90+
return 0
91+
else
92+
return 1
93+
fi
94+
}
95+
96+
has_changes_in_git() {
97+
local file="$1"
98+
if ! check_file_exists "$file"; then
99+
return 1
100+
fi
101+
102+
# Fetch latest branch to ensure accurate comparison
103+
git fetch origin "$COMPARISION_BRANCH" >/dev/null 2>&1 || {
84104
if [[ "$MODE" == "verbose" ]]; then
85-
echo "Error: Failed to fetch origin/$BRANCH" >&2
105+
echo "Error: Failed to fetch origin/$COMPARISION_BRANCH" >&2
86106
fi
87107
return 1
88108
}
89109

90-
# Check if file has differences
91-
git diff --quiet "origin/$BRANCH" -- "$REPO_ROOT/$file" 2>/dev/null
92-
return $?
110+
# Check if file was modified in last commit, staged, or has unstaged changes
111+
local file_path="$REPO_ROOT/$file"
112+
113+
# Check if file was modified in last commit
114+
if git diff --quiet HEAD~1 HEAD -- "$file_path" 2>/dev/null; then
115+
# No changes in last commit, check staged changes
116+
if git diff --quiet --cached -- "$file_path" 2>/dev/null; then
117+
# No staged changes, check unstaged changes
118+
if git diff --quiet -- "$file_path" 2>/dev/null; then
119+
# No changes found
120+
return 1
121+
fi
122+
fi
123+
fi
124+
125+
# File has changes in one of the three states
126+
return 0
93127
}
94128

129+
95130
# Main execution
96131
main() {
97132
parse_args "$@"
@@ -120,6 +155,12 @@ main() {
120155

121156
# If schema files changed, verify upgrade script exists
122157
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+
123164
# Check that all required scripts exist
124165
for script_path in "${scripts[@]}"; do
125166
if ! check_file_exists "$script_path"; then
@@ -130,6 +171,23 @@ main() {
130171
fi
131172
exit 1
132173
fi
174+
175+
# Check if the upgrade script itself has changes
176+
if has_changes_in_git "$script_path"; then
177+
if [[ "$MODE" == "verbose" ]]; then
178+
echo "✓ Upgrade script has been modified: $script_path"
179+
fi
180+
else
181+
if [[ "$MODE" == "verbose" ]]; then
182+
echo "Error: Schema changed but upgrade script not updated: $script_path"
183+
echo "Please update the upgrade script to reflect schema changes."
184+
echo "This is critical to ensure smooth database migrations in production."
185+
echo "Upgrade/Rollback scripts must be updated together with schema changes, in the same commit."
186+
echo "For local testing, scripts can be modified in staged/unstaged git states."
187+
exit 1
188+
fi
189+
fi
190+
133191
done
134192

135193
if [[ "$MODE" == "verbose" ]]; then

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 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

buildkite/src/Command/Rosetta/Connectivity.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ let command
5959
, "source ./buildkite/scripts/export-git-env-vars.sh"
6060
, "scripts/tests/rosetta-connectivity.sh --network ${Network.lowerName
6161
spec.network} --tag \\\${MINA_DOCKER_TAG} --timeout ${Natural/show
62-
spec.timeout} --run-load-test"
62+
spec.timeout} --run-compatibility-test develop --run-load-test "
6363
]
6464
]
6565
, label =

buildkite/src/Jobs/Lint/ArchiveUpgrade.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ in Pipeline.build
3636
Command.Config::{
3737
, commands =
3838
[ Cmd.run
39-
"buildkite/scripts/archive/upgrade-script-check.sh --mode verbose --branch develop"
39+
"buildkite/scripts/archive/upgrade-script-check.sh --mode verbose --comparison-branch develop"
4040
]
4141
, label = "Archive: Check upgrade script need"
4242
, key = "archive-check-upgrade-script"

changes/17713.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added guardian test to CI, which will verify if there is a mismatch in content of create_schema.sql / drop_tables.sql. If yes, then test will demand change in upgrade-to-mesa.sh script

scripts/debian/builder-helpers.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,7 @@ copy_common_archive_configs() {
544544
cp ./default/src/app/replayer/replayer.exe \
545545
"${BUILDDIR}/usr/local/bin/mina-replayer"
546546

547-
cp ../src/app/archive/create_schema.sql "${BUILDDIR}/etc/mina/archive"
548-
cp ../src/app/archive/drop_tables.sql "${BUILDDIR}/etc/mina/archive"
547+
rsync -Huav ../src/app/archive/*.sql "${BUILDDIR}/etc/mina/archive"
549548

550549
build_deb "$ARCHIVE_DEB"
551550
}

0 commit comments

Comments
 (0)