travis-ci / beta-features

The perfect place to leave feedback and comments on newly released Beta Features.
56 stars 68 forks source link

Conditional build stages and job pruning #50

Closed SamMousa closed 6 years ago

SamMousa commented 6 years ago

I'm trying to improve CI performance by pruning jobs.

Consider a situation where I have 30 jobs (5 php versions, 6 modules that need testing). Based on the project setup I'm sure that if changes are limited to 1 module there is no need to test the other 5 modules. I can easily identify what changes have been made (git diff --name-only ...).

I'd like to be able to run a prune stage that executes my code, then based on the outcome (re)evaluates job conditions. My pruning stages could for example set environment variables, but the issue is that at that point the jobs have already been created / scheduled.

Currently the only solution is to do this check before each job, which is a small optimization but still requires Travis to prep VMs and clone the repository for each job...

kenman345 commented 6 years ago

I dont know if this solves all the things you wish to fix, but have you considered perhaps making your different jobs/stages check whether it needs to run and have that as an if statement in the builds? If they dont need to be run, then it would skip over running the tests and just pass that job. this can easily be done with a bash script in your tests as well.

Right now I am not aware of anything that allows you to set a condition that checks the commits themselves to see what to run, but perhaps it could be possible in the future.

SamMousa commented 6 years ago

I do that now but it wastes a lot of resources; 20 jobs which still take 2 minutes each for doing nothing..

batter commented 6 years ago

I think this could be done easily if we had the ability to set and share ENV variables across build stages. I made a comment on the build stages open PR saying as much.

Since build stages already has the ability to execute jobs or stages conditionally, you the idea is that you could set an ENV variable in your first stage, and then use it within the conditional evaluation as to whether or not to execute the subsequent job(s) or stage(s).

joshk commented 6 years ago

As Stages is now released and GA, I'm going to close this issue.

If you have any feedback on improvements we should consider, please feel free to add a discussion in our new Community forum: https://travis-ci.community/c/product

Happy building

Josh