This guide provides a walkthrough of .razorops.yaml for a typical Node.js based application. Our CI process is going to consist of following steps -

  • Install dependencies (npm install or npm ci)
  • Execute test suite (npm test)

We recommend you use docker based workflow for easier operations and immutable deployment. If not, you can directly jump below to use non-docker based tasks.

Docker based

I assume you are familiar with Docker concepts, if not please refer here to know more about the advantages of Docker.

Build/Test steps

If you have Dockerfile in the root of your source repository, you can build a container image and use that container image to run your test suit. For example -

tasks:
    build-image:
        type: build
        name: registry.example.com/web
        tags: ["${CI_COMMIT_SHA}", "latest"]

    rspec:
        image: registry.example.com/web:latest
        commands:
            - yarn test

Non-Docker based

Installing dependencies

Using official node docker image:



 



tasks:
    build-deps:
        image: node:10
        commands:
            - npm install --package-lock-only

Read more how to use this image on dockerhub docs.

TIP

You can further speedup the workflow by caching npm dependencies so that every subsequent build then performs just incremental changes on top of that during npm install which may lead to even faster builds.

Execute test suite

Using official node docker image:



 



tasks:
    build-deps:
        image: node:10
        commands:
            - npm test

You can additionally provide environment variables and provide service dependencies to run your test suite.