I'm trying to set up CI/CD for several Python projects (all GAE/GCF). I can deploy the code just fine but I want to run the entire test suite before the deploy steps. How can I do that? Do I have to setup a whole docker build step in order to get this done or is there a simpler way?
Here's how I do it:
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker build . --tag my_app']
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker tag my_app:latest eu.gcr.io/my_project/my_app']
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker push eu.gcr.io/my_project/my_app']
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker run my_app pytest']
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app', 'deploy', 'app.yaml', '--image-url=eu.gcr.io/my_project/my_app:latest']
I build and tag my container image. Then I push it up to Google Cloud Repo. Then I run my tests with pytest
and then I deploy to Google Cloud Engine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With