We provide the @qawolf/ci-sdk NPM package to handle most of the integration work for you. This script integrates with the two endpoints currently available, and provides one async function for each:
The package features TypeScript definitions, ESM and CJS module interoperability. See the NPM package page for more information.
We recommend using the ^ npm range operator to get on-the-fly fixes. The SDK package follows SemVer. Learn more about stability guarantees in the official NPM package page.
API key
Go to https://app.qawolf.com/<team slug>/settings/integrationsOr, navigate via the UI:
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 ephemeralEnvironment: 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.
import { makeQaWolfSdk } from "@qawolf/ci-sdk";const { pollCiGreenlightStatus } = makeQaWolfSdk({ apiKey: "qawolf_xxxxx",});(async () => { // Retrieve runId from the previous job. const { outcome } = await pollCiGreenlightStatus({ runId, // Optional: Callback to be called when the run stage changes. onRunStageChanged: (current, previous) => { console.log(current, previous); }, // Optional: abort the job when a superseding run is encountered. // Default "false" abortOnSuperseded: false, // EXPERIMENTAL! // Optional: Defaults to "green". // When set to `"red"`, the job will fail when blocking bugs were // found in the environment that were affecting workflows not executed // in the run. outcomeWhenBlockingBugsInOtherWorkflows: "green", }); if (outcome !== "success") { // Fail the job. // This will depend on the CI platform you are using. // You can also distinguish between "failed" and "aborted" outcomes. // Only "failed" outcome indicates bugs were found. process.exit(1); } // Continue CI.})();
import { type NotifyTerminatedEphemeralEnvironmentInput, makeQaWolfSdk,} from "@qawolf/ci-sdk";// Edit this to your needsconst terminateConfig: NotifyTerminatedEphemeralEnvironmentInput = { environmentId: "test-environment-id",};const { notifyTerminatedEphemeralEnvironment } = makeQaWolfSdk({ apiKey: "qawolf_xxxxx",});const result = await notifyTerminatedEphemeralEnvironment(terminateConfig);if (result.outcome !== "success") { // Fail the job. process.exit(1);}// result.environmentId can be output from the job.