-
Notifications
You must be signed in to change notification settings - Fork 3.9k
CASSANDRA-21403 – trunk – Preload dependencies in build docker images to reduce downloading at build/test/ci runtime #4853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
michaelsembwever
wants to merge
5
commits into
apache:trunk
Choose a base branch
from
thelastpickle:mck/21403/trunk
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+266
−43
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c977bbf
Preload dependencies in build docker images to reduce downloading at …
michaelsembwever 99e9bc2
THROWAWAY
michaelsembwever 1d07530
SQUASH – extra commit. fix for "missing parameters" after helm updat…
michaelsembwever d4d26e7
SQUASH – small fix for argument checking
michaelsembwever dc7525f
SQUASH – review comments
michaelsembwever File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| set -e | ||
|
|
||
| # Script to prepopulate Maven repository with dependencies from multiple Cassandra branches | ||
| # This will download all dependencies to a custom Maven repository directory | ||
|
|
||
| # pre-conditions | ||
| command -v ant >/dev/null 2>&1 || { error 1 "ant needs to be installed"; } | ||
|
michaelsembwever marked this conversation as resolved.
|
||
| command -v git >/dev/null 2>&1 || { error 1 "git needs to be installed"; } | ||
|
|
||
|
|
||
| error() { | ||
| echo >&2 $2; | ||
| set -x | ||
| exit $1 | ||
| } | ||
|
|
||
| # Function to download dependencies for a branch | ||
| download_deps_for_branch() { | ||
| local branch=$1 | ||
| local branch_name=$(echo "$branch" | sed 's|origin/||') | ||
|
|
||
| # Check if branch exists | ||
| if ! git rev-parse --verify "$branch" >/dev/null 2>&1; then | ||
| echo "WARNING: Branch $branch does not exist, skipping..." | ||
| return | ||
| fi | ||
|
|
||
| git checkout "$branch" | ||
|
|
||
| echo "" | ||
| echo "Downloading dependencies for $branch to $CUSTOM_M2_REPO..." | ||
| echo "" | ||
|
|
||
| # ensure git modules are initialised | ||
| ant init | ||
| # HACK | ||
| if [ -d "modules/accord" ]; then | ||
| local version=$(grep '<property name="base.version"' build.xml | sed 's/.*value="\([^"]*\)".*/\1/') | ||
| cd modules/accord | ||
| ./gradlew clean publishToMavenLocal -Dmaven.repo.local="$CUSTOM_M2_REPO" -Paccord_group=org.apache.cassandra -Paccord_artifactId=cassandra-accord -Paccord_version="${version}-SNAPSHOT" -x test -x rat -x checkstyleMain -x checkstyleTest -x javadoc | ||
| cd - | ||
| fi | ||
| # download all dependencies | ||
| ant -Dmaven.repo.local="$CUSTOM_M2_REPO" -Dlocal.repository="$CUSTOM_M2_REPO" resolver-dist-lib | ||
| } | ||
|
|
||
| CUSTOM_M2_REPO="${1:-$HOME/.m2/repository}" | ||
|
michaelsembwever marked this conversation as resolved.
|
||
| TMP_DIR=${TMP_DIR:-/tmp} | ||
|
|
||
| cd $TMP_DIR | ||
|
michaelsembwever marked this conversation as resolved.
|
||
| git clone https://github.com/apache/cassandra.git | ||
| cd cassandra | ||
| git config advice.detachedHead false | ||
|
|
||
| # Automatically detect branches from cassandra-5.0 onwards to trunk | ||
| echo "Detecting branches..." | ||
| BRANCHES=() | ||
|
|
||
| # Get all origin branches matching cassandra-5.x+, cassandra-6.x+, etc., and trunk | ||
| # Pattern matches: cassandra-5.0, cassandra-5.0.0, cassandra-10.0, cassandra-10.0.1, trunk | ||
| while IFS= read -r branch; do | ||
| BRANCHES+=("$branch") | ||
| done < <(git branch -r | grep -E "^\s*origin/(cassandra-[5-9][0-9]*\.[0-9]+(\.[0-9]+)?|trunk)$" | sed 's/^[[:space:]]*//' | sort -V) | ||
|
|
||
| # If no branches found, fail | ||
| if [ ${#BRANCHES[@]} -eq 0 ]; then | ||
| echo "ERROR: No branches auto-detected matching pattern origin/cassandra-[5+].x or origin/trunk" | ||
| echo "Please ensure you have fetched remote branches: git fetch origin" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Branches to process:" | ||
| for branch in "${BRANCHES[@]}"; do | ||
| echo " - $branch" | ||
| done | ||
| echo "==========================================" | ||
| echo "" | ||
|
|
||
| # Create custom Maven repository directory | ||
| mkdir -p "$CUSTOM_M2_REPO" | ||
|
|
||
| # Process each branch | ||
| for branch in "${BRANCHES[@]}"; do | ||
| download_deps_for_branch "$branch" | ||
| done | ||
|
|
||
| cd - | ||
| rm -rf $TMP_DIR/cassandra | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.