From c530f2a8d8496437a902759e2d8c2f1cbf4996ad Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Tue, 27 May 2025 14:10:10 +0100 Subject: [PATCH 1/2] Evergreen added shell script to create a git archive Ensure all submodules are included into the archive. JAVA-5882 --- .evergreen/.evg.yml | 26 +++----------------------- .evergreen/git-archive.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 23 deletions(-) create mode 100755 .evergreen/git-archive.sh diff --git a/.evergreen/.evg.yml b/.evergreen/.evg.yml index 760704d970e..4ea7d3853b1 100644 --- a/.evergreen/.evg.yml +++ b/.evergreen/.evg.yml @@ -831,15 +831,7 @@ functions: set -o errexit ${PREPARE_SHELL} export K8S_VARIANT=${VARIANT} - cd src - git add . - git commit --allow-empty -m "add files" - # uncompressed tar used to allow appending .git folder - export K8S_DRIVERS_TAR_FILE=/tmp/mongo-java-driver.tar - git archive -o $K8S_DRIVERS_TAR_FILE HEAD - tar -rf $K8S_DRIVERS_TAR_FILE .git - # Loop through all submodule directories and append to the archive - git submodule status --recursive | awk '{ print $2 }' | xargs tar -rf "$K8S_DRIVERS_TAR_FILE" + export K8S_DRIVERS_TAR_FILE=$(./.evergreen/git-archive.sh) export K8S_TEST_CMD="OIDC_ENV=k8s VARIANT=${VARIANT} ./.evergreen/run-mongodb-oidc-test.sh" bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/setup-pod.sh bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/run-self-test.sh @@ -939,13 +931,7 @@ tasks: script: |- set -o errexit ${PREPARE_SHELL} - cd src - git add . - git commit --allow-empty -m "add files" - # uncompressed tar used to allow appending .git folder - export AZUREOIDC_DRIVERS_TAR_FILE=/tmp/mongo-java-driver.tar - git archive -o $AZUREOIDC_DRIVERS_TAR_FILE HEAD - tar -rf $AZUREOIDC_DRIVERS_TAR_FILE .git + export AZUREOIDC_DRIVERS_TAR_FILE=$(./.evergreen/git-archive.sh) export AZUREOIDC_TEST_CMD="OIDC_ENV=azure ./.evergreen/run-mongodb-oidc-test.sh" bash $DRIVERS_TOOLS/.evergreen/auth_oidc/azure/run-driver-test.sh @@ -957,13 +943,7 @@ tasks: script: |- set -o errexit ${PREPARE_SHELL} - cd src - git add . - git commit --allow-empty -m "add files" - # uncompressed tar used to allow appending .git folder - export GCPOIDC_DRIVERS_TAR_FILE=/tmp/mongo-java-driver.tar - git archive -o $GCPOIDC_DRIVERS_TAR_FILE HEAD - tar -rf $GCPOIDC_DRIVERS_TAR_FILE .git + export GCPOIDC_DRIVERS_TAR_FILE=$(./.evergreen/git-archive.sh) # Define the command to run on the VM. # Ensure that we source the environment file created for us, set up any other variables we need, # and then run our test suite on the vm. diff --git a/.evergreen/git-archive.sh b/.evergreen/git-archive.sh new file mode 100755 index 00000000000..105800042d1 --- /dev/null +++ b/.evergreen/git-archive.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Exit the script with error if any of the commands fail +set -o errexit + +# Returns the path to the root archive file which includes all git submodules. + +echo "Creating root archive" +export GIT_ARCHIVE_FILE="/tmp/mongo-java-driver" + +# create root archive +git archive --output "$GIT_ARCHIVE_FILE.tar" HEAD + +echo "Appending submodule archives" +# for each of git submodules append to the root archive +git submodule foreach --recursive 'git archive --prefix=$path/ --output "$GIT_ARCHIVE_FILE-sub-$sha1.tar" $sha1' + +if [[ $(ls $GIT_ARCHIVE_FILE-sub*.tar | wc -l) != 0 ]]; then + echo "Combining all submodule archives into one tar" + tar -cf $GIT_ARCHIVE_FILE.tar $GIT_ARCHIVE_FILE-sub*.tar + + echo "Removing submodule archives" + rm -rf $GIT_ARCHIVE_FILE-sub*.tar +fi + +echo "Appending .git directory to the root archive" +tar -rf $GIT_ARCHIVE_FILE.tar .git + +echo "$GIT_ARCHIVE_FILE.tar" From dd782f6bd85d2a9f23497263ca2cb9cf1d83dd42 Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Tue, 27 May 2025 16:34:10 +0100 Subject: [PATCH 2/2] Update to a neater way of doing things --- .evergreen/git-archive.sh | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.evergreen/git-archive.sh b/.evergreen/git-archive.sh index 105800042d1..5c22c9170a4 100755 --- a/.evergreen/git-archive.sh +++ b/.evergreen/git-archive.sh @@ -6,24 +6,15 @@ set -o errexit # Returns the path to the root archive file which includes all git submodules. echo "Creating root archive" -export GIT_ARCHIVE_FILE="/tmp/mongo-java-driver" +export GIT_ARCHIVE_FILE="/tmp/mongo-java-driver.tar" # create root archive -git archive --output "$GIT_ARCHIVE_FILE.tar" HEAD +git archive --output $GIT_ARCHIVE_FILE HEAD echo "Appending submodule archives" -# for each of git submodules append to the root archive -git submodule foreach --recursive 'git archive --prefix=$path/ --output "$GIT_ARCHIVE_FILE-sub-$sha1.tar" $sha1' - -if [[ $(ls $GIT_ARCHIVE_FILE-sub*.tar | wc -l) != 0 ]]; then - echo "Combining all submodule archives into one tar" - tar -cf $GIT_ARCHIVE_FILE.tar $GIT_ARCHIVE_FILE-sub*.tar - - echo "Removing submodule archives" - rm -rf $GIT_ARCHIVE_FILE-sub*.tar -fi +git submodule status --recursive | awk '{ print $2 }' | xargs tar -rf $GIT_ARCHIVE_FILE echo "Appending .git directory to the root archive" -tar -rf $GIT_ARCHIVE_FILE.tar .git +tar -rf $GIT_ARCHIVE_FILE .git -echo "$GIT_ARCHIVE_FILE.tar" +echo "$GIT_ARCHIVE_FILE"