Gil 🐲

@gil_x

Early-stage Startup CTO survival guide - Part 2

Collaboration and quality

Last time, we left our startup with a basic setup. Just enough to release MVP and validate the idea.

Also, guess what, start-up “Medium for pets” is shaping to be quite a success!

Photo by taylor griffith on Unsplash

Since the project had some financial wins, you hired the first two members of your technical team. Nico, front end, and Sally as a backend developer.

Now your task as a CTO of the early-stage startup that is doing well is to set up a proper infrastructure for collaboration and quality assurance.

At the moment the application is hosted on your buddies server and every time you change something you need to FTP and upload a modified file and then ask your teammates to download changes. Ouch!

Let’s Collaborate!

With the team in place, there has to be a way to collaborate and share code. Here systems like GIT come in handy. Since GIT is opensource software, we could install and host the central/remote repository on our own, but we are not in the business of hosting distributed version control systems. We would certainly need an easy way to control access, request merging into the main branch and ability to review code submitted by our team members.

Photo by Anoir Chafik on Unsplash

There are many options to choose from here. One of the most interesting solutions in this field is GitLab. Initially started as an opensource clone of super popular GitHub (acquired by Microsoft), GitLab is very advanced, feature rich, preferred by many, solution. We will opt for SaaS (hosted) solution that GitLab offers, although it is possible to use their community edition and set it up and run on your own. We will also choose our workflow, so everyone is on the same page in regards to the course. To keep things simple and flexible we will go for GitHub Flow.

With all set up we should be able to create feature branches and push our code to the central repository where we could open pull/merge request and let our peer reviewers rip our code apart as the first line of our code quality defense. However, this is just a beginning.

Automatic & continuous quality

Having code inside the git repository gives us the ability to compare versions of software and to track changes on a very granular level. We can review line by line what is going on and preserve quality and standards we defined with our team. On its own, that is immensely useful! However, we could do even better.

If only there is a way to automatically check the recently submitted code for standard compliance, standard violation, and bugs. Plus, if we can run our unit and acceptance test suites automatically too, that would be genuinely cool!

We need some system that will detect changes in our git repository, pull a new code, perform some cleanup and run few commands.

Photo by Nathan Fertig on Unsplash

For many people’s go-to automation server is Jenkins. It is an open-source solution battle tested over many years. Jenkins is quite easy to set up for a basic usage. Functionality is extendable through a plethora of plugins made for almost any conceivable integration. Possibility to distribute work across multiple machines makes running builds, tests, and deployments very fast.

Even though all this sounds amazing, we need to look at other managed solutions, offered as a service, as our team is quite small and cannot run additional software system as their primary goal is to deliver a fantastic product.

Travis CI is one of the oldest hosted automation servers out there, and it has won the trust of many folks, especially GitHub users and opensource project maintainers. Company Cloudbees, a big supporter of the Jenkins project, acquired CodeShip, which is another strong contender to fill our automation server spot. Few other products, worth mentioning, praised for their speed and simplicity are Semaphore CI and Circle CI.

Picking proper solution for automation is genuinely hard, given the vastness of choices. However, taking into consideration that we are a small startup with limited tech resources, we need to opt for the “cheapest” and most convenient in all regards. As we already decided to use GitLab as our solution for code versioning and storage, we can not overlook their offering in automation space, GitLab CI.

With GitLab CI we can write and commit pipeline and job description file to our repository, and with minimal configuration effort in its UI, in no time we can have build, quality and test job running.

# .gitlab-ci.yml
stages:
- build
- test
- quality

build:
stage:
build
script:
- php composer.phar install -o

code_test:
stage:
test
- php ./vendor/bin/phpunit

code_quality:
stage:
quality
- codeclimate analyze -f text app

For ensuring quality, we are going to use Code Climate analysis platform.
Code Climate supports a lot of different “engines” that usually perform static analysis of your code and looks for potential problems within the source code, like possible bugs, suboptimal code, overcomplicated expressions, and unused parameters, methods, or properties. Also helps you detect violations of a defined coding standard. Supported engines include PHP Code Sniffer, PHP Mess Detector, Pylint, Radon, Rubocop, TSLint, SonoraJava, SonoraPHP …
You get the idea. Code Climate covers quality.

# .codeclimate.yml
plugins:
phpcodesniffer:
enabled:
true
config:
standard:
"PSR1,PSR2"

Our test job will use a tools like PHPUnit, Unittest (python), MochaJS, JUnit, Behat, RSpec.

With all our collaboration (Git, GitLab) and automation tools (GitLab CI, CodeClimate) in place and running, we have upped our team’s game manifold.

Win-win-win 🎉🎉🎉

Our team has the best of breed tools for code management, testing, and quality analysis. Everytime team member pushes their work to the repository, code is available for everyone to review, it is automatically tested, and quality score is immediately accessible. Bye bye, technical debt.

With this level of confidence, we are ready to talk about one-click-deploy directly to the production servers!

But, more about that next time!

Thanks for reading! If you enjoyed this story, please click the 👏 button and share to help others find it! Feel free to leave a comment 💬 below.
Have feedback? Let’s be friends
on Twitter.

More by Gil 🐲

Topics of interest

More Related Stories