How to use updateCommitStatus method in qawolf

Best JavaScript code snippet using qawolf

Ghe.js

Source:Ghe.js Github

copy

Full Screen

...66 });67}68exports.createPullRequest = createPullRequest;69function updateCommitStatusError(ghToken, commitSha, description) {70 updateCommitStatus(ghToken, commitSha, description, 'error');71}72exports.updateCommitStatusError = updateCommitStatusError;73function updateCommitStatusPending(ghToken, commitSha, description) {74 updateCommitStatus(ghToken, commitSha, description, 'pending');75}76exports.updateCommitStatusPending = updateCommitStatusPending;77function updateCommitStatusFailure(ghToken, commitSha, description) {78 updateCommitStatus(ghToken, commitSha, description, 'failure');79}80exports.updateCommitStatusFailure = updateCommitStatusFailure;81function updateCommitStatusSuccess(ghToken, commitSha, description) {82 updateCommitStatus(ghToken, commitSha, description, 'success');83}84exports.updateCommitStatusSuccess = updateCommitStatusSuccess;85function updateCommitStatus(ghToken, commitSha, description, state) {86 console.log(`update status to: ${state} for commit with sha: ${commitSha}`);87 (0, github_1.getOctokit)(ghToken).rest.repos.createCommitStatus({88 owner: github_1.context.repo.owner,89 repo: github_1.context.repo.repo,90 sha: commitSha,91 state: state,92 description: description93 });94}95function cleanUpSynchPullRequests(ghToken) {96 (0, github_1.getOctokit)(ghToken).rest.pulls.list({97 owner: github_1.context.repo.owner,98 repo: github_1.context.repo.repo,99 state: 'open'...

Full Screen

Full Screen

handler.ts

Source:handler.ts Github

copy

Full Screen

...18 Pending = 'pending',19 Success = 'success',20 Failure = 'failure',21}22async function updateCommitStatus(ctx: Ctx, status: githubState, url?: string): Promise<void> {23 let description = '';24 let state = githubState.Pending;25 const context = `waypoint/${ctx.operation}`;26 core.info(`updating commit status to: ${status}`);27 switch (status) {28 case githubState.Error: {29 state = githubState.Error;30 description = `The ${ctx.operation} encountered an error`;31 break;32 }33 case githubState.Pending: {34 state = githubState.Pending;35 description = `The ${ctx.operation} has started running`;36 break;37 }38 case githubState.Success: {39 state = githubState.Success;40 description = `The ${ctx.operation} has completed successfully`;41 break;42 }43 }44 try {45 await ctx.octokit.request('POST /repos/:owner/:repo/statuses/:sha', {46 owner: ctx.context.repo.owner,47 repo: ctx.context.repo.repo,48 sha: ctx.context.sha,49 state,50 description,51 context,52 target_url: ctx.uiAppUrl || undefined,53 });54 } catch (e) {55 throw new Error(`failed to create commit status ${e}`);56 }57}58/* eslint-expect-error-next-line @typescript-eslint/no-explicit-any */59async function createDeployment(ctx: Ctx): Promise<any> {60 core.info(`creating github deployment`);61 try {62 const deployment = await ctx.octokit.request('POST /repos/:owner/:repo/deployments', {63 owner: ctx.context.repo.owner,64 repo: ctx.context.repo.repo,65 ref: ctx.context.sha,66 environment: ctx.workspace,67 auto_merge: false,68 required_contexts: [],69 });70 /* eslint-expect-error-next-line @typescript-eslint/no-explicit-any */71 const responseData: any = deployment.data;72 return responseData;73 } catch (e) {74 throw new Error(`failed to create deployment ${e}`);75 }76}77async function createDeploymentStatus(78 ctx: Ctx,79 deploymentId: number,80 status: githubDeploymentState,81 url?: string82): Promise<void> {83 let state = githubDeploymentState.Pending;84 switch (status) {85 case githubDeploymentState.Pending: {86 state = githubDeploymentState.Pending;87 break;88 }89 case githubDeploymentState.Failure: {90 state = githubDeploymentState.Failure;91 break;92 }93 case githubDeploymentState.Success: {94 state = githubDeploymentState.Success;95 break;96 }97 }98 core.info(`update github deployment status to ${status}`);99 try {100 await ctx.octokit.request('POST /repos/:owner/:repo/deployments/:deployment_id/statuses', {101 owner: ctx.context.repo.owner,102 repo: ctx.context.repo.repo,103 ref: ctx.context.sha,104 deployment_id: deploymentId,105 state,106 target_url: ctx.uiAppUrl || undefined,107 });108 } catch (e) {109 throw new Error(`failed to create deployment status ${e}`);110 }111}112// CLI options for all commands, for labeling and determing the workspace113export async function getCliOptions(ctx: Ctx, payload: EventPayloads.WebhookPayloadPush): Promise<string[]> {114 const commit = await ctx.octokit.request('GET /repos/:owner/:repo/commits/:ref', {115 owner: ctx.context.repo.owner,116 repo: ctx.context.repo.repo,117 ref: payload.after,118 });119 return [120 '-workspace',121 ctx.workspace,122 '-label',123 `${LABEL_PREFIX}/vcs-ref=${ctx.context.ref}`,124 '-label',125 `${LABEL_PREFIX}/vcs-sha=${payload.after}`,126 '-label',127 `${LABEL_PREFIX}/vcs-url=${commit.data.html_url}`,128 '-label',129 `${LABEL_PREFIX}/vcs-run-id=${ctx.context.runId}`,130 ];131}132export async function initWaypoint(ctx: Ctx): Promise<void> {133 // Run init quietly134 const options: ExecOptions = {};135 core.info(`running Waypoint init`);136 try {137 const buildCode = await exec('waypoint', ['init', '-workspace', ctx.workspace], options);138 if (buildCode !== 0) {139 throw new Error(`init failed with exit code ${buildCode}`);140 }141 } catch (e) {142 throw new Error(`init failed: ${e}`);143 }144}145export async function handleBuild(ctx: Ctx, payload: EventPayloads.WebhookPayloadPush): Promise<void> {146 const waypointOptions = await getCliOptions(ctx, payload);147 // Set status to pending148 await updateCommitStatus(ctx, githubState.Pending);149 // Run init150 await initWaypoint(ctx);151 // Run the build152 try {153 const buildCode = await exec('waypoint', ['build', ...waypointOptions]);154 if (buildCode !== 0) {155 throw new Error(`build failed with exit code ${buildCode}`);156 }157 } catch (e) {158 // Set status to error159 await updateCommitStatus(ctx, githubState.Error);160 throw new Error(`build failed: ${e}`);161 }162 // Set status to success163 await updateCommitStatus(ctx, githubState.Success);164}165export async function handleDeploy(ctx: Ctx, payload: EventPayloads.WebhookPayloadPush): Promise<void> {166 const waypointOptions = await getCliOptions(ctx, payload);167 // Set status to pending168 await updateCommitStatus(ctx, githubState.Pending);169 // Create a github deployment, which also updates the status170 const deploy = await createDeployment(ctx);171 // Update the status of the deployment172 await createDeploymentStatus(ctx, deploy.id, githubDeploymentState.Pending);173 // This is pretty unfortunate, but if you run `waypoint deploy` too soon174 // after `waypoint build` you might not get the recently built artifact. So175 // we just naively wait.176 await new Promise((resolve) => {177 setTimeout(resolve, WAIT_FOR_BUILD);178 });179 // Run init180 await initWaypoint(ctx);181 let output = '';182 const options: ExecOptions = {};183 options.listeners = {184 stdout: (data: Buffer) => {185 // Store a copy out of the output so we can186 // search for a deployment URL after187 output += data.toString();188 core.info(output);189 },190 };191 await createDeploymentStatus(ctx, deploy.id, githubDeploymentState.Pending);192 // Run the deploy193 try {194 const buildCode = await exec('waypoint', ['deploy', ...waypointOptions], options);195 if (buildCode !== 0) {196 throw new Error(`deploy failed with exit code ${buildCode}`);197 }198 } catch (e) {199 await updateCommitStatus(ctx, githubState.Error);200 await createDeploymentStatus(ctx, deploy.id, githubDeploymentState.Failure);201 throw new Error(`deploy failed: ${e}`);202 }203 let deployUrl = undefined;204 const matches = URL_REGEX.exec(output);205 if (matches?.length === 1) {206 deployUrl = matches[0];207 core.info(`got deployment url from output: ${deployUrl}`);208 }209 // Update the commit status210 await updateCommitStatus(ctx, githubState.Success, deployUrl);211 await createDeploymentStatus(ctx, deploy.id, githubDeploymentState.Success);212}213export async function handleRelease(ctx: Ctx, payload: EventPayloads.WebhookPayloadPush): Promise<void> {214 const waypointOptions = await getCliOptions(ctx, payload);215 // Set status to pending216 await updateCommitStatus(ctx, githubState.Pending);217 // Run init218 await initWaypoint(ctx);219 try {220 const releaseCode = await exec('waypoint', ['release', ...waypointOptions]);221 if (releaseCode !== 0) {222 await updateCommitStatus(ctx, githubState.Error);223 throw new Error(`release failed with exit code ${releaseCode}`);224 }225 } catch (e) {226 throw new Error(`release failed: ${e}`);227 }228 // Update the commit status to success229 await updateCommitStatus(ctx, githubState.Success);...

Full Screen

Full Screen

scm.test.js

Source:scm.test.js Github

copy

Full Screen

1'use strict';2const { assert } = require('chai');3const scm = require('../../plugins/scm');4const { validate } = require('../helper');5describe('scm test', () => {6 describe('getPermissions', () => {7 it('validates', () => {8 assert.isNull(validate('scm.getPermissions.yaml', scm.getPermissions).error);9 });10 it('validates with scmRepo', () => {11 assert.isNull(validate('scm.getPermissionsWithScmRepo.yaml', scm.getPermissions).error);12 });13 it('fails', () => {14 assert.isNotNull(validate('empty.yaml', scm.getPermissions).error);15 });16 });17 describe('getOrgPermissions', () => {18 it('validates', () => {19 assert.isNull(validate('scm.getOrgPermissions.yaml', scm.getOrgPermissions).error);20 });21 it('fails', () => {22 assert.isNotNull(validate('empty.yaml', scm.getOrgPermissions).error);23 });24 });25 describe('getCommitSha', () => {26 it('validates', () => {27 assert.isNull(validate('scm.getCommitSha.yaml', scm.getCommitSha).error);28 });29 it('validates with scmRepo', () => {30 assert.isNull(validate('scm.getCommitShaWithScmRepo.yaml', scm.getCommitSha).error);31 });32 it('fails', () => {33 assert.isNotNull(validate('empty.yaml', scm.getCommitSha).error);34 });35 });36 describe('getCommitRefSha', () => {37 it('validates', () => {38 assert.isNull(validate('scm.getCommitRefSha.yaml', scm.getCommitRefSha).error);39 });40 it('fails', () => {41 assert.isNotNull(validate('empty.yaml', scm.getCommitRefSha).error);42 });43 });44 describe('addPrComment', () => {45 it('validates', () => {46 assert.isNull(validate('scm.addPrComment.yaml', scm.addPrComment).error);47 });48 it('fails', () => {49 assert.isNotNull(validate('empty.yaml', scm.addPrComment).error);50 });51 });52 describe('updateCommitStatus', () => {53 it('validates', () => {54 assert.isNull(validate('scm.updateCommitStatus.yaml', scm.updateCommitStatus).error);55 });56 it('validates with extra optional params (context and description)', () => {57 assert.isNull(validate('scm.updateCommitStatusFull.yaml', scm.updateCommitStatus).error);58 });59 it('fails', () => {60 assert.isNotNull(validate('empty.yaml', scm.updateCommitStatus).error);61 });62 });63 describe('getFile', () => {64 it('validates', () => {65 assert.isNull(validate('scm.getFile.yaml', scm.getFile).error);66 });67 it('validates with optional scmRepo', () => {68 assert.isNull(validate('scm.getFileWithScmRepo.yaml', scm.getFile).error);69 });70 it('fails', () => {71 assert.isNotNull(validate('empty.yaml', scm.getFile).error);72 });73 });74 describe('getChangedFiles', () => {75 it('validates input', () => {76 assert.isNull(validate('scm.getChangedFilesInput.yaml', scm.getChangedFilesInput).error);77 });78 it('fails empty input', () => {79 assert.isNotNull(validate('empty.yaml', scm.getChangedFilesInput).error);80 });81 it('validates output', () => {82 assert.isNull(validate('scm.getChangedFilesOutput.yaml', scm.getChangedFilesOutput).error);83 });84 it('validates empty array output', () => {85 assert.isNull(validate('scm.getChangedFilesEmptyArrayOutput.yaml', scm.getChangedFilesOutput).error);86 });87 it('validates empty output', () => {88 assert.isNull(validate('empty.yaml', scm.getChangedFilesOutput).error);89 });90 });91 describe('decorateUrl', () => {92 it('validates', () => {93 assert.isNull(validate('scm.decorateUrl.yaml', scm.decorateUrl).error);94 });95 it('validates with optional scmRepo', () => {96 assert.isNull(validate('scm.decorateUrlWithScmRepo.yaml', scm.decorateUrl).error);97 });98 it('fails', () => {99 assert.isNotNull(validate('empty.yaml', scm.decorateUrl).error);100 });101 });102 describe('decorateCommit', () => {103 it('validates', () => {104 assert.isNull(validate('scm.decorateCommit.yaml', scm.decorateCommit).error);105 });106 it('fails', () => {107 assert.isNotNull(validate('empty.yaml', scm.decorateCommit).error);108 });109 });110 describe('decorateAuthor', () => {111 it('validates', () => {112 assert.isNull(validate('scm.decorateAuthor.yaml', scm.decorateAuthor).error);113 });114 it('fails', () => {115 assert.isNotNull(validate('empty.yaml', scm.decorateAuthor).error);116 });117 });118 describe('parseUrl', () => {119 it('validates', () => {120 assert.isNull(validate('scm.parseUrl.yaml', scm.parseUrl).error);121 });122 it('fails', () => {123 assert.isNotNull(validate('empty.yaml', scm.parseUrl).error);124 });125 });126 describe('getCheckoutCommand', () => {127 it('validates', () => {128 assert.isNull(validate('scm.getCheckoutCommand.yaml', scm.getCheckoutCommand).error);129 });130 it('fails', () => {131 assert.isNotNull(validate('empty.yaml', scm.getCheckoutCommand).error);132 });133 });134 describe('parseHook', () => {135 it('validates full output', () => {136 assert.isNull(validate('scm.parseHook.yaml', scm.parseHookOutput).error);137 });138 it('validates null output', () => {139 const res = scm.parseHookOutput.validate(null).error;140 assert.equal(res, undefined);141 });142 });143 describe('addWebhook', () => {144 it('validates', () => {145 assert.isNull(validate('scm.addWebhook.yaml', scm.addWebhook).error);146 });147 it('fails', () => {148 assert.isNotNull(validate('empty.yaml', scm.addWebhook).error);149 });150 });151 describe('addDeployKey', () => {152 it('validates', () => {153 assert.isNull(validate('scm.addDeployKey.yaml', scm.addDeployKey).error);154 });155 it('fails', () => {156 assert.isNotNull(validate('empty.yaml', scm.addDeployKey).error);157 });158 });159 describe('getBranchList', () => {160 it('validates', () => {161 assert.isNull(validate('scm.getBranchList.yaml', scm.getBranchList).error);162 });163 it('fails', () => {164 assert.isNotNull(validate('empty.yaml', scm.getBranchList).error);165 });166 });167 describe('openPr', () => {168 it('validates', () => {169 assert.isNull(validate('scm.openPr.yaml', scm.openPr).error);170 });171 it('fails', () => {172 assert.isNotNull(validate('empty.yaml', scm.openPr).error);173 });174 });175 describe('scm to build map', () => {176 it('validates scm statuses mapping', () => {177 assert.strictEqual(scm.SCM_STATE_MAP.QUEUED, 'PENDING');178 });179 it('validates an invalid scm statuses mapping', () => {180 assert.notStrictEqual(scm.SCM_STATE_MAP.QUEUED, 'SUCCESS');181 });182 });183 describe('scm statuses', () => {184 it('check a valid scm status', () => {185 assert.isTrue(scm.SCM_STATUSES.includes('PENDING'));186 });187 it('check an invalid scm status', () => {188 assert.isFalse(scm.SCM_STATUSES.includes('QUEUED'));189 });190 });...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...45 gitAuthToken = gitAuthToken || await getSecretValue(GIT_SECRET_MANAGER_NAME, GIT_PAT_SECRET_KEY);46 gitConnection = gitConnection || GITHUB.getOctokit(gitAuthToken);47 return gitConnection;48}49async function updateCommitStatus(repoInfo) {50 let octokit = await getGitConnection();51 return octokit.repos.createCommitStatus({52 owner: GIT_OWNER,53 repo: repoInfo.repoName,54 sha: repoInfo.commitId,55 state: repoInfo.state,56 context: GIT_COMMIT_STATUS_CONTEXT,57 description: GIT_COMMIT_STATUS_DESC,58 target_url: repoInfo.target_url59 });60}61exports.handler = (event, context, callback) => {62 try {63 const { headers: { 'X-Hub-Signature': webhookSecretSignature, 'X-GitHub-Event': githubEvent }, body } = event,64 validPrStatus = ['opened', 'reopened', 'synchronize'],65 requestBody = JSON.parse(body);66 if (githubEvent === 'pull_request' && validPrStatus.includes(requestBody.action) && await verifySignature(webhookSecretSignature, requestBody)) {67 let {68 number: prNumber,69 repository: { name: repoName },70 pull_request: { head: { ref: branchName, sha: commitId } }71 } = requestBody,72 codeBuildParams = {73 projectName: CODEBUILD_NAME,74 environmentVariablesOverride: [75 {76 name: 'REPO',77 value: `${repoName}`78 },79 {80 name: 'BRANCH_NAME',81 value: `${branchName}`82 },83 {84 name: 'PR_NUMBER',85 value: `${prNumber}`86 },87 {88 name: 'COMMIT_ID',89 value: `${commitId}`90 }91 ]92 };93 let repoInfo = { repoName, commitId };94 CodeBuild.startBuild(codeBuildParams, async function (err, data) {95 if (err) {96 console.log(err, err.stack);97 repoInfo.state = 'failure';98 repoInfo.target_url = 'https://console.aws.amazon.com/cloudwatch/home';99 await updateCommitStatus(repoInfo);100 callback(null, responseBody(err));101 }102 else {103 let { build: { id, logs: { deepLink } } } = data;104 let [buildName, buildId] = id.split(':');105 repoInfo.state = 'pending';106 repoInfo.target_url = encodeURI(deepLink.replace('null', `/aws/codebuild/${buildName}`).replace('null', buildId));107 await updateCommitStatus(repoInfo);108 callback(null, responseBody(data));109 }110 });111 } else {112 callback(null, responseBody('Invalid Request'));113 }114 } catch (error) {115 callback(null, responseBody(error));116 }...

Full Screen

Full Screen

updateCommitStatus.runnable.spec.ts

Source:updateCommitStatus.runnable.spec.ts Github

copy

Full Screen

1import { Test, TestingModule } from '@nestjs/testing';2import { GithubService } from '../github/github.service';3import { GitlabService } from '../gitlab/gitlab.service';4import { GitTypeEnum } from '../webhook/utils.enum';5import { CallbackType } from './runnables.service';6import { RuleResult } from '../rules/ruleResult';7import { MockGitlabService, MockGithubService } from '../__mocks__/mocks';8import { UpdateCommitStatusRunnable } from './updateCommitStatus.runnable';9import { EnvVarAccessor } from '../env-var/env-var.accessor';10import { Webhook } from '../webhook/webhook';11import { Logger } from '@nestjs/common';12jest.mock('../analytics/analytics.decorator');13describe('UpdateCommitStatusRunnable', () => {14 let app: TestingModule;15 let githubService: GithubService;16 let gitlabService: GitlabService;17 let updateCommitStatus: UpdateCommitStatusRunnable;18 let args: any;19 let ruleResultCommitMessage: RuleResult;20 beforeAll(async () => {21 app = await Test.createTestingModule({22 providers: [23 UpdateCommitStatusRunnable,24 { provide: GitlabService, useClass: MockGitlabService },25 { provide: GithubService, useClass: MockGithubService },26 EnvVarAccessor,27 ],28 }).compile();29 githubService = app.get(GithubService);30 gitlabService = app.get(GitlabService);31 updateCommitStatus = app.get(UpdateCommitStatusRunnable);32 const webhook = new Webhook(gitlabService, githubService);33 webhook.branchName = 'test_webhook';34 ruleResultCommitMessage = new RuleResult(webhook);35 ruleResultCommitMessage.validated = true;36 ruleResultCommitMessage.data.commits = [37 {38 status: 'Success',39 success: true,40 sha: '1',41 message: 'fix: readme (#12)',42 matches: ['fix: readme (#12)', 'fix', null, '(#12)'],43 },44 {45 status: 'Success',46 success: true,47 sha: '2',48 message: 'feat(test): tdd (#34)',49 matches: ['feat(test): tdd (#34)', 'feat', '(test)', '(#34)'],50 },51 {52 status: 'Success',53 success: true,54 sha: '3',55 message: 'docs: gh-pages',56 matches: ['docs: gh-pages', 'docs', null, null],57 },58 ];59 args = {60 successTargetUrl: 'http://www.google.com',61 failTargetUrl: 'http://moogle.com/',62 successDescriptionMessage: 'good commit status!',63 failDescriptionMessage: 'NOOOT good...',64 };65 });66 beforeEach(() => {67 jest.clearAllMocks();68 });69 describe('updateCommitMessage Runnable', () => {70 it('should not call the updateCommitStatus Github nor Gitlab service', () => {71 updateCommitStatus72 .run(CallbackType.Both, ruleResultCommitMessage, args)73 .catch(err => Logger.error(err));74 expect(githubService.updateCommitStatus).not.toBeCalled();75 expect(gitlabService.updateCommitStatus).not.toBeCalled();76 });77 });78 describe('updateCommitMessage Runnable', () => {79 it('should call the updateCommitStatus Github service 3 times', () => {80 ruleResultCommitMessage.gitApiInfos.git = GitTypeEnum.Github;81 updateCommitStatus82 .run(CallbackType.Both, ruleResultCommitMessage, args)83 .catch(err => Logger.error(err));84 expect(githubService.updateCommitStatus).toBeCalledTimes(3);85 expect(gitlabService.updateCommitStatus).not.toBeCalled();86 });87 });88 describe('updateCommitMessage Runnable', () => {89 it('should call the updateCommitStatus Gitlab service 3 times', () => {90 ruleResultCommitMessage.gitApiInfos.git = GitTypeEnum.Gitlab;91 updateCommitStatus92 .run(CallbackType.Both, ruleResultCommitMessage, args)93 .catch(err => Logger.error(err));94 expect(githubService.updateCommitStatus).not.toBeCalled();95 expect(gitlabService.updateCommitStatus).toBeCalledTimes(3);96 });97 });...

Full Screen

Full Screen

deploy.spec.ts

Source:deploy.spec.ts Github

copy

Full Screen

1import 'mocha';2import { expect } from 'chai';3import * as sinon from 'sinon';4import deploy from './deploy';5import * as Chance from 'chance';6import { IGithubService } from './createGithubService';7describe('deploy', () => {8 let rootPath;9 let sourceDirectory;10 let domain;11 let surgeService;12 let sandbox;13 let fileService;14 let githubService: IGithubService;15 let pr;16 let sha;17 beforeEach(() => {18 sandbox = sinon.createSandbox();19 rootPath = Chance().word();20 sourceDirectory = Chance().word();21 domain = Chance().word();22 sha = Chance().word();23 pr = Chance().natural({ min: 1, max: 20 });24 surgeService = sandbox.spy();25 fileService = {26 exists: sandbox.stub().returns(true),27 };28 githubService = {29 isInitialized: sandbox.stub().returns(Chance().bool()),30 updateCommitStatus: sandbox.spy(),31 getPrSha: sandbox.stub().returns(sha),32 };33 });34 afterEach(() => {35 sandbox.restore();36 });37 const callDeploy = async () =>38 deploy({39 rootPath,40 sourceDirectory,41 domain,42 pr,43 surgeService,44 fileService,45 githubService,46 });47 const givenInitializedGithubService = isInitialized => {48 githubService.isInitialized = sandbox.stub().returns(isInitialized);49 };50 it('should update the status as pending', async () => {51 givenInitializedGithubService(true);52 await callDeploy();53 expect(githubService.updateCommitStatus).to.be.calledWithExactly({54 sha,55 state: 'pending',56 description: 'Deploying to surge',57 context: domain,58 });59 });60 it('should call surge with the correct static folder and domain', async () => {61 await callDeploy();62 expect(surgeService).to.be.calledOnce.and.to.be.calledWithExactly([63 'publish',64 '--project',65 `${rootPath}/${sourceDirectory}`,66 '--domain',67 `https://${domain}-pr-${pr}.surge.sh/`,68 ]);69 });70 it('should call surge with the correct static folder and domain with no pr', async () => {71 pr = null;72 await callDeploy();73 expect(surgeService).to.be.calledOnce.and.to.be.calledWithExactly([74 'publish',75 '--project',76 `${rootPath}/${sourceDirectory}`,77 '--domain',78 `https://${domain}.surge.sh/`,79 ]);80 });81 it('should update the status as success', async () => {82 givenInitializedGithubService(true);83 await callDeploy();84 expect(githubService.updateCommitStatus).to.be.calledTwice;85 expect(86 (githubService.updateCommitStatus as any).secondCall,87 ).to.be.calledWithExactly({88 sha,89 state: 'success',90 description: 'Deployed to surge.sh',91 target_url: `https://${domain}-pr-${pr}.surge.sh/`,92 context: domain,93 });94 });95 it('should update the status as error', async () => {96 givenInitializedGithubService(true);97 surgeService = sinon.stub().throws();98 try {99 await callDeploy();100 } catch (e) {101 expect(e).to.be.an('Error');102 }103 expect(githubService.updateCommitStatus).to.be.calledTwice;104 expect(105 (githubService.updateCommitStatus as any).secondCall,106 ).to.be.calledWithExactly({107 sha,108 state: 'error',109 description: 'Deployment failed',110 context: domain,111 });112 });113 it('should fail if the folder does not exist', async () => {114 fileService = {115 exists: sandbox.stub().returns(false),116 };117 let error;118 try {119 await callDeploy();120 } catch (e) {121 error = e;122 }123 expect(error).to.be.an('Error');124 });125 it('should not update the commit status', async () => {126 givenInitializedGithubService(false);127 await callDeploy();128 expect(githubService.updateCommitStatus).to.not.be.called;129 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { updateCommitStatus } = require("qawolf");2const { GITHUB_TOKEN, GITHUB_REPOSITORY, GITHUB_SHA } = process.env;3const run = async () => {4 if (!GITHUB_TOKEN || !GITHUB_REPOSITORY || !GITHUB_SHA) {5 throw new Error("Missing environment variables");6 }7 const [owner, repo] = GITHUB_REPOSITORY.split("/");8 await updateCommitStatus({

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require('qawolf');2const { updateCommitStatus } = qawolf;3updateCommitStatus('commitId', 'status', 'url', 'description');4const qawolf = require('qawolf');5const { updateCommitStatus } = qawolf;6updateCommitStatus('commitId', 'status', 'url', 'description');7const qawolf = require('qawolf');8const { updateCommitStatus } = qawolf;9updateCommitStatus('commitId', 'status', 'url', 'description');10const qawolf = require('qawolf');11const { updateCommitStatus } = qawolf;12updateCommitStatus('commitId', 'status', 'url', 'description');13const qawolf = require('qawolf');14const { updateCommitStatus } = qawolf;15updateCommitStatus('commitId', 'status', 'url', 'description');16const qawolf = require('qawolf');17const { updateCommitStatus } = qawolf;18updateCommitStatus('commitId', 'status', 'url', 'description');19const qawolf = require('qawolf');20const { updateCommitStatus } = qawolf;21updateCommitStatus('commitId', 'status', 'url', 'description');22const qawolf = require('qawolf');23const { updateCommitStatus } = qawolf;24updateCommitStatus('commitId', 'status', 'url', 'description');25const qawolf = require('qawolf');26const { updateCommitStatus } = qawolf;27updateCommitStatus('commitId', 'status', 'url', 'description');28const qawolf = require('qawolf');29const { updateCommitStatus } = qawolf;30updateCommitStatus('commitId', 'status', 'url', 'description');31const qawolf = require('qawolf

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful