Skip to content

Commit

Permalink
PMM-13487 Require the HEAD to be a feature branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Dec 7, 2024
1 parent 1944317 commit cb66c3b
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions build/local/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ check_files() {
fi

if [ ! -d "$DIR/sources" ] || [ ! -d "$DIR/.git" ] || [ ! -f "$DIR/.gitmodules" ] || [ ! -f "$DIR/ci.py" ]; then
echo "Error: directory $DIR does not look like a clone of https://github.com/percona-lab/pmm-submodules repository, exiting..."
echo "Error: the contents of directory $DIR do not look like a clone of https://github.com/percona-lab/pmm-submodules repository, exiting..."
echo
exit 1
fi
Expand All @@ -180,12 +180,24 @@ check_files() {
exit 1
fi

local branch_name=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ -z "$branch_name" ]; then
echo "Error: could not determine the current branch name, exiting..."
echo
exit 1
fi
if [[ "$branch_name" =~ ^main$|^v3$ ]]; then
echo "Error: you are not on a feature branch, but on '$branch_name'."
echo "Please make sure to create a feature branch before proceeding."
echo
exit 1
fi

mkdir -p "$DIR/build"
}

# Update submodules and PR branches
update() {
local DEPS=
local CURDIR="$PWD"

if [ "$NO_UPDATE" -eq 1 ]; then
Expand All @@ -208,6 +220,7 @@ update() {

echo
echo "This script rewinds submodule branches as per the joint config of '.gitmodules' and user-supplied 'ci.yml'"
echo

cd "$SUBMODULES"

Expand Down Expand Up @@ -304,7 +317,7 @@ run_build_script() {
}

purge_files() {
local CURDIR=$PWD
local CURDIR="$PWD"
local PMM_DIR="build/source/pmm"
local tmp_files

Expand Down Expand Up @@ -337,12 +350,6 @@ purge_files() {
}

check_volumes() {
local CURDIR="$PWD"

if [ -d "$SUBMODULES" ]; then
cd "$SUBMODULES" > /dev/null
fi

# Create docker volumes to persist package and build cache
# Read more in the section about `rpmbuild`.
for volume in pmm-gobuild pmm-gomod pmm-yarn pmm-dnf; do
Expand Down Expand Up @@ -377,13 +384,11 @@ check_volumes() {
sudo chown builder:builder /home/builder/.cache/yarn
fi
"

cd "$CURDIR" > /dev/null
}

initialize() {
local CURDIR="$PWD"
local NPROCS=$(getconf _NPROCESSORS_ONLN)
local NPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)

if [ -d "$SUBMODULES" ]; then
echo "Info: the source code has already been cloned to '$SUBMODULES', exiting..."
Expand Down Expand Up @@ -417,7 +422,7 @@ check_if_installed() {
}

check_preprequisites() {
local commands=("docker" "make" "bash" "tar" "git" "curl" "jq")
local commands=("docker" "make" "bash" "tar" "git" "curl")
echo "Checking pre-requisites..."
for cmd in "${commands[@]}"; do
check_if_installed "$cmd"
Expand All @@ -440,7 +445,8 @@ cleanup() {
}

main() {
# All global variables are declared in `parse_params`
# All global variables are declared in `parse_params` for this script,
# and in `scripts/vars` for the other build scripts.
parse_params "$@"

# Capture the build logs in the log file
Expand Down

0 comments on commit cb66c3b

Please sign in to comment.