From 8800e17854961cf3ba7ed817e8b1a6dde690c142 Mon Sep 17 00:00:00 2001 From: Alex Demidoff Date: Thu, 5 Dec 2024 03:30:12 +0300 Subject: [PATCH] PMM-13487 Replace LOCAL_BUILD with USE_S3_CACHE var --- build/local/README.md | 2 +- build/local/build.sh | 7 ++++++- build/scripts/build-server-rpm | 10 +++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/build/local/README.md b/build/local/README.md index a6b38de164..85133d2439 100644 --- a/build/local/README.md +++ b/build/local/README.md @@ -58,7 +58,7 @@ In order to save time and to avoid building the same package versions repeatedly - before proceeding to building a package, we check if this package version can be found in S3 and we download the package instead of building it; - if the package can not be found, we build and upload it to S3 for future reuse. -There is special variable `LOCAL_BUILD`, which needs to be set to '1' in case you don't have AWS CLI installed or you don't want to use the cache. Please be aware, that interacting with Percona's AWS S3 account, i.e. upload and download artefacts, requires authentication and is therefore reserved for Percona's own purposes. This is why, when building packages locally, you are requested to set this variable to '1', which happens to be the default value. Please note, that an attempt to interact with the S3 bucket without proper authorization will lead to a build failure. +There is special parameter `--use-s3-cache`, which you have to pass in case you have AWS CLI installed or you want to use the build cache. Please be aware, that interacting with Percona's AWS S3 account, i.e. upload and download artefacts, requires authentication and is therefore reserved for Percona's own purposes. This is why, when building packages locally, you are requested to set this variable to '1', which is also the default value. Please note, that an attempt to interact with the S3 bucket without proper authorization will lead to a build failure. ## Avoiding unnecessary builds diff --git a/build/local/build.sh b/build/local/build.sh index 518a01799d..a6a259cd12 100755 --- a/build/local/build.sh +++ b/build/local/build.sh @@ -13,6 +13,7 @@ Options: --client-only Build only PMM Client (client binaries + docker) --no-client Do not build PMM Client (this will use local cache) --no-client-docker Do not build PMM Client docker image + --use-s3-cache Use S3 cache for the build (defaults to false) --log-file Save build logs to a file located at (defaults to $PWD/build.log) Note: the log file will get reset on every subsequent run --release-build Make it a release, or release candidate build (otherwise it's a feature build) @@ -40,7 +41,7 @@ parse_params() { PATH_TO_SCRIPTS="sources/pmm/src/github.com/percona/pmm/build/scripts" # Exported variables - export LOCAL_BUILD=1 + export USE_S3_CACHE=0 export DEBUG_MODE=0 export ROOT_DIR="$(realpath ./${SUBMODULES})" export RPMBUILD_DOCKER_IMAGE=perconalab/rpmbuild:3 @@ -84,6 +85,9 @@ parse_params() { fi PLATFORM="$1" ;; + --use-s3-cache) + USE_S3_CACHE=1 + ;; --log-file) shift if [ -z "$1" ]; then @@ -431,6 +435,7 @@ initialize() { git submodule update --init --jobs ${NPROCS:-2} git submodule status + echo echo "Info: the source code has been cloned to '$SUBMODULES'." echo diff --git a/build/scripts/build-server-rpm b/build/scripts/build-server-rpm index 6b9c692f5f..88c6317ff2 100755 --- a/build/scripts/build-server-rpm +++ b/build/scripts/build-server-rpm @@ -42,10 +42,10 @@ is_build_needed() { # s3://pmm-build-cache/RELEASE/9 - el9 # Check if this is a release build - if [ -z "$RPM_EPOCH"] && [ "$RELEASE_BUILD" = 1 ]; then + if [ "$RELEASE_BUILD" = 1 ]; then s3_cache_dir=RELEASE fi - if command -v aws &> /dev/null && [ -z "$LOCAL_BUILD" ]; then + if command -v aws &> /dev/null && [ "${USE_S3_CACHE:-0}" -eq 1 ]; then aws s3 sync \ --region us-east-2 \ --no-sign-request \ @@ -180,21 +180,21 @@ build() { rm -f SOURCES/${spec_name}.spec* " - if [ "$LOCAL_BUILD" = 1 ]; then + if [ "${USE_S3_CACHE:-0}" -eq 0 ]; then echo "Finished building Server RPMs, spec_name: ${spec_name}.spec, repo_name: ${repo_name}" echo return fi if ! command -v aws &> /dev/null; then - echo "Skipping upload to S3..." + echo "AWS CLI is not installed, skipping upload to S3..." echo echo "Finished building Server RPMs, spec_name: ${spec_name}.spec, repo_name: ${repo_name}" echo return fi - if [ -z "$RPM_EPOCH" ] && [ "$RELEASE_BUILD" = 1 ]; then + if [ "$RELEASE_BUILD" = 1 ]; then s3_cache_dir=RELEASE fi aws s3 sync \