dev prod in Github repo

jrv
Bronze 2
Bronze 2

Hi,

I have some questions regarding the setup of our Github repo. Initially we want to create several Cloud Functions in the same repository. In our Github repo we have initially a folder "local" and another "cloud".

We would like to develop all the python scripts under "local" and if possible do some unit testing locally. Then if working then move it to "cloud" where it would be automatically pushed to our "dev" project where some integration tests should take place. 
If all integration tests are green then we would move it to the "prod" project.

1) does this setup make sense or are there other best practises?
2) how can we do unit tests locally? the easier and most automated the better
3) is it possible to setup automated integration tests every time we push something to "cloud"?
4) suggestions on how to move from the project "dev" to "prod" with as much automation as possible if all integration tests are green?

Thanks a lot in advance!

3 REPLIES 3

Hi @jrv

You can try below setup

1)  Instead of creating folder in Github , create seperate branch "local" and "cloud"

2) Even testing code in local , create one sandbox project if code is for cloud function.

3) Once code is tested in "Local" branch and deployed successfully in sandbox/dev project , you can push code to Cloud(prod) branch.

4) Make sure to add review / approval at prod branch before actual deployment to validate testing in local.

jrv
Bronze 2
Bronze 2

Thanks @VishalBulbule for the reply

1) what are the advantages here of using branches instead of folders?

2) I am not sure of the suggestion for how can we do unit tests locally, preferably easier and automated 

3) you mean with a Github action that updates the whole "prod" branch with the content of "dev" once everything under "dev" works locally and in the "dev" cloud project?

4) if I understood it correctly a developer will push from "dev" to "prod" branch. Then some automatic testing takes place in  a Github action before being pushed and another developer has to approve this push. Then after aproval another Github action will deploy automatically to the prod project. Is that correct?

Thanks again!

@jrv 

Please find my comments on each query

1) benefits of having branch is your production code always remain protected and updated and dev branch will have latest prod code for new developement and testing with identical code in both branch while deploying code in prod ( just with prod variables like project,connections etc)

2)For Most of the Google cloud services , you have to use sandbox project or dev project for testing , local testing wont assure your for error free production deployment considering permissions,vpc,firewalls etc at google cloud side.

3) Yes , that is correct , if everything in dev tested and validated then you can push to prod with tharough review and approval process.

4) Testing has to be done  while pushing in dev , once tested then it can be approved and merged to prod.