8 Nonsensical Reasons to Redesign a Website

Post pobrano z: 8 Nonsensical Reasons to Redesign a Website

Websites
are businesses’ online window to the world. And just like real windows, these
online windows look worn out and rusty with time. Meaning, website redesigning
shouldn’t be a nice-to-have strategy. It should be a necessity.

Even
so, you cannot simply undertake website redesigning just because your
competitor has done so, or just because you feel like it. Given the kind of
money involved, (the average cost of web redesign is
$43,000), a lot of thinking and re-thinking needs to be done before you could go ahead with your website re-designing plans.  

According to a Hubspot report, 38% of the companies did
not experience any improvement in their performance after a redesign. Turned
out, the dissatisfaction stemmed from the fact that the re-designing was
undertaken for all the wrong reasons.  

So, are you planning to redesign your website
in the future? If so, no matter what, don’t do it for the below-mentioned
reasons.

1. To Add Sparkling New Features

To use a cliche, everything that glitters is not gold. So, if you think those sliders, parallax scrolling, rotating images, scrolling logos and more are a must for your site, think again.  Hot new trends keep invading the website landscape every single year. That doesn’t mean every trend is good for your site. For example, sliders are clicked by as few as 1% of visitors. Even with regards to parallax scrolling people may not like to scroll infinitely on a homepage.

To cut to the chase, find out what works for
your audience and stick with it. You could even think of running user tests
through software such as HotJar for existing users and UsabilityHub for new
users, before introducing new features to your website. User tests will help you
decide whether or not a redesign is required. 
    

2. To Make it more SEO-Optimized

Majority
of the time businesses redesign to SEO-optimize their website, which, in turn, helps
draw more traffic to the traffic. Of course, traffic is paramount. However, the
question is: Whether this traffic is getting converted into more subscribers,
leads, and customers?

No
doubt, the launch of a search-optimized website could lead to a good jump in
Google rankings. But according to SEO experts, such jumps are typically
flash-in-the-pan types.

For
your rankings to climb and last longer on Google, the focus should be on
building quality content on a consistent basis. 
Search engines love websites that offer fresh content, fresh offers and are
written for people and not for robots.  

3. To Make Visitors Stick around your Site Longer  

If visitors are finding it hard to stick
around your site, then obviously the first thing that crosses your mind is that
your website design is not good enough.  

However, the fact is, just addressing design
issues is just not enough. There could be other problems as well such as navigation,
badly written copy and so on.  

Long story short, go back to your Web Design
101 fundamentals to make sure whether you have taken care of the fundamentals
before planning a full-fledged design overhaul. Or, you could even consult top web design companies
to know whether your site needs a redesign or not.

4. To Beat Competitor Hands Down

Tell me one thing: Will you overhaul your wardrobe just because the colleague sitting next to you just did the same. No, right. You have budget constraints and, more importantly, you may not be such a clotheshorse like your colleague.

Likewise, if your competitor is overhauling
their website, doesn’t mean you too follow in their footsteps. Sure, you need
to keep a watch on your competitors. But like a monkey, you don’t mimic
everything that comes your way. The design overhaul may have worked out for
your competitor, but then there’s no surety that it will work for your site as
well.    

Simply put, focus on building high-value
content that brings in thousands of leads rather than aping your competitors
blindly without knowing whether it would bring in the desired results or not.
To generate lead-worthy content, you could take help of some top content marketing agencies.

5. To make Website more Product-centric

Are you witnessing slow sales? If yes, the
first thing most businesses undertake is redesigning their product pages.

However, the fact is, most websites are
already product-centric. And, let’s face it, being product-centric doesn’t help
accelerate sales. Rather, the sites should be more customer-centric. The goal
of any website should be to be as customer-friendly as possible by offering
visitors the information they need wherever they are in the customer journey.

It helps to remember, people don’t remember
the content they read on the product pages; however, they do remember the
experience. So, think of delighting your customers rather than focussing on
re-designing your product pages.   

6. To Launch PR Campaigns 

You have decided to relaunch your website
with sparkling new features and all so that you could be in the public eye. And
so that you could be the talk of the town. So that you could come up with a
press release announcing all the big bang changes you have made to your site.   

The fact is, just making your PR factory work
around-the-clock won’t get you the desired results There’s more to an
authoritative website than meets the eye. And it has more to do with creating
valuable content that people love to consume and also transforming yourself
into an educational hub that each one in the industry is interested in to find
information from. 

7. To Attract More Leads

If anything, generating leads is also one of
the most important reasons that make businesses think about redesigning every
so often. 

However, focussing on generating more and more leads won’t really help convert into sales. Rather focus on generating fewer leads of a higher quality than wasting time on useless ones.

8.  For a Complete Business Facelift

More often than not businesses are not happy
with the way things are moving. They wish to re-start from the scratch and work
toward a new beginning.

However, thinking of redesigning the website,
as the first step toward recreating a company, may not bring you the desired
results. In other words, outside appearances only matter so much. You may need
to work on the inside as well to get the desired results. In other words, you
may have to re-visit your values, company culture, vision, mission and so on
rather than giving your website a facelift. 
    

Putting it all together

There you are! 8 nonsensical reasons for getting
your website
designed
. And, believe me, whether these reasons seem sensible to
you or not, businesses do undertake web redesigning for the above-mentioned
reasons. So, if you intend to redesign your website, go beyond looks and see
how it works as well. And, more than anything else focus on creating valuable
content for each buyer persona.

A book about the work of Japanese ty

Post pobrano z: A book about the work of Japanese ty

Even if you love typography, there are chances that you don’t know Takenobu Igarashi yet. The Japanese designer is more famous in his home country, but his work is definitively worth a look.

A recent crowdfunding campaign launched in Japan gives you the perfect opportunity to discover the 3D lettering of the type master. In this monograph, you will get a great overview of the designer’s work and acquire a piece of graphic design history.

A book about the work of Japanese ty

Post pobrano z: A book about the work of Japanese ty

Even if you love typography, there are chances that you don’t know Takenobu Igarashi yet. The Japanese designer is more famous in his home country, but his work is definitively worth a look.

A recent crowdfunding campaign launched in Japan gives you the perfect opportunity to discover the 3D lettering of the type master. In this monograph, you will get a great overview of the designer’s work and acquire a piece of graphic design history.

A book about the work of Japanese ty

Post pobrano z: A book about the work of Japanese ty

Even if you love typography, there are chances that you don’t know Takenobu Igarashi yet. The Japanese designer is more famous in his home country, but his work is definitively worth a look.

A recent crowdfunding campaign launched in Japan gives you the perfect opportunity to discover the 3D lettering of the type master. In this monograph, you will get a great overview of the designer’s work and acquire a piece of graphic design history.

A book about the work of Japanese ty

Post pobrano z: A book about the work of Japanese ty

Even if you love typography, there are chances that you don’t know Takenobu Igarashi yet. The Japanese designer is more famous in his home country, but his work is definitively worth a look.

A recent crowdfunding campaign launched in Japan gives you the perfect opportunity to discover the 3D lettering of the type master. In this monograph, you will get a great overview of the designer’s work and acquire a piece of graphic design history.

Incredible Ways You Can Earn Profits Online

Post pobrano z: Incredible Ways You Can Earn Profits Online

Image Credit: Štefan Štefančík

There are so many
ways to earn some extra cash online, that it’s almost possible to live your
life without having to leave your house. Especially now, when you can work
remotely and online.

Your job can be
anything you like – you can still work for a corporation, become a freelance or
create an online business of your own. Relying on the latest ecommerce trends, the digital world
online is the best place to make some amazing profits nowadays.

Sell Online Courses

Learning is
something people and companies are really confident spending money on, because
it is an investment to yourself, to your career, and the quality of your work.
So why not create and sell online courses? You
can teach people anything – starting with languages and ending with complex web
development.

Become a Famous YouTuber

Well yes, it will
take time to become famous, but you can start doing it today. For some, it
takes longer, but there are YouTubers who manage to become successful very fast
and become viral. Maybe try reviewing some other famous viral videos and
incorporate it into your own video by using a video downloader.

Start an e-shop

Image credit: Igor Miske

Choose a product
you believe in, buy a domain and start selling. Make sure you use an online survey to learn what your
customers think about you and your business. It’s crucial to know these things
when your business is still fresh – learn what you’re doing good and learn from
your mistakes.

Event Planning

That’s right, it
is absolutely possible to organize events online, especially if you like to
communicate with other people. You can settle up with specialized events or
have a very wide range instead. But what you will truly need is a website and
for your website – an amazing template that can be found on template express.

Blogging

Blogging is great for three things: it’s an
amazing tool for self-realization, spreading your ideas and words, changing the
world. The two other purposes might be creating a community and making a
business out of it. Both can be profitable. You can sell your own services or
products on your blog or recommend other businesses to your community.

Graphic Design

Graphic designers
are very needed in the digital market – we need them for our website design,
logo design, print, and especially for social media content creation. Sign
up Crello
to make things faster – it’s a tool every
designer should have on their list. It has 33 formats, over 12 000 templates,
and so much more.

Email Marketing

Whatever the field
you choose, any kind of business you decide to start and build from zero you’ll
need to promote it at all times, in the beginning – the most. Therefore email
marketing is something that can be very profitable to do. To create the best email
and promotions, try out the best
mailchimp alternative
ever.

SEO consulting

Image Credit: rawpixel

Search engine
optimization is a service that every business has, needs, or doesn’t know yet,
but still needs it. You know what they say – if you are not on the web, you
basically do not exist. So if you know much about SEO and how to optimize it –
the success is waiting for you. When your business peeks, you might want to
have a logo – for the best logo ideas, you could start a logo
contest.

Become
a Nutritionist

In the famous body cult nowadays and fast
lifestyle, many people are worried about their looks. But a big part of these
people are too shy to go to the gym and rather prefers dieting. You’d be
surprised, how many people actually want to do it professionally, with an
experienced nutritionist. You could be the one to help other people love
themselves again.

Travel
Consulting

Many people love to travel and explore the
world. If you are one of these people and have some experience in traveling,
you can help other people plan their trips and vacations. You can earn money
either by planning or by helping people find better deals for travel tickets
and still have a profit out of it.

Technical
Support

Image Credit: True Agency

The best idea for those who study, work or
have worked with IT is remote technical support. It can be done as an
additional job or as a separate business – it depends on how many time you
have. Everything’s very digitized today, so you can be sure you’ll always have
work to do, technical support is a very needed service for all businesses.

Incredible Ways You Can Earn Profits Online

Post pobrano z: Incredible Ways You Can Earn Profits Online

Image Credit: Štefan Štefančík

There are so many
ways to earn some extra cash online, that it’s almost possible to live your
life without having to leave your house. Especially now, when you can work
remotely and online.

Your job can be
anything you like – you can still work for a corporation, become a freelance or
create an online business of your own. Relying on the latest ecommerce trends, the digital world
online is the best place to make some amazing profits nowadays.

Sell Online Courses

Learning is
something people and companies are really confident spending money on, because
it is an investment to yourself, to your career, and the quality of your work.
So why not create and sell online courses? You
can teach people anything – starting with languages and ending with complex web
development.

Become a Famous YouTuber

Well yes, it will
take time to become famous, but you can start doing it today. For some, it
takes longer, but there are YouTubers who manage to become successful very fast
and become viral. Maybe try reviewing some other famous viral videos and
incorporate it into your own video by using a video downloader.

Start an e-shop

Image credit: Igor Miske

Choose a product
you believe in, buy a domain and start selling. Make sure you use an online survey to learn what your
customers think about you and your business. It’s crucial to know these things
when your business is still fresh – learn what you’re doing good and learn from
your mistakes.

Event Planning

That’s right, it
is absolutely possible to organize events online, especially if you like to
communicate with other people. You can settle up with specialized events or
have a very wide range instead. But what you will truly need is a website and
for your website – an amazing template that can be found on template express.

Blogging

Blogging is great for three things: it’s an
amazing tool for self-realization, spreading your ideas and words, changing the
world. The two other purposes might be creating a community and making a
business out of it. Both can be profitable. You can sell your own services or
products on your blog or recommend other businesses to your community.

Graphic Design

Graphic designers
are very needed in the digital market – we need them for our website design,
logo design, print, and especially for social media content creation. Sign
up Crello
to make things faster – it’s a tool every
designer should have on their list. It has 33 formats, over 12 000 templates,
and so much more.

Email Marketing

Whatever the field
you choose, any kind of business you decide to start and build from zero you’ll
need to promote it at all times, in the beginning – the most. Therefore email
marketing is something that can be very profitable to do. To create the best email
and promotions, try out the best
mailchimp alternative
ever.

SEO consulting

Image Credit: rawpixel

Search engine
optimization is a service that every business has, needs, or doesn’t know yet,
but still needs it. You know what they say – if you are not on the web, you
basically do not exist. So if you know much about SEO and how to optimize it –
the success is waiting for you. When your business peeks, you might want to
have a logo – for the best logo ideas, you could start a logo
contest.

Become
a Nutritionist

In the famous body cult nowadays and fast
lifestyle, many people are worried about their looks. But a big part of these
people are too shy to go to the gym and rather prefers dieting. You’d be
surprised, how many people actually want to do it professionally, with an
experienced nutritionist. You could be the one to help other people love
themselves again.

Travel
Consulting

Many people love to travel and explore the
world. If you are one of these people and have some experience in traveling,
you can help other people plan their trips and vacations. You can earn money
either by planning or by helping people find better deals for travel tickets
and still have a profit out of it.

Technical
Support

Image Credit: True Agency

The best idea for those who study, work or
have worked with IT is remote technical support. It can be done as an
additional job or as a separate business – it depends on how many time you
have. Everything’s very digitized today, so you can be sure you’ll always have
work to do, technical support is a very needed service for all businesses.

Continuous Integration: The What, Why and How

Post pobrano z: Continuous Integration: The What, Why and How

Not long ago, I had a novice understanding of Continuous Integration (CI) and thought it seemed like an extra process that forces engineers to do extra work on already large projects. My team began to implement CI into projects and, after some hands-on experience, I realized its great benefits, not only to the company, but to me, an engineer! In this post, I will describe CI, the benefits I’ve discovered, and how to implement it for free, and fast.

CI and Continuous Delivery (CD) are usually discussed together. Writing about both CI and CD within a post is a lot to write and read about all at once, so we’ll only discuss CI here. Maybe, I will cover CD in a future post. 😉

Table of Contents:

What is CI?

Continuous Integration, as I understand it, is a pattern of programming combining testing, safety checks, and development practices to confidently push code from a development branch to production ready branch continuously.

Microsoft Word is an example of CI. Words are written into the program and checked against spelling and grammar algorithms to assert a document’s general readability and spelling.

Why CI should be used everywhere

We’ve already touched on this a bit, but the biggest benefit of CI that I see is that it saves a lot of money by making engineers more productive. Specifically, it provides quicker feedback loops, easier integration, and it reduces bottlenecks. Directly correlating CI to company savings is hard because SaaS costs scale as the user base changes. So, if a developer wants to sell CI to the business, the formula below can be utilized. Curious just how much it can save? My friend, David Inoa, created the following demo to help calculate the savings.

See the Pen Continuous Integration (CI) Company Cost Savings Estimator by David (@davidinoa) on CodePen.

What really excites enough to scream to the top of the rooftops is how CI can benefit you and me as developers!

For starters, CI will save you time. How much? We’re talking hours per week. How? Oh, do I want to tell you! CI automatically tests your code and lets you know if it is okay to be merged in a branch that goes to production. The amount of time that you would spend testing your code and working with others to get code ready for production is a lot of time.

Then there’s the way it helps prevent code fatigue. It sports tools like Greenkeeper, which can automatically set up — and even merge — pull requests following a code review. This keeps code up-to-date and allows developers to focus on what we really need to do. You know, like writing code or living life. Code updates within packages usually only need to be reviewed for major version updates, so there’s less need to track every minor release for breaking changes that require action.

CI takes a lot of the guesswork out of updating dependencies that otherwise would take a lot of research and testing.

No excuses, use CI!

When talking to developers, the conversation usually winds up something like:

„I would use CI but…[insert excuse].”

To me, that’s a cop out! CI can be free. It can also be easy. It’s true that the benefits of CI come with some costs, including monthly fees for tools like CircleCI or Greenkeeper. But that’s a drop in the bucket with the long-term savings it provides. It’s also true that it will take time to set things up. But it’s worth calling out that the power of CI can be used for free on open source projects. If you need or want to keep your code private and don’t want pay for CI tools, then you really can build your own CI setup with a few great npm packages.

So, enough with the excuses and behold the power of CI!

What problems does CI solve?

Before digging in much further, we should cover the use cases for CI. It solves a lot of issues and comes in handy in many situations:

  • When more than one developer wants to merge into a production branch at once
  • When mistakes are not caught or cannot be fixed before deployment
  • When dependencies are out of date
  • When developers have to wait extended periods of time to merge code
  • When packages are dependent on other packages
  • When a package is updated and must be changed in multiple place
CI tests updates and prevents bugs from being deployed.

Recommended CI tools

Let’s look at the high level parts used to create a CI feedback loop with some quick code bits to get CI setup for any open source project today. We’ll break this down into digestible chunks.

Documentation

In order to get CI working for me right away, I usually set CI up to test my initial documentation for a project. Specifically, I use MarkdownLint and Write Good because they provide all the features and functionality I need to write tests for this part of the project.

The great news is that GitHub provides standard templates and there is a lot of content that can be copied to get documentation setup quickly. Read more about quickly setting up documentation and creating a documentation feedback loop.

I keep a package.json file at the root of the project and run a script command like this:

"grammar": "write-good *.md --no-passive",
"markdownlint": "markdownlint *.md"

Those two lines allow me to start using CI. That’s it! I can now run CI to test grammar.

At this point, I can move onto setting up CircleCI and Greenkeeper to help me make sure that packages are up to date. We’ll get to that in just a bit.

Unit testing

Unit tests are a method for testing small blocks (units) of code to ensure that the expected behavior of that block works as intended.

Unit tests provide a lot of help with CI. They define code quality and provide developers with feedback without having to push/merge/host code. Read more about unit tests and quickly setting a unit test feedback loop.

Here is an example of a very basic unit test without using a library:

const addsOne = (num) => num + 1 // We start with 1 as an initial value
  const numPlus1 = addsOne(3) // Function to add 3
  const stringNumPlus1 = addsOne('3') // Add the two functions, expect 4 as the value
    
  /**
    * console.assert
    * https://developer.mozilla.org/en-US/docs/Web/API/console/assert
    * @param test?
    * @param string
    * @returns string if the test fails
    **/
    
  console.assert(numPlus1 === 4, 'The variable `numPlus1` is not 4!')
  console.assert(stringNumPlus1 === 4, 'The variable `stringNumPlus1` is not 4!')

Over time, it is nice to use libraries like Jest to unit test code, but this example gives you an idea of what we’re looking at.

Here’s an example of the same test above using Jest:

const addsOne = (num) => num + 1

describe('addsOne', () => {
  it('adds a number', () => {
    const numPlus1 = addsOne(3)
    expect(numPlus1).toEqual(4)
  })
  it('will not add a string', () => {
    const stringNumPlus1 = addsOne('3')
    expect(stringNumPlus1 === 4).toBeFalsy();
  })
})

Using Jest, tests can be hooked up for CI with a command in a package.json like this:

"test:jest": "jest --coverage",

The flag --coverage configures Jest to report test coverage.

Safety checks

Safety checks help communicate code and code quality. Documentation, document templates, linter, spell checkers, and type checker are all safety checks. These tools can be automated to run during commits, in development, during CI, or even in a code editor.

Safety checks fall into more than one category of CI: feedback loop and testing. I’ve compiled a list of the types of safety checked I typically bake into a project.

All of these checks may seem like another layer of code abstraction or learning, so be gentle on yourself and others if this feels overwhelming. These tools have helped my own team bridge experience gaps, define shareable team patterns, and assist developers when they’re confused about what their code is doing.

  • Committing, merging, communicating: Tools like husky, commitizen, GitHub Templates, and Changelogs help keep CI running clean code and form a nice workflow for a collaborative team environment.
  • Defining code (type checkers): Tools like TypeScript define and communicate code interfaces — not only types!
  • Linting: This is the practice of ensuring that something matches defined standards and patterns. There’s a linter for nearly all programming languages and you’ve probably worked with common ones, like ESlint (JavaScript) and Stylelint (CSS) in other projects.
  • Writing and commenting: Write Good helps catch grammar errors in documentation. Tools like JSDoc, Doctrine, and TypeDoc assist in writing documentation and add useful hints in code editors. Both can compile into markdown documentation.

ESlint is a good example for how any of these types of tools are implemented in CI. For example, this is all that’s needed in package.json to lint JavaScript:

"eslint": "eslint ."

Obviously, there are many options that allow you to configure a linter to conform to you and your team’s coding standards, but you can see how practical it can be to set up.

High level CI setup

Getting CI started for a repository often takes very little time, yet there are plenty of advanced configurations we can also put to use, if needed. Let’s look at a quick setup and then move into a more advanced configuration. Even the most basic setup is beneficial for saving time and code quality!

Two features that can save developers hours per week with simple CI are automatic dependency updates and build testing. Dependency updates are written about in more detail here.

Build testing refers to node_modules installation during CI by running an install — for example, (npm install where all node_modules install as expected. This is a simple task and does fail. Ensuring that node_modules installs as expected saves considerable time!

Quick CI Setup

CI can be setup automatically for both CircleCI and Travis! If a valid test command is already defined in the repository’s package.json, then CI can be implemented without any more configuration.

In a CI tool, like CircleCI or Travis, the repository can be searched for after logging in or authentication. From there, follow the CI tool’s UI to start testing.

For JavaScript, CircleCI will look at test within a repository’s package.json to see if a valid test script is added. If it is, then CircleCI will begin running CI automatically! Read more about setting up CircleCI automatically here.

Advanced configurations

If unit tests are unfinished, or if a more configuration is needed, a .yml file can be added for a CI tool (like CircleCI) where the execute runner scripts are made.

Below is how to set up a custom CircleCI configuration with JavaScript linting (again, using ESlint as an example) for a CircleCI.

First off, run this command:

mkdir .circleci && touch .circleci/config.yml

Then add the following to generated file:

defaults: &defaults
  working_directory: ~/code
  docker:
    - image: circleci/node:10
  environment:
  NPM_CONFIG_LOGLEVEL: error # make npm commands less noisy
  JOBS: max <h3>https://gist.github.com/ralphtheninja/f7c45bdee00784b41fed
    version: 2
    jobs:
    build:
      <<: *defaults
      steps:
        - checkout
        - run: npm i
        - run: npm run eslint:ci

After these steps are completed and after CircleCI has been configured in GitHub (more on that here), CircleCI will pick up .circleci/config.yml and lint JavaScript in a CI process when a pull request is submitted.

I created a folder with examples in this demo repository to show ideas for configuring CI with config.yml filesand you can reference it for your own project or use the files as a starting point.

The are more even more CI tools that can be setup to help save developers more time, like auto-merging, auto-updating, monitoring, and much more!

Summary

We covered a lot here! To sum things up, setting up CI is very doable and can even be free of cost. With additional tooling (both paid and open source), we can have more time to code, and more time to write more tests for CI — or enjoy more life away from the screen!

Here are some demo repositories to help developers get setup fast or learn. Please feel free to reach out within the repositories with questions, ideas or improvements.

The post Continuous Integration: The What, Why and How appeared first on CSS-Tricks.

Continuous Integration: The What, Why and How

Post pobrano z: Continuous Integration: The What, Why and How

Not long ago, I had a novice understanding of Continuous Integration (CI) and thought it seemed like an extra process that forces engineers to do extra work on already large projects. My team began to implement CI into projects and, after some hands-on experience, I realized its great benefits, not only to the company, but to me, an engineer! In this post, I will describe CI, the benefits I’ve discovered, and how to implement it for free, and fast.

CI and Continuous Delivery (CD) are usually discussed together. Writing about both CI and CD within a post is a lot to write and read about all at once, so we’ll only discuss CI here. Maybe, I will cover CD in a future post. 😉

Table of Contents:

What is CI?

Continuous Integration, as I understand it, is a pattern of programming combining testing, safety checks, and development practices to confidently push code from a development branch to production ready branch continuously.

Microsoft Word is an example of CI. Words are written into the program and checked against spelling and grammar algorithms to assert a document’s general readability and spelling.

Why CI should be used everywhere

We’ve already touched on this a bit, but the biggest benefit of CI that I see is that it saves a lot of money by making engineers more productive. Specifically, it provides quicker feedback loops, easier integration, and it reduces bottlenecks. Directly correlating CI to company savings is hard because SaaS costs scale as the user base changes. So, if a developer wants to sell CI to the business, the formula below can be utilized. Curious just how much it can save? My friend, David Inoa, created the following demo to help calculate the savings.

See the Pen Continuous Integration (CI) Company Cost Savings Estimator by David (@davidinoa) on CodePen.

What really excites enough to scream to the top of the rooftops is how CI can benefit you and me as developers!

For starters, CI will save you time. How much? We’re talking hours per week. How? Oh, do I want to tell you! CI automatically tests your code and lets you know if it is okay to be merged in a branch that goes to production. The amount of time that you would spend testing your code and working with others to get code ready for production is a lot of time.

Then there’s the way it helps prevent code fatigue. It sports tools like Greenkeeper, which can automatically set up — and even merge — pull requests following a code review. This keeps code up-to-date and allows developers to focus on what we really need to do. You know, like writing code or living life. Code updates within packages usually only need to be reviewed for major version updates, so there’s less need to track every minor release for breaking changes that require action.

CI takes a lot of the guesswork out of updating dependencies that otherwise would take a lot of research and testing.

No excuses, use CI!

When talking to developers, the conversation usually winds up something like:

„I would use CI but…[insert excuse].”

To me, that’s a cop out! CI can be free. It can also be easy. It’s true that the benefits of CI come with some costs, including monthly fees for tools like CircleCI or Greenkeeper. But that’s a drop in the bucket with the long-term savings it provides. It’s also true that it will take time to set things up. But it’s worth calling out that the power of CI can be used for free on open source projects. If you need or want to keep your code private and don’t want pay for CI tools, then you really can build your own CI setup with a few great npm packages.

So, enough with the excuses and behold the power of CI!

What problems does CI solve?

Before digging in much further, we should cover the use cases for CI. It solves a lot of issues and comes in handy in many situations:

  • When more than one developer wants to merge into a production branch at once
  • When mistakes are not caught or cannot be fixed before deployment
  • When dependencies are out of date
  • When developers have to wait extended periods of time to merge code
  • When packages are dependent on other packages
  • When a package is updated and must be changed in multiple place
CI tests updates and prevents bugs from being deployed.

Recommended CI tools

Let’s look at the high level parts used to create a CI feedback loop with some quick code bits to get CI setup for any open source project today. We’ll break this down into digestible chunks.

Documentation

In order to get CI working for me right away, I usually set CI up to test my initial documentation for a project. Specifically, I use MarkdownLint and Write Good because they provide all the features and functionality I need to write tests for this part of the project.

The great news is that GitHub provides standard templates and there is a lot of content that can be copied to get documentation setup quickly. Read more about quickly setting up documentation and creating a documentation feedback loop.

I keep a package.json file at the root of the project and run a script command like this:

"grammar": "write-good *.md --no-passive",
"markdownlint": "markdownlint *.md"

Those two lines allow me to start using CI. That’s it! I can now run CI to test grammar.

At this point, I can move onto setting up CircleCI and Greenkeeper to help me make sure that packages are up to date. We’ll get to that in just a bit.

Unit testing

Unit tests are a method for testing small blocks (units) of code to ensure that the expected behavior of that block works as intended.

Unit tests provide a lot of help with CI. They define code quality and provide developers with feedback without having to push/merge/host code. Read more about unit tests and quickly setting a unit test feedback loop.

Here is an example of a very basic unit test without using a library:

const addsOne = (num) => num + 1 // We start with 1 as an initial value
  const numPlus1 = addsOne(3) // Function to add 3
  const stringNumPlus1 = addsOne('3') // Add the two functions, expect 4 as the value
    
  /**
    * console.assert
    * https://developer.mozilla.org/en-US/docs/Web/API/console/assert
    * @param test?
    * @param string
    * @returns string if the test fails
    **/
    
  console.assert(numPlus1 === 4, 'The variable `numPlus1` is not 4!')
  console.assert(stringNumPlus1 === 4, 'The variable `stringNumPlus1` is not 4!')

Over time, it is nice to use libraries like Jest to unit test code, but this example gives you an idea of what we’re looking at.

Here’s an example of the same test above using Jest:

const addsOne = (num) => num + 1

describe('addsOne', () => {
  it('adds a number', () => {
    const numPlus1 = addsOne(3)
    expect(numPlus1).toEqual(4)
  })
  it('will not add a string', () => {
    const stringNumPlus1 = addsOne('3')
    expect(stringNumPlus1 === 4).toBeFalsy();
  })
})

Using Jest, tests can be hooked up for CI with a command in a package.json like this:

"test:jest": "jest --coverage",

The flag --coverage configures Jest to report test coverage.

Safety checks

Safety checks help communicate code and code quality. Documentation, document templates, linter, spell checkers, and type checker are all safety checks. These tools can be automated to run during commits, in development, during CI, or even in a code editor.

Safety checks fall into more than one category of CI: feedback loop and testing. I’ve compiled a list of the types of safety checked I typically bake into a project.

All of these checks may seem like another layer of code abstraction or learning, so be gentle on yourself and others if this feels overwhelming. These tools have helped my own team bridge experience gaps, define shareable team patterns, and assist developers when they’re confused about what their code is doing.

  • Committing, merging, communicating: Tools like husky, commitizen, GitHub Templates, and Changelogs help keep CI running clean code and form a nice workflow for a collaborative team environment.
  • Defining code (type checkers): Tools like TypeScript define and communicate code interfaces — not only types!
  • Linting: This is the practice of ensuring that something matches defined standards and patterns. There’s a linter for nearly all programming languages and you’ve probably worked with common ones, like ESlint (JavaScript) and Stylelint (CSS) in other projects.
  • Writing and commenting: Write Good helps catch grammar errors in documentation. Tools like JSDoc, Doctrine, and TypeDoc assist in writing documentation and add useful hints in code editors. Both can compile into markdown documentation.

ESlint is a good example for how any of these types of tools are implemented in CI. For example, this is all that’s needed in package.json to lint JavaScript:

"eslint": "eslint ."

Obviously, there are many options that allow you to configure a linter to conform to you and your team’s coding standards, but you can see how practical it can be to set up.

High level CI setup

Getting CI started for a repository often takes very little time, yet there are plenty of advanced configurations we can also put to use, if needed. Let’s look at a quick setup and then move into a more advanced configuration. Even the most basic setup is beneficial for saving time and code quality!

Two features that can save developers hours per week with simple CI are automatic dependency updates and build testing. Dependency updates are written about in more detail here.

Build testing refers to node_modules installation during CI by running an install — for example, (npm install where all node_modules install as expected. This is a simple task and does fail. Ensuring that node_modules installs as expected saves considerable time!

Quick CI Setup

CI can be setup automatically for both CircleCI and Travis! If a valid test command is already defined in the repository’s package.json, then CI can be implemented without any more configuration.

In a CI tool, like CircleCI or Travis, the repository can be searched for after logging in or authentication. From there, follow the CI tool’s UI to start testing.

For JavaScript, CircleCI will look at test within a repository’s package.json to see if a valid test script is added. If it is, then CircleCI will begin running CI automatically! Read more about setting up CircleCI automatically here.

Advanced configurations

If unit tests are unfinished, or if a more configuration is needed, a .yml file can be added for a CI tool (like CircleCI) where the execute runner scripts are made.

Below is how to set up a custom CircleCI configuration with JavaScript linting (again, using ESlint as an example) for a CircleCI.

First off, run this command:

mkdir .circleci && touch .circleci/config.yml

Then add the following to generated file:

defaults: &defaults
  working_directory: ~/code
  docker:
    - image: circleci/node:10
  environment:
  NPM_CONFIG_LOGLEVEL: error # make npm commands less noisy
  JOBS: max <h3>https://gist.github.com/ralphtheninja/f7c45bdee00784b41fed
    version: 2
    jobs:
    build:
      <<: *defaults
      steps:
        - checkout
        - run: npm i
        - run: npm run eslint:ci

After these steps are completed and after CircleCI has been configured in GitHub (more on that here), CircleCI will pick up .circleci/config.yml and lint JavaScript in a CI process when a pull request is submitted.

I created a folder with examples in this demo repository to show ideas for configuring CI with config.yml filesand you can reference it for your own project or use the files as a starting point.

The are more even more CI tools that can be setup to help save developers more time, like auto-merging, auto-updating, monitoring, and much more!

Summary

We covered a lot here! To sum things up, setting up CI is very doable and can even be free of cost. With additional tooling (both paid and open source), we can have more time to code, and more time to write more tests for CI — or enjoy more life away from the screen!

Here are some demo repositories to help developers get setup fast or learn. Please feel free to reach out within the repositories with questions, ideas or improvements.

The post Continuous Integration: The What, Why and How appeared first on CSS-Tricks.