Socket
Book a DemoInstallSign in
Socket

@trussle/ci

Package Overview
Dependencies
Maintainers
14
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trussle/ci

Continuous Integration scripts

1.0.3
latest
npmnpm
Version published
Maintainers
14
Created
Source

Trussle CI

This package provides a suite of scripts used by Trussle's Continuous Integration system to build Docker images for testing and deployment.

Usage

Installation

Install this package as a devDependency:

npm install --save-dev @trussle/ci

Dockerfile

Next, set up your Dockerfile with the following constraints:

  • There should be a builder stage, which creates an image ready to build and test in the /builder directory. The ENTRYPOINT should run all unit tests (with coverage) and provide results in JUnit format to the directory /builder/test-results.
  • The final stage of the Dockerfile should create a runner image continaing only the files required to run the application. The ENTRYPOINT should run the application.
  • The host machine's NPM token will be injected into the image as the argument NPM_TOKEN, so you'll likely need the following lines at the top of your Dockerfile:
# Embed the NPM_TOKEN (passed in from the host machine) into the image.
ARG NPM_TOKEN
RUN echo -n ${NPM_TOKEN} > /root/.npmrc

Samples of Dockerfiles can be found in the templates.

Docker Compose

If you have integration tests (tests that require an external dependency to be running), you should include a Docker Compose file that looks like this:

version: "2.1"

services:
  integration:
    image: "878732450721.dkr.ecr.eu-west-1.amazonaws.com/[package-name]-builder:latest"
    # depends_on:
    #   - service1
    #   - service2
    entrypoint: npm run test:integration
    environment:
      - NODE_ENV=CI
  # Your other services go here!

Running

You can now run:

  • npx t-ci builder to make the build/test image.
  • npx t-ci test-unit runs unit tests in the builder.
  • npx t-ci test-integration sets up the Docker Compose environment and runs the integration tests.
  • npx t-ci runner to make the runner image.

These commands can be used to make your Jenkinsfile super short:

pipeline {
  agent any
  stages {
    stage("Setup") { steps { sh "npx t-ci builder" } }
    stage("Tests") {
      parallel {
        stage("Unit Tests") { steps { sh "npx t-ci test-unit" } }
        stage("Integration Tests") { steps { sh "npx t-ci test-integration" } }
      }
    }
    stage("Build") { steps { sh "npx t-ci runner" } }
  }
  post {
    always {
      junit "test-results/**/*.xml"
      sh "aws s3 sync test-results/ s3://qa-junit-test-reports/${env.JOB_NAME}/${env.BUILD_NUMBER}/test-results"
      cleanWs(
        cleanWhenAborted: true,
        cleanWhenFailure: true,
        cleanWhenNotBuilt: true,
        cleanWhenSuccess: true,
        cleanWhenUnstable: true,
        cleanupMatrixParent: true,
        deleteDirs: true
      )
    }
  }
}

FAQs

Package last updated on 06 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.