I am working on JavaScript and Node.js project. In my project, the dev code of the product and an automated test script framework is placed in different GitHub repositories.
Now, the issue is that I don’t know how to run my test script if any commit is pushed to the Dev repository. As we need to add the .travis.yml file in the repository from where the build will trigger.
I contact the support team they said “you may consider using the API to trigger a build from one repo to another.”
As I’m very new to Travis-ci so, I have no idea how to deal with API.
Can anyone help me to make things happen and can provide more clearance about the things from where I need to start.
It’ll probably be easier to make the test repo a submodule of the dev repo, or check it out manually in the build logic in the dev repo.
(The practical difference is: for a submodule, the SHA of the test repo commit to check out is held statically in Git metadata in the dev repo, while if you check it out manually, you can check out whichever commit you want. On the other hand, Travis checks out submodules automatically by default and if you don’t hold the test commit info in Git metadata, you’ll still need to hold the info necessary to make a decision somewhere).
Then the dev build logic will call the necessary script to run the tests from the resulting checkout.
This way, you’ll see the test result right in the build for the dev commit. If you trigger a build in the test repo instead, that build will have the test result and you won’t readily see in the dev project if a particular commit is good or not.
In the test repo build, use this data to check out the necessary commit from the dev repo
This way, the dev build will always succeed (as long as it could trigger the test build) and you won’t see the test result in the dev repo. To pass the result to the dev build, you’ll need to somehow stall in the dev build and wait for the test build result (via Travis API). You can easily run into the job time limit, and it will be wasting your credits (if you’re on a credits-based plan) or a concurrency unit (if on a concurrency-based plan) while waiting.
This is why I see this way as an unnecessary complication and do not recommend it.
Didn’t quite understand what “request info” you’re referring to.
The links and information I gave show how to make the request and how to pass additional information to the triggered build with it.
In the build logic. I.e. either in .travis.yml directly, or in some script that it will call.
If you wish me to make a full solution for your specific case, I can do that for a couple of bucks. PM me if you’re interested. I’ll require additional info since in the light of your last message, even your goals are unclear.