Hello there. I'm at a point where I have to set up a continuous integration environment. I have contributed to projects using CI before, but I have never set it up. I roughly know what it is supposed to do, but I could definitely use some help.

In my head I'm thinking something like this is what should happen (I'm using this for a PHP project):

pre-commit

  • run unit tests
  • check if Sass compiles
  • check if JS compiles (using Webpack)
  • if everything goes well: commit

post-push

  • run the same checks as before (as we cannot be sure that a client has actually tested his code before pushing)
  • composer install
  • compile Sass
  • compile JS (using Webpack)
  • if everything goes well: deploy

deployment

  • Move the whole build to the web server root so that our new build is now live.

Now the questions that I have: how do I automate these processes? Do I locally just use a task runner? What tools could I use to set-up CI on our webserver? Thanks for the feedback!

While I like ideas like CI, one of the issues I take with any of the systems is the idea it should catch all errors. That would be nice but I don't think we're here yet. First, this is CI.

Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

So you're going to have to automate what you can and possibly buy tools for things you think are important but don't have time to create.

Here's my first point. Try automating what you can. Work on it in bite sized chunks.

Here's my next issue. Just because Sass compiles (without error?) doesn't mean it's fine. Consider this statement from http://sass.logdown.com/

Sass has no idea which properties are valid, which HTML elements actually exist, or even to a large extent what the syntax of most @-rules is.

You wrote JS. Now there is a prime oportunity to automate some error checking.

How about some autobot idea like https://github.com/smacleod/reviewbot-jslint ?

Thanks for your reply! Completely agree with what you're saying, but I think that even though it might not be 100% valid CSS that the Sass compiles to, if it doesn't break down it means there is at least a style sheet that works. CSS errors could be there even without Sass, I don't think Sass is the problem there :).

A bigger question for me is though: how do I actually get to automating all this? Do I install tools on the server on which the projects run? Or do I use another server that builds and checks and validates everything and then pushes the valid built package to the server that serves the application (website)?

Let me reveal a few things. I've been sold (doesn't mean I buy them all) ideas on development for decades so I've seen many attempts at improving quality in many ways.

Back to CI. Look at the tutorial found with https://www.google.com/search?q=jenkins+server+continuous+integration

Now back to Earth.

  1. Yes, you would set up a server which you should have already for checkin and then add the compiles and checks you want to implement.
  2. No. As it stands today I do not think it should automatically push the build to deployment without your approval.

  3. CI in real life is rarely complete. That is most folk start with what they can automate in the way of compiler checking, LINT and bound checking then for the result they either report it to a log or the server sends an email on the status. This could be daily, hourly or as you want.

The one big hole almost no one will jump into is to implement CI to the max (full unit test, etc.) since no one I know has the resources to do that. Yes, you may be told you should do that, but bills must be paid, deadlines met.

My answer here is to implement CI in a small way then build on to it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.