How can a commit in a git submodule run assembly in continuous integration?

I am working on project A, and A depends on the rapidly developing project B (its main branch).

Therefore, B is a submodule of A, every time I build A, B also rebuilds. In addition, every time B has a new commit, I need to build B and then rebuild A. (Fortunately, the projects are small enough, so compile time is not important).

Now, here is the point. I want to start a new build in Travis CI or other continuous integration services when there is a new commit in projects A or B.

I just tried Github and Travis CI. Reconciliation in project B does not initiate assembly in project A. Is there an easy way to trigger such continuous integration?

+8
source share
2 answers

Commit in project B will not create an assembly in project A

This is expected, given that B has no idea that A. exists.

You will need to record the new state B (new gitlink , special entry in the index ) of project A:

cd /path/to/projectA git submodule update --remote git add . git commit -m "Record new B SHA1 gitlink" git push 

git submodule update --remote updates the submodule B to the last commit of the branch recorded in the A .gitmodules file for B.
See " git tracking submodules of the latter " and " git submodules: specify branch / tag "

Then for A, the new Travis build will start.

If you want to automate the sequence described above, you need a webhook (GitHub) ( or BitBucket ) for projectB and a local listener that, in the push event on repo B, runs the commands mentioned earlier in the local repo of project A.

+7
source

Based on the @VonC question, I solved this problem. Ref https://developer.github.com/webhooks/configuring/

  • I set up the Monitor project, which has two submodules, project A and B
  • Create trigger.rb file in project monitor

Sinatra required

 post '/payload' do system("git submodule update --remote") system("git add .") system("git commit -m Record_new_change") system("git push") puts "Finished handling" end 
  1. Download ngrok , run it on a VPS or long compiler with ./ngrok http 4567 . You can get a link, for example http://7e9ea9dc.ngrok.io
  2. Run ruby trigger.rb
  3. Fork project B to B ', write another script to make sure all commits are in sync with project B'
  4. Go to the project settings page, create a new webhook whose address is http://7e9ea9dc.ngrok.io/payload for projects A and B '
  5. Add Project Monitor to Travis CI

Thus, development for A and B is unaffected, and new builds can start automatically.

+3
source

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


All Articles