How to distribute the generated Thrift code in a development and production environment using Git?

How do you manage the generated source code files in your repositories and deployment procedures using Git (PHP, Python, etc.)?

For example, I have a repository named “interfaces” with Thrift definitions. They can be converted to Python, PHP, JS, etc. Skeletons / stubs. Other projects in different languages, each in their own repository, want to use these stubs. How to deliver stubs to projects?

I see only two ways:

  • Create stub files and save them in the “interfaces” repository, and this repository should be attached to the projects (as soon as for the submodule or in any other way). But this method introduces a lot of headaches when checking for interface updates and stubs due to the complex concepts of "git subodules".

  • Attach a clean "interface" repository to each project and create stub files as temporary git -ignorable (!) Files (using "make stubs" or similar). Thus, each project can have its own generation settings using its own patches (if necessary at all). But you need to introduce some compilation commands into the PHP / Python development and production environment (and not just git pull).

What are the pros and cons of these approaches?

+4
source share
2 answers

As a rule, it is best to use the “generation” route along the “save generated content” route, mainly because you are not always 100% sure of the current status of the specified generated content: is it synchronized with the sources?

Capturing after receiving can take care of push to create relevant content.
See Git Hooks or Pro-Git hooks .
However, in your own local instance (i.e., on git pull ), an alias can combine pulling and creating the specified content.

+4
source

I think # 2 is the way to go, if nothing else, because you don't want git to automatically generate the generated files.

In your php or python application initialization code, you can check the timestamp on idl files and generated stubs, as well as give a warning and / or interrupt or run the trift compiler, if available.

0
source

Source: https://habr.com/ru/post/1382134/


All Articles