guardian / tip

Scala library for testing in production

GitHub

Testing in Production (TiP) Maven Central Build Status Coverage Status

How to verify user journeys are not broken without writing a single test?

  • First time a production user completes a path the corresponding square on the board lights up green: board_example

  • Once all paths have been completed, label is set on the corresponding pull request: pr_label_example and a message is written to logs All tests in production passed.

User Guide

Minimal configuration - single board

  1. Add library to your application's dependencies:
    libraryDependencies += "com.gu" %% "tip" % "0.5.0"
    
  2. List paths to be covered in tip.yaml file and make sure it is on the classpath:
    - name: Register
      description: User creates an account
    
    - name: Update User
      description: User changes account details
    
  3. Instantiate Tip with TipConfig:
    val tipConfig = TipConfig("guardian/identity")
    TipFactory.create(tipConfig)
  4. Call tip.verify("My Path Name"") at the point where you consider path has been successfully completed.
  5. Access board at <tip cloud domain>/{owner}/{repo}/boards/head to monitor verification in real-time.

Setting a label on PR

Optionally, if you want Tip to notify when all paths have been hit by setting a label on the corresponding merged PR, then

  1. Create a GitHub label, for instance, a green label with name Verified in PROD: label_example
  2. Create a GitHub personal access token with at least public_repo scope. Keep this secret!
  3. Set personalAccessToken in TipConfig:
    TipConfig(
      repo = "guardian/identity",
      personalAccessToken = some-secret-token
    )

Board by merge commit SHA

Optionally, if you want to have a separate board for each merged PR, then

  1. Set boardSha in TipConfig:
    TipConfig(
      repo = "guardian/identity",
      boardSha = some-sha-value
    )
    
  2. Example Tip configuration which uses sbt-buildinfo to set boardSha:
    TipConfig(
      repo = "guardian/identity",
      personalAccessToken = config.Tip.personalAccessToken, // remove if you do not need GitHub label functionality
      label = "Verified in PROD", // remove if you do not need GitHub label functionality
      boardSha = BuildInfo.GitHeadSha // remove if you need only one board instead of board per sha
    )
    build.sbt:
      buildInfoKeys := Seq[BuildInfoKey](
        BuildInfoKey.constant("GitHeadSha", "git rev-parse HEAD".!!.trim)
      )
      buildInfoPackage := "com.gu.identity.api"
      buildInfoOptions += BuildInfoOption.ToMap
    )
  3. Access board at <tip cloud domain>/board/{sha}