Skip to content

Dev Ops

Kunal Nagpal edited this page Apr 24, 2016 · 8 revisions

Automation:

  • During the course of regular workflow, you may encounter tasks that need to be performed on a periodic basis, such as testing, database cleanup, code refactoring, static asset compression, and many more.

  • Identify automated alternatives to all such tasks, keeping all your focus directed toward the core segment of project work itself. For instance, database cleanup scenarios can be identified and automated with JS scripts. Add all such scripts to the folder utils, and add the run time command for these tasks to the scripts key in package.json.

  • In extension to the point above, run the above scripts with npm run scriptName. The table below elucidates various scripts present:

SNo Script Description
1 sim Runs all the scheduled match simulations for the given matchday and round combination
2 seed Instantiates a dummy database with fake teams, players and an admin.
3 purge Destroys the dummy database (disbarred on production environments)
4 schedule Creates a match schedule for the current round (adds padding teams to bring the overall count to a multiple of 8). Will fail if a schedule already exists.
5 scrape Scrapes commentary from a standard source and appends it to the commentary archive.
6 deploy Promotes the code slug from staging to production
7 start Starts a new host instance, fails if the port is occupied or a database connection cannot be established within the timeout period.
8 stop Kills the running hosting process.
9 test Executes the test suite for the given test directory, is also run automatically before every commit.
10 restart stop+start
  • The same applies to testing, so do have a look at Mocha.js for more details. Only bypass test failures if you know precisely what you are doing, consult with your project lead regarding the same.

Code health:

  • Currently, Code climate is used as the code health monitoring tool. It provides a 4.0 scaled score based on a variety of factors, such as code repetition, bad styling (not necessarily that of CSS), inconsistent naming, and so on. Keep in mind that receiving a perfect score of 4.0 can prove to be irritatingly difficult.

  • Given that the application depends on several other packages, keeping regular checks on the dependency status is an important part of code health. There are two halves to this task:

  1. npm-check: Install this module globally with the command npm i npm-check -g to enable the CLI to check for outdated dependencies: npm-check -u

  2. Check for the dependency status badge on the repository's README

Tests:

The following realms need attention within the scope of tests:

  • Route request handlers.

  • Database calls.

  • Front end render operations.

  • Simulation

Contributions:

To add a contributor to the developers page, all you have to do is append a record to the contributors key in package.json, and ensure that the corresponding image is present in the developers folder on Cloudinary. For instance, if the contributor's name is Foo Bar, the the image should be named foo.jpg.

Usually, the contributors key in package.json is an array of objects, like so:

contributors: [
    {
      "name": "Foo Bar",
      "email": "[email protected]"
    }, 
    ...
]

However, to accommodate year wise contributions, the above array of objects has been adjusted to an array of arrays. The index of each sub-array represents the year of contribution, and the elements within the sub array represent the contributors themselves, as usual.

contributors: [
    [ // <= Year one, v1.0
      {
        "name": "Foo Bar",
        "email": "[email protected]"
      }...
    ], 
    [ // <= Year two, v2.0
      {
        "name": "Bar Foo",
        "email": "[email protected]"
      }...
    ],
    ...
]

In short, a new sub-array within contributors has to be created every year.

Optimization:

Remember, there is nothing better than optimized code that gets the job done (Writing code in fewer lines is not necessarily an act of optimization). You will not only reduce the load on your servers, alleviating the need for additional machines, but keep your users happy as well.

More to follow in this space.

GPL

General

First steps

Setup instructions

Technical information

Developer guidelines

Simulation

Clone this wiki locally