Created
June 14, 2021 22:06
-
-
Save edvasqueza/f7b588fdf6fe157f6c8fa3f1945b0e55 to your computer and use it in GitHub Desktop.
Cloudbuild for running a test database or any service required to run in the cloudbuild network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Thanks to: https://github.com/GoogleCloudPlatform/cloud-builders/issues/376#issuecomment-594094378 | |
| steps: | |
| # Runs postgresql | |
| - name: gcr.io/cloud-builders/docker | |
| id: boot-postgres | |
| args: [ 'run', '-d', '--publish=5432:5432', '--env=POSTGRES_PASSWORD=postgres', '--network=cloudbuild', '--name=postgres', 'postgres:9.6-alpine', '-N', '500' ] | |
| waitFor: [ '-' ] | |
| # Wait until postgresql is available | |
| - name: jwilder/dockerize:0.6.1 | |
| id: await-postgres | |
| args: [ 'dockerize', '-timeout=60s', '-wait=tcp://postgres:5432' ] | |
| waitFor: [ 'boot-postgres' ] | |
| # Runing nose2 tests using the postgres container, as example | |
| - name: 'python:3.8-slim-buster' | |
| id: unit-tests | |
| entrypoint: bash | |
| env: | |
| - 'INSTANCE_CONNECTION_NAME=postgres' | |
| - 'POSTGRES_USER=postgres' | |
| - 'POSTGRES_PASSWORD=postgres' | |
| - 'POSTGRES_DATABASE=postgres' | |
| - 'POSTGRES_PASSWORD=postgres' | |
| args: | |
| - '-c' | |
| - | | |
| apt-get update && apt-get install -y libpq-dev && \ | |
| venv/bin/nose2 --verbose -s . -c tests/configurations/nose2-ci.cfg tests | |
| waitFor: [ 'await-postgres', 'pip-install' ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment