When you deploy a new version of your application, you can notify us and we will initiate a test run for this deployment.

<aside> ⚠️ Please note that these are meant to be triggered by your main environment, per the contract with QA Wolf. If you need additional environment support, please reach out to our team. There are both technical and account implications for secondary environments that are not fully covered in this document.

</aside>

Notify QA Wolf after Deployment

Prerequisites

A QAE representative must configure a trigger associated with an environment for deploy success requests to initiate test runs. The DeployConfig object below will require some parameters that match this Trigger configuration.

Contact your QA Wolf representative, and we’ll set it up with you.

Option 1: With our SDK

Below is a sample script written in TypeScript:

<aside> ⚠️ Please refer to Choosing Fields Based on Your Setup to properly set up the DeployConfig object.

</aside>

import { type DeployConfig, makeQaWolfSdk } from "@qawolf/ci-sdk";

// Edit this to your needs.
const deployConfig: DeployConfig = {
  sha: undefined, // Recomended
  branch: undefined, // Recommended
  commitUrl: undefined, // Recommended
  deploymentType: undefined, // "accounting"
  deduplicationKey: undefined, // Not needed
  deploymentUrl: undefined, // Not needed
  hostingService: undefined, // Not needed
  variables: undefined, // Not needed
};

const { attemptNotifyDeploy } = makeQaWolfSdk({ apiKey });

const result = await attemptNotifyDeploy(deployConfig);
if (result.outcome !== "success") {
  // Fail the job.
  throw Error(`Failed to notify QAWolf: ${JSON.stringify(result)}`);
}

// result.runId can be output from the job to be used in a CI-greenlight job.

CircleCI Example

Save this script in a file named .circleci/notifyQaWolf.mjs in the repo the corresponds to the deployments QA Wolf will be testing. This example assumes GitHub, but just change the hostingService value if you use another supported code hosting service.

import assert from "assert";
import { makeQaWolfSdk } from "<https://esm.sh/@qawolf/[email protected]>";

const apiKey = process.env.QA_WOLF_TEAM_API_KEY;
assert(apiKey, "QA_WOLF_TEAM_API_KEY is required");

const sha = process.env.CIRCLE_SHA1;
assert(sha, "CIRCLE_SHA1 is required");

const branch = process.env.CIRCLE_BRANCH;
assert(branch, "CIRCLE_BRANCH is required");

const deployConfig = {
  branch,
  // Required only if the target trigger requires matching a deployment type
  deploymentType: "staging", // e.g., "production", "staging", "qa"
  // Optional: Include deployment URL to override URL environment variable for the run
  deploymentUrl: undefined,
  hostingService: "GitHub",
  // Optional: Include pull request number for PR testing
  // pullRequestNumber: 123,
  // Recommended: Include repository information
  repository: {
    name: "circleci-example",
    owner: "qawolf",
  },
  sha,
};

const { attemptNotifyDeploy } = makeQaWolfSdk({ apiKey });

const result = await attemptNotifyDeploy(deployConfig);
if (result.outcome !== "success") {
  // Fail the job.
  throw Error(`Failed to notify QAWolf: ${JSON.stringify(result)}`);
}

// result.runId can be output from the job to be used in a CI-greenlight job.

Then run it from a CircleCI job in your workflow. Simple example:

# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: <https://circleci.com/docs/configuration-reference>
version: 2.1

# Use the latest Node.js orb
orbs:
  node: circleci/[email protected]

# Define a job to be invoked later in a workflow.
# See: <https://circleci.com/docs/jobs-steps/#jobs-overview> & <https://circleci.com/docs/configuration-reference/#jobs>
jobs:
  # build: TODO
  # deploy: TODO
  notify-qa-wolf:
    executor: node/default
    steps:
      - checkout
      - run: node --version
      - run: node --experimental-network-imports .circleci/notifyQaWolf.mjs

# Orchestrate jobs using workflows
# See: <https://circleci.com/docs/workflows/> & <https://circleci.com/docs/configuration-reference/#workflows>
workflows:
  build-deploy-test-workflow:
    jobs:
      # - build
      # - deploy
      - notify-qa-wolf

The important parts are:

  1. Add the circleci/node orb.
  2. Create the notify-qa-wolf job to run after your deployment is healthy. It must use the node/default executor, check out your code, and run node --experimental-network-imports .circleci/notifyQaWolf.mjs.