Skip to content

Commit 0c27b26

Browse files
authored
Evergreen added shell script to create a git archive (#1718)
Ensure all submodules are included into the archive and dry up the logic JAVA-5882
1 parent 25c0262 commit 0c27b26

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

.evergreen/.evg.yml

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -831,15 +831,7 @@ functions:
831831
set -o errexit
832832
${PREPARE_SHELL}
833833
export K8S_VARIANT=${VARIANT}
834-
cd src
835-
git add .
836-
git commit --allow-empty -m "add files"
837-
# uncompressed tar used to allow appending .git folder
838-
export K8S_DRIVERS_TAR_FILE=/tmp/mongo-java-driver.tar
839-
git archive -o $K8S_DRIVERS_TAR_FILE HEAD
840-
tar -rf $K8S_DRIVERS_TAR_FILE .git
841-
# Loop through all submodule directories and append to the archive
842-
git submodule status --recursive | awk '{ print $2 }' | xargs tar -rf "$K8S_DRIVERS_TAR_FILE"
834+
export K8S_DRIVERS_TAR_FILE=$(./.evergreen/git-archive.sh)
843835
export K8S_TEST_CMD="OIDC_ENV=k8s VARIANT=${VARIANT} ./.evergreen/run-mongodb-oidc-test.sh"
844836
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/setup-pod.sh
845837
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/k8s/run-self-test.sh
@@ -939,13 +931,7 @@ tasks:
939931
script: |-
940932
set -o errexit
941933
${PREPARE_SHELL}
942-
cd src
943-
git add .
944-
git commit --allow-empty -m "add files"
945-
# uncompressed tar used to allow appending .git folder
946-
export AZUREOIDC_DRIVERS_TAR_FILE=/tmp/mongo-java-driver.tar
947-
git archive -o $AZUREOIDC_DRIVERS_TAR_FILE HEAD
948-
tar -rf $AZUREOIDC_DRIVERS_TAR_FILE .git
934+
export AZUREOIDC_DRIVERS_TAR_FILE=$(./.evergreen/git-archive.sh)
949935
export AZUREOIDC_TEST_CMD="OIDC_ENV=azure ./.evergreen/run-mongodb-oidc-test.sh"
950936
bash $DRIVERS_TOOLS/.evergreen/auth_oidc/azure/run-driver-test.sh
951937
@@ -957,13 +943,7 @@ tasks:
957943
script: |-
958944
set -o errexit
959945
${PREPARE_SHELL}
960-
cd src
961-
git add .
962-
git commit --allow-empty -m "add files"
963-
# uncompressed tar used to allow appending .git folder
964-
export GCPOIDC_DRIVERS_TAR_FILE=/tmp/mongo-java-driver.tar
965-
git archive -o $GCPOIDC_DRIVERS_TAR_FILE HEAD
966-
tar -rf $GCPOIDC_DRIVERS_TAR_FILE .git
946+
export GCPOIDC_DRIVERS_TAR_FILE=$(./.evergreen/git-archive.sh)
967947
# Define the command to run on the VM.
968948
# Ensure that we source the environment file created for us, set up any other variables we need,
969949
# and then run our test suite on the vm.

.evergreen/git-archive.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Exit the script with error if any of the commands fail
4+
set -o errexit
5+
6+
# Returns the path to the root archive file which includes all git submodules.
7+
8+
echo "Creating root archive"
9+
export GIT_ARCHIVE_FILE="/tmp/mongo-java-driver.tar"
10+
11+
# create root archive
12+
git archive --output $GIT_ARCHIVE_FILE HEAD
13+
14+
echo "Appending submodule archives"
15+
git submodule status --recursive | awk '{ print $2 }' | xargs tar -rf $GIT_ARCHIVE_FILE
16+
17+
echo "Appending .git directory to the root archive"
18+
tar -rf $GIT_ARCHIVE_FILE .git
19+
20+
echo "$GIT_ARCHIVE_FILE"

0 commit comments

Comments
 (0)