Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continuous Integration using composer

I have a PHP project in which I load packages through Composer. I also run Continious Integration using Jenkins, on a dedicated CI server. Once every hour, Jenkins queries my repository for changes, and if present, if executes a test run.

First step of the testrun is making a fresh checkout of the repository, and performing a build of the application, using Phing. One of the steps of the build is performing an

composer install

Since Jenkins always works with a fresh checkout, composer will always fetch all packages on every test run, even if none of the packages have been changed since the previous run. This has a couple of disadvantages:

  • It takes a relativally long time to complete a test run (composer needs to fetch for example Zend Framework, which is rather large
  • It put unnecessary strain on the packagist server, if new packages are fetched every hour
  • If, for some reason, the composer install fails, so does my test run.

I was thinking of possibly storing the packages that composer fetches on a central spot at the CI server, so Jenkins would be able to access the packages at that location for every test run. Of course, now I have to rewrite part of my application to handle the fact that the vendor folder is in a different location when on the CI server. Secondly, I have to tell Jenkins to keep track of changes on the composer.lock file, to see if he needs to run composer anyway. I'm afraid none of those two things are really trivial.

Does anyone have any suggestions of a other/better way to do this, or is it the best option to just fetch all packages through composer on every test run. Admiditally, it's the best way to make sure you always use the correct packages, but it sortof feels like a waste of bandwith, certainly in later stages of development, when the list of packages will hardly change anymore.

like image 773
rj_bijl Avatar asked Oct 23 '12 12:10

rj_bijl


People also ask

How do I run a Composer in Jenkins?

Add Composer build step Go back to the Jenkins front-end, and configure the project. Add a build step, of the "Execute shell" type, then enter composer install , and click "Save". Now go back to the project's homepage and click "Build Now" and look at the console results.

What is CI CD in big data?

What is CI/CD? Continuous integration and continuous delivery (CI/CD) is a software development approach where all developers work together on a shared repository of code – and as changes are made, there are automated build process for detecting code issues.

What is CI CD used for?

CI/CD is a method to frequently deliver apps to customers by introducing automation into the stages of app development. The main concepts attributed to CI/CD are continuous integration, continuous delivery, and continuous deployment.


1 Answers

One way to speed it up is to use composer install --prefer-dist which only downloads zips even for dev packages. This is preferred for unique builds since it skips the whole history of the project.

As for sparing packagist, don't worry about it too much, one build every hour isn't going to make a huge difference compared to all the open source libs that build on travis at every commit.

like image 164
Seldaek Avatar answered Oct 03 '22 14:10

Seldaek