Skip to content

Commit 56d3d7a

Browse files
committed
chore: Fix the build script so it works consistently with other projects.
1 parent 8207158 commit 56d3d7a

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

build.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ SCRIPT_FILE="${SCRIPT_DIR}/$(basename "$0")"
2323
##
2424
## These functions should be used to run the local development process
2525
##
26+
function init_venv() {
2627

2728
if [[ ! -d venv ]] ; then
2829
echo "./venv not found. Setting up venv"
2930
python3 -m venv "$PWD/venv"
3031
fi
3132

3233
source "$PWD/venv/bin/activate"
34+
python --version
3335

3436
if which pip3 ; then
3537
PIP_CMD=pip3
@@ -39,10 +41,12 @@ else
3941
echo "pip not found. Please add pip to your path."
4042
exit 1
4143
fi
44+
4245
if ! which nox ; then
43-
python3 -m pip install nox
46+
$PIP_CMD install nox
4447
fi
4548

49+
}
4650

4751

4852
## clean - Cleans the build output
@@ -130,6 +134,7 @@ function write_e2e_env(){
130134
echo "the e2e test suite secrets."
131135
exit 1
132136
fi
137+
local_user=$(gcloud auth list --format 'value(account)' | grep '@google.com' | tr -d '\n')
133138

134139
echo "Getting test secrets from $TEST_PROJECT into $1"
135140
{
@@ -140,10 +145,15 @@ function write_e2e_env(){
140145
val=$(gcloud secrets versions access latest --project "$TEST_PROJECT" --secret="$secret_name")
141146
echo "export $env_var_name='$val'"
142147
done
148+
149+
# Set IAM User env vars to the local gcloud user
150+
echo "export MYSQL_IAM_USER='${local_user%%@*}'"
151+
echo "export MYSQL_USER_IAM='${local_user%%@*}'"
152+
echo "export POSTGRES_IAM_USER='$local_user'"
153+
echo "export POSTGRES_USER_IAM='$local_user'"
154+
143155
# Aliases for python e2e tests
144156
echo "export POSTGRES_CUSTOMER_CAS_PASS_VALID_DOMAIN_NAME=\"\$POSTGRES_CUSTOMER_CAS_DOMAIN_NAME\""
145-
echo "export POSTGRES_IAM_USER=\"\$POSTGRES_USER_IAM\""
146-
echo "export MYSQL_IAM_USER=\"\$MYSQL_USER_IAM\""
147157
} > "$1"
148158

149159
}
@@ -172,6 +182,7 @@ if [[ "$#" -lt 1 ]] ; then
172182
fi
173183

174184
cd "$SCRIPT_DIR"
185+
init_venv
175186

176187
"$@"
177188

0 commit comments

Comments
 (0)