Skip to content

Commit

Permalink
PMM-13487 Replace LOCAL_BUILD with USE_S3_CACHE var
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Dec 5, 2024
1 parent 69b4ba8 commit 8800e17
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build/local/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion build/local/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path> Save build logs to a file located at <path> (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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -84,6 +85,9 @@ parse_params() {
fi
PLATFORM="$1"
;;
--use-s3-cache)
USE_S3_CACHE=1
;;
--log-file)
shift
if [ -z "$1" ]; then
Expand Down Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions build/scripts/build-server-rpm
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit 8800e17

Please sign in to comment.