Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion golang-sample/test.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ steps:
args:
- '-c'
- |
gsutil rm gs://${_BUCKET_NAME}/${SHORT_SHA}_test_log.xml
gcloud storage rm gs://${_BUCKET_NAME}/${SHORT_SHA}_test_log.xml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To make the cleanup step more robust, consider adding the --ignore-not-found flag. This will prevent the step from failing if the test log file doesn't exist (for example, if the test step failed before creating the log). This is generally a good practice for cleanup scripts to ensure they are idempotent and don't fail unnecessarily.

        gcloud storage rm --ignore-not-found gs://${_BUCKET_NAME}/${SHORT_SHA}_test_log.xml

gcloud artifacts docker images delete us-central1-docker.pkg.dev/${PROJECT_ID}/${_AR_REPO_NAME}/myimage:${SHORT_SHA}
gcloud run services delete helloworld-${SHORT_SHA} --region us-central1 --quiet
2 changes: 1 addition & 1 deletion python-example-flask/test.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ steps:
args:
- '-c'
- |
gsutil rm gs://${_BUCKET_NAME}/${SHORT_SHA}_test_log.xml
gcloud storage rm gs://${_BUCKET_NAME}/${SHORT_SHA}_test_log.xml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve the robustness of this cleanup step, I recommend adding the --ignore-not-found flag. This ensures that the build step won't fail if the specified test log file is not found in the bucket, which can happen if the preceding test step failed. This makes the cleanup logic more resilient.

        gcloud storage rm --ignore-not-found gs://${_BUCKET_NAME}/${SHORT_SHA}_test_log.xml

gcloud artifacts docker images delete us-central1-docker.pkg.dev/${PROJECT_ID}/${_ARTIFACT_REGISTRY_REPO}/myimage:${SHORT_SHA}
gcloud run services delete helloworld-${SHORT_SHA} --region us-central1 --quiet
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ steps:
args:
- '-c'
- |
gsutil rm gs://${_BUCKET_NAME}/${SHORT_SHA}_test_log.xml
gcloud storage rm gs://${_BUCKET_NAME}/${SHORT_SHA}_test_log.xml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For a more resilient cleanup process, it's a good idea to add the --ignore-not-found flag here. This will prevent the cleanup step from failing if the test log file doesn't exist, which could happen if the tests didn't run or failed to produce a log. This makes the cleanup script more reliable.

        gcloud storage rm --ignore-not-found gs://${_BUCKET_NAME}/${SHORT_SHA}_test_log.xml

gcloud artifacts versions delete 0.0.1 -q --package python-example-noncontainer-artifacts --repository $_ARTIFACT_REGISTRY_PYTHON_REPO --location us-central1