我的项目结构设置如下:
cloudbuild.yaml
requirements.txt
functions/
folder_a/
test/
main_test.py
main.py我需要在我的cloudbuild.yaml中指定什么来获取functions/中每个新编辑的函数,运行它们的测试,然后将这些函数同步到Google Cloud Functions?所有函数都是python37,并使用http作为其触发器。
发布于 2019-06-06 17:03:24
为什么不重新运行测试并在每次代码更改时重新部署?测试更新后的依赖项没有破坏旧的东西,或者你依赖的东西可能已经改变,这是没有坏处的。
我不确定您使用的是什么测试框架,但类似于
steps:
- name: 'python'
args: ['pip3','install', '-r', 'requirements.txt', '--user']
# This installs your requirements and `--user` makes them persist between steps
- name: 'python'
args: ['python3','pytest', 'functions/folder_a/test/'] #run all tests in the tests folder
# Create a task for each function as shown here: https://cloud.google.com/functions/docs/bestpractices/testing#continuous_testing_and_deployment
- name: 'gcr.io/cloud-builders/gcloud']
id: 'deployMyFunction'
args: ['functions', 'deploy', 'my-function', '--source' , 'functions/folder_a/main.py', '--runtime' , 'python37' ,'--trigger-http']
# Option B: Write some python that iterates and deploys each function, although I can't seem to find the Cloud Functions in the python SDK SPI.
- name: 'python'
args: ['python3','deploy.py']
env:
- 'PROJECT_ID=${_PROJECT_ID}'https://stackoverflow.com/questions/56469896
复制相似问题