My project structure is as follows:
cloudbuild.yaml
requirements.txt
functions/
folder_a/
test/
main_test.py
main.py
My cloudbuild.yaml
steps:
# Install
- name: 'docker.io/library/python:3.7'
args: ['pip', 'install', '-t', '/workspace/lib', '-r', 'requirements.txt']
# Test
- name: '?'
args: ['pytest', 'functions/**/*_test.py']
What builder do I use to run pytest? I just installed it using the previous install step. Should I use that same docker image? How do I stop my build from passing until pytest successfully finishes all tests?
Each step runs in a separate container, so you should do it all in one step:
steps:
# This step runs the unit tests on the app
- name: 'docker.io/library/python:3.7'
id: Test
entrypoint: /bin/sh
args:
- -c
- 'pip install -t /workspace/lib -r requirements.txt && pytest functions/**/*_test.py'
See "GitOps-style continuous delivery with Cloud Build" for more details.
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