Have you eaten plastic today?

Imagine you walk along the Bosphorus seashore in Istanbul. And then you ordered ”balik ekmek” from the vendors, planning to enjoy tasty with breathtaking sea view. Suddenly, you see multiple variety…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Automate your Unit Testing on every Git Push

You built an app. You thought it was perfect. You’re wrong.

You revise an app again. You tested it and thought it was perfect. Again, you’re wrong.

Every time you revise your app, you have to re-test everything, you think that was stupid. So, you use Unit Testing to do these dirty jobs.

Everything seems perfect now. Except that you have to remember to run unit testing each and every time you revise your app. How can we automate this?

Biztory CodePipeline to manage CI/CD workflow

We leverage on AWS CodePipeline to manage our CI/CD process, from git commit to deployment. In this article, we will explore how can we implement PHPUnit to be part of our workflow, so that only if the new revision passes the tests, it will flow down to next stage for deployment.

We are going to use AWS CodeBuild as a micro-service to run PHPUnit on the newly pushed revision. This is what we going to do here:

I actually write my DockerFile based on the sample given from AWS DevOp, and customized to PHP 5.6 and PHPUnit 4.3.5. I have also included MySQL and MCrypt in my build.

Next, build your Docker.

Now, you have to host your Docker image on Amazon ECR so that you can link it into CodeBuild later.

Amazon ECR to create your own Docker image repository

After you created the repo, simply follow the instruction given to push it over.

You should see your pushed image on the main tab.

Last but not least, grant the permission so that it allows CodeBuild to pull this image and setup the container later. Navigate to Permission tab and add a new policy, and allow ecr:GetDownloadUrlForLayer, ecr:BatchGetImage and ecr:BatchCheckLayerAvailability.

Let’s configure a new CodeBuild project to link with your docker image.

I left the rest untouched as default. As I have already run composer install in my codebase, I only instruct CodeBuild to run phpunit during testing phase.

Voila! You are ready to test your codes using CodeBuild. You may head over to try run just to get a feel how it works on CodeBuild.

CodeBuild returns as Failed where unit testing hit errors.

Lastly, simply slot in a build phase into your CodePipeline and point it to your fresh baked build project.

Now, make a commit and push it, sit back and wait for it to flow through your pipeline.

Have something to say? Drop me a PM or comment below.

Add a comment

Related posts:

5 skills needed to become a paid professional content writer in 2018.

Of course! Content writing is your passion, guess what, so is the case with the next-door neighbour who reads Vogue and runs a fashion blog on Drupal. It is clear that every individual gets an equal…

Yuko Kitchen

In an attempt to be adventurous with my food choices, and a result of finally being sick of vegan West Hollywood cuisine, my colleague and fellow food connoisseur Zoe (@EatThisUp on Substack) and I…

Just a Rubber Ducker!

Welcome to the quacktastic world of $DUCKER, the ultimate meme coin for all you rubber ducky enthusiasts out there! We’re not just another spin-off, we’re a coin that builds its own culture…