Skip to content

Commit

Permalink
fix(ci): use script over args in all cloudbuild (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuan325 authored Apr 1, 2024
1 parent b5aa667 commit da8d3f6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 64 deletions.
15 changes: 6 additions & 9 deletions llm_demo/langchain_tools.int.tests.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ steps:
- id: "Deploy to Cloud Run"
name: "gcr.io/cloud-builders/gcloud:latest"
dir: llm_demo
entrypoint: /bin/bash
args:
- "-c"
- |
script: |
#!/usr/bin/env bash
gcloud run deploy ${_SERVICE} \
--source . \
--region ${_REGION} \
Expand Down Expand Up @@ -46,7 +44,7 @@ steps:
-H 'Content-Type: application/json' \
-d '{"prompt":"How can you help me?"}' \
$$URL/chat)
if grep -q "400" <<< "$msg"; then
echo "Chat Handler Test: PASSED"
else
Expand All @@ -64,15 +62,14 @@ steps:
- id: "Delete image and service"
name: "gcr.io/cloud-builders/gcloud"
entrypoint: "/bin/bash"
args:
- "-c"
- |
script: |
#!/usr/bin/env bash
gcloud artifacts docker images delete $_GCR_HOSTNAME/$PROJECT_ID/cloud-run-source-deploy/$_SERVICE --quiet
gcloud run services delete ${_SERVICE} --region ${_REGION} --quiet
serviceAccount: "projects/$PROJECT_ID/serviceAccounts/[email protected]" # Necessary for ID token creation
options:
automapSubstitutions: true
logging: CLOUD_LOGGING_ONLY # Necessary for custom service account
dynamic_substitutions: true

Expand Down
15 changes: 6 additions & 9 deletions llm_demo/vertexai_function_calling.int.tests.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ steps:
- id: "Deploy to Cloud Run"
name: "gcr.io/cloud-builders/gcloud:latest"
dir: llm_demo
entrypoint: /bin/bash
args:
- "-c"
- |
script: |
#!/usr/bin/env bash
gcloud run deploy ${_SERVICE} \
--source . \
--region ${_REGION} \
Expand Down Expand Up @@ -46,7 +44,7 @@ steps:
-H 'Content-Type: application/json' \
-d '{"prompt":"How can you help me?"}' \
$$URL/chat)
if grep -q "400" <<< "$msg"; then
echo "Chat Handler Test: PASSED"
else
Expand All @@ -64,15 +62,14 @@ steps:
- id: "Delete image and service"
name: "gcr.io/cloud-builders/gcloud"
entrypoint: "/bin/bash"
args:
- "-c"
- |
script: |
#!/usr/bin/env bash
gcloud artifacts docker images delete $_GCR_HOSTNAME/$PROJECT_ID/cloud-run-source-deploy/$_SERVICE --quiet
gcloud run services delete ${_SERVICE} --region ${_REGION} --quiet
serviceAccount: "projects/$PROJECT_ID/serviceAccounts/[email protected]" # Necessary for ID token creation
options:
automapSubstitutions: true
logging: CLOUD_LOGGING_ONLY # Necessary for custom service account
dynamic_substitutions: true

Expand Down
6 changes: 3 additions & 3 deletions retrieval_service/alloydb.tests.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ steps:
secretEnv:
- DB_USER
- DB_PASS
script: |
script: |
#!/usr/bin/env bash
# Create config
cp example-config.yml config.yml
sed -i "s/127.0.0.1/${_DATABASE_HOST}/g" config.yml
sed -i "s/my_database/${_DATABASE_NAME}/g" config.yml
sed -i "s/my-user/$$PGUSER/g" config.yml
sed -i "s/my-password/$$PGPASSWORD/g" config.yml
sed -i "s/my-user/$$DB_USER/g" config.yml
sed -i "s/my-password/$$DB_PASS/g" config.yml
- id: Run Alloy DB integration tests
name: python:3.11
Expand Down
17 changes: 3 additions & 14 deletions retrieval_service/app.tests.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,11 @@ steps:
- id: Install dependencies
name: python:3.11
dir: retrieval_service
entrypoint: pip
args:
[
"install",
"-r",
"requirements.txt",
"-r",
"requirements-test.txt",
"--user",
]
script: pip install -r requirements.txt -r requirements-test.txt --user

- id: Run retrieval service app tests
name: python:3.11
dir: retrieval_service/app
entrypoint: /bin/bash
args:
- "-c"
- |
script: |
#!/usr/bin/env bash
python -m pytest app_test.py
43 changes: 14 additions & 29 deletions retrieval_service/cloudsql.tests.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,21 @@ steps:
- id: Install dependencies
name: python:3.11
dir: retrieval_service
entrypoint: pip
args:
[
"install",
"-r",
"requirements.txt",
"-r",
"requirements-test.txt",
"--user",
]
script: pip install -r requirements.txt -r requirements-test.txt --user

- id: Update config
name: python:3.11
dir: retrieval_service
secretEnv:
- PGUSER
- PGPASSWORD
entrypoint: /bin/bash
args:
- "-c"
- |
- DB_USER
- DB_PASS
script: |
#!/usr/bin/env bash
# Create config
cp example-config-cloudsql.yml config.yml
sed -i "s/my_database/${_DATABASE_NAME}/g" config.yml
sed -i "s/my-user/$$PGUSER/g" config.yml
sed -i "s/my-password/$$PGPASSWORD/g" config.yml
sed -i "s/my-user/$$DB_USER/g" config.yml
sed -i "s/my-password/$$DB_PASS/g" config.yml
sed -i "s/my-project/$PROJECT_ID/g" config.yml
sed -i "s/my-region/${_CLOUDSQL_REGION}/g" config.yml
sed -i "s/my-instance/${_CLOUDSQL_INSTANCE}/g" config.yml
Expand All @@ -55,15 +44,10 @@ steps:
- "DB_REGION=${_CLOUDSQL_REGION}"
- "DB_INSTANCE=${_CLOUDSQL_INSTANCE}"
secretEnv:
- PGUSER
- PGPASSWORD
entrypoint: /bin/bash
args:
- "-c"
- |
# Set env var expected by tests
export DB_USER=$$PGUSER
export DB_PASS=$$PGPASSWORD
- DB_USER
- DB_PASS
script: |
#!/usr/bin/env bash
python -m pytest datastore/providers/cloudsql_postgres_test.py
substitutions:
Expand All @@ -75,10 +59,11 @@ substitutions:
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/cloudsql_pass/versions/latest
env: PGPASSWORD
env: DB_PASS
- versionName: projects/$PROJECT_ID/secrets/cloudsql_user/versions/latest
env: PGUSER
env: DB_USER

options:
automapSubstitutions: true
substitutionOption: 'ALLOW_LOOSE'
dynamic_substitutions: true

0 comments on commit da8d3f6

Please sign in to comment.