How to use octokit.repos.createCommitStatus method in qawolf

Best JavaScript code snippet using qawolf

deploy.js

Source:deploy.js Github

copy

Full Screen

...201 octokit,202 pullRequest,203 })204 } else {205 await octokit.repos.createCommitStatus({206 owner,207 repo,208 sha: pullRequest.head.sha,209 context: CONTEXT_NAME,210 state: 'pending',211 description: 'The app is being deployed. See local logs.',212 })213 await deployToStaging({214 octokit,215 pullRequest,216 forceRebuild,217 })218 await octokit.repos.createCommitStatus({219 owner,220 repo,221 sha: pullRequest.head.sha,222 context: CONTEXT_NAME,223 state: 'success',224 description: 'Successfully deployed! See local logs.',225 })226 }227 } catch (error) {228 const action = destroy ? 'undeploy from' : 'deploy to'229 console.error(`Failed to ${action} staging: ${error.message}`)230 console.error(error)231 if (!destroy) {232 await octokit.repos.createCommitStatus({233 owner,234 repo,235 sha: pullRequest.head.sha,236 context: CONTEXT_NAME,237 state: 'error',238 description: 'Failed to deploy. See local logs.',239 })240 }241 process.exit(1)242 }243}...

Full Screen

Full Screen

action.js

Source:action.js Github

copy

Full Screen

...23 if ( githubToken) {24 octokit = github.getOctokit(githubToken);25 }26 if ( octokit ) {27 await octokit.repos.createCommitStatus({28 ...context.repo,29 sha: batchId,30 state: 'pending'31 });32 }33 const baseUrl = core.getInput('baseUrl') || process.env.APPLITOOLS_BASE_URL;34 const sitemapUrl = core.getInput('sitemapUrl') || process.env.APPLITOOLS_SITEMAP_URL;35 if ( !baseUrl && !sitemapUrl ) {36 throw new Error(`Invalid URL: did you remember to set a baseUrl or sitemapUrl option?`);37 }38 const appName = core.getInput('appName');39 const batchName = core.getInput('batchName');40 const concurrency = parseInt(core.getInput('concurrency'));41 const cypressBrowser = core.getInput('cypressBrowser');42 const errorOnFailure = `${core.getInput('errorOnFailure')}` === 'true';43 const maxDepth = parseInt(core.getInput('maxDepth'));44 const serverUrl = core.getInput('serverUrl') || process.env.APPLITOOLS_SERVER_URL;45 const showLogs = `${core.getInput('showLogs')}` === 'true';46 if ( showLogs ) {47 console.log(`${prefix} --Start context--`);48 console.log(JSON.stringify(context, null, 2));49 console.log(`${prefix} --End context--`);50 }51 let ignoreSelector = core.getInput('ignoreSelector');52 let pagesToCheck = [];53 if ( baseUrl ) {54 console.log(`${prefix} Found baseUrl: ${baseUrl}`);55 if ( maxDepth === 1 ) {56 console.log(`${prefix} maxDepth set to 1, skipping crawl of ${baseUrl}`);57 pagesToCheck.push(baseUrl);58 } else {59 try {60 console.log(`${prefix} Crawling ${baseUrl} at a depth of ${maxDepth}`);61 const crawledPages = await promiseToCrawl({62 url: baseUrl,63 maxDepth64 });65 pagesToCheck = pagesToCheck.concat(crawledPages);66 } catch(error) {67 throw new Error(`Failed to crawl ${url}: ${error.message}`);68 }69 }70 }71 if ( sitemapUrl ) {72 console.log(`${prefix} Found sitemapUrl: ${sitemapUrl}`);73 try {74 const sitemapList = await promiseToGetAndReadSitemap(sitemapUrl);75 pagesToCheck = pagesToCheck.concat(sitemapList);76 } catch(error) {77 throw new Error(`Failed to get sitemap ${sitemapUrl}: ${error.message}`);78 }79 }80 ignoreSelector = ignoreSelector ? ignoreSelector.split(',').map(selector => ({ selector: selector.trim() })) : []81 core.exportVariable('APPLITOOLS_API_KEY', key);82 if ( batchId ) {83 core.exportVariable('APPLITOOLS_BATCH_ID', batchId);84 }85 const applitoolsConfig = {86 testConcurrency: concurrency,87 // showLogs: true88 }89 if ( isPullRequest ) {90 applitoolsConfig.branchName = `${repository.full_name}/${pull_request.head.ref}`;91 applitoolsConfig.parentBranchName = `${repository.full_name}/${pull_request.base.ref}`;92 } else {93 applitoolsConfig.branchName = `${repository.full_name}/${ref.replace('refs/heads/', '')}`;94 }95 if ( showLogs ) {96 console.log(`${prefix} --Start Applitools Config--`);97 console.log(JSON.stringify(applitoolsConfig, null, 2));98 console.log(`${prefix} --End Applitools config--`);99 }100 console.log(`${prefix} Writing applitools.config.js`);101 await fs.writeFile('./applitools.config.js', `module.exports = ${JSON.stringify(applitoolsConfig)}`, 'utf8');102 const cypressEnv = {103 APPLITOOLS_APP_NAME: appName,104 APPLITOOLS_BATCH_NAME: batchName,105 APPLITOOLS_SERVER_URL: serverUrl,106 APPLITOOLS_IGNORE_SELECTOR: ignoreSelector,107 PAGES_TO_CHECK: pagesToCheck108 };109 if ( showLogs ) {110 console.log(`${prefix} --Start Cypress Env--`);111 console.log(JSON.stringify(cypressEnv, null, 2));112 console.log(`${prefix} --End Cypress Env--`);113 }114 let results;115 let errors = [];116 try {117 results = await cypress.run({118 browser: cypressBrowser,119 config: {120 baseUrl121 },122 env: cypressEnv,123 headless: true,124 record: false,125 });126 if ( showLogs ) {127 console.log(`${prefix} --Start Cypress Results--`);128 console.log(JSON.stringify(results, null, 2));129 console.log(`${prefix} --End Cypress Results--`);130 }131 } catch(error) {132 errors.push(`Failed to run Eyes check: ${error.message}`)133 }134 if ( octokit ) {135 try {136 const batchResults = await waitFor200(() => getBatchByPointerId(batchId))137 if ( showLogs ) {138 console.log(`${prefix} --Start Applitools Results--`);139 console.log(JSON.stringify(batchResults, null, 2))140 console.log(`${prefix} --End Applitools Results--`);141 }142 const { completedCount, failedCount, passedCount, unresolvedCount } = batchResults;143 await octokit.repos.createCommitStatus({144 ...context.repo,145 sha: batchId,146 state: failedCount > 0 ? 'failure' : 'success'147 });148 if ( isPullRequest ) {149 const bodyReturn = "\n";150 let bodyParts = [151 `## <a href="${applitoolsHomeUrl}"><img width="140" src="${apptliioolsLogoUrl}" alt="Applitools"></a>`152 ];153 if ( completedCount > 1 ) {154 bodyParts.push(`${completedCount} visual tests have completed.`)155 } else if ( completedCount === 1 ) {156 bodyParts.push(`${completedCount} visual test has completed.`)157 } else {158 bodyParts.push(`No visual tests ran.`)159 }160 bodyParts.push(bodyReturn);161 if ( completedCount > 0 ) {162 bodyParts = bodyParts.concat([163 `✅ Passed: ${passedCount} / ${completedCount}`,164 `❌ Failed: ${failedCount} / ${completedCount}`,165 `⚠️ Unresolved: ${unresolvedCount} / ${completedCount}`166 ])167 }168 bodyParts.push(bodyReturn);169 bodyParts.push(`[Log in at applitools.com](${applitoolsHomeUrl}) for more details!`)170 await octokit.issues.createComment({171 ...context.repo,172 issue_number: pull_request.number,173 body: bodyParts.join(bodyReturn)174 });175 }176 } catch(error) {177 errors.push(`Failed to get Eyes batch: ${error.message}`)178 }179 }180 if ( errorOnFailure && results.totalFailed > 0 ) {181 errors.push(`${prefix} Unsuccessful with ${results.totalFailed} failing tests!`);182 }183 if ( errors.length > 0 ) {184 if ( octokit ) {185 await octokit.repos.createCommitStatus({186 ...context.repo,187 sha: batchId,188 state: 'error'189 });190 }191 core.setFailed(errors.join(';'));192 return;193 }194 if ( octokit ) {195 await octokit.repos.createCommitStatus({196 ...context.repo,197 sha: batchId,198 state: 'success'199 });200 }201 console.log(`${prefix} Success!`);202}203try {204 run();205} catch(error) {206 console.log(`${prefix} ERROR: ${error.message}`);207 core.setFailed(error.message);...

Full Screen

Full Screen

github-status.test.ts

Source:github-status.test.ts Github

copy

Full Screen

1import { Octokit } from '@octokit/rest';2import { APIGatewayProxyEvent, Context } from 'aws-lambda';3import ctx from 'aws-lambda-mock-context';4import github from '../../shared/github';5import { handler } from '../github-status';6jest.mock('../../shared/github', () =>7 jest.fn().mockResolvedValue({8 repos: {9 createCommitStatus: jest.fn(),10 },11 }),12);13describe('github-status', () => {14 let callback: jest.Mock;15 let context: Context;16 let event: APIGatewayProxyEvent;17 let octokit: Octokit;18 beforeEach(async () => {19 context = ctx();20 context.done();21 callback = jest.fn();22 octokit = await github();23 });24 describe('when RUN_FINISH event is received', () => {25 it('should send the correct payload when a single test has failed', async () => {26 event = {27 body: JSON.stringify({28 commit: {29 message: 'Merge x into y',30 remoteOrigin: 'https://path.to.location/owner/repo',31 sha: 'z',32 },33 event: 'RUN_FINISH',34 failures: 1,35 passes: 0,36 runUrl: 'https://path.to.location/',37 wallClockDurationSeconds: 2500,38 }),39 } as APIGatewayProxyEvent;40 await handler(event, context, callback);41 expect(octokit.repos.createCommitStatus).toHaveBeenCalledWith({42 context: 'Cypress',43 description: '1 test failed',44 owner: 'owner',45 repo: 'repo',46 sha: 'x',47 state: 'failure',48 target_url: 'https://path.to.location/',49 });50 });51 it('should send the correct payload when a multiple tests have failed', async () => {52 event = {53 body: JSON.stringify({54 commit: {55 message: 'Merge x into y',56 remoteOrigin: 'https://path.to.location/owner/repo',57 sha: 'z',58 },59 event: 'RUN_FINISH',60 failures: 2,61 passes: 0,62 runUrl: 'https://path.to.location/',63 wallClockDurationSeconds: 2500,64 }),65 } as APIGatewayProxyEvent;66 await handler(event, context, callback);67 expect(octokit.repos.createCommitStatus).toHaveBeenCalledWith({68 context: 'Cypress',69 description: '2 tests failed',70 owner: 'owner',71 repo: 'repo',72 sha: 'x',73 state: 'failure',74 target_url: 'https://path.to.location/',75 });76 });77 it('should send the correct payload when a single test has passed', async () => {78 event = {79 body: JSON.stringify({80 commit: {81 message: 'Merge x into y',82 remoteOrigin: 'https://path.to.location/owner/repo',83 sha: 'z',84 },85 event: 'RUN_FINISH',86 failures: 0,87 passes: 1,88 runUrl: 'https://path.to.location/',89 wallClockDurationSeconds: 39,90 }),91 } as APIGatewayProxyEvent;92 await handler(event, context, callback);93 expect(octokit.repos.createCommitStatus).toHaveBeenCalledWith({94 context: 'Cypress',95 description: '1 test passed in 0:39',96 owner: 'owner',97 repo: 'repo',98 sha: 'x',99 state: 'success',100 target_url: 'https://path.to.location/',101 });102 });103 it('should send the correct payload when multiple tests have passed', async () => {104 event = {105 body: JSON.stringify({106 commit: {107 message: 'Merge x into y',108 remoteOrigin: 'https://path.to.location/owner/repo',109 sha: 'z',110 },111 event: 'RUN_FINISH',112 failures: 0,113 passes: 12,114 runUrl: 'https://path.to.location/',115 wallClockDurationSeconds: 2500,116 }),117 } as APIGatewayProxyEvent;118 await handler(event, context, callback);119 expect(octokit.repos.createCommitStatus).toHaveBeenCalledWith({120 context: 'Cypress',121 description: '12 tests passed in 41:40',122 owner: 'owner',123 repo: 'repo',124 sha: 'x',125 state: 'success',126 target_url: 'https://path.to.location/',127 });128 });129 });130 describe('when RUN_START event is received', () => {131 beforeEach(() => {132 event = {133 body: JSON.stringify({134 commit: {135 message: 'Merge pull request x from y',136 remoteOrigin: 'https://path.to.location/owner/repo',137 sha: 'z',138 },139 event: 'RUN_START',140 failures: 0,141 passes: 0,142 runUrl: 'https://path.to.location/',143 wallClockDurationSeconds: 0,144 }),145 } as APIGatewayProxyEvent;146 });147 it('should send the correct payload', async () => {148 await handler(event, context, callback);149 expect(octokit.repos.createCommitStatus).toHaveBeenCalledWith({150 context: 'Cypress',151 description: 'This check has started...',152 owner: 'owner',153 repo: 'repo',154 sha: 'z',155 state: 'pending',156 target_url: 'https://path.to.location/',157 });158 });159 });160 describe('when RUN_TIMEOUT event is received', () => {161 beforeEach(() => {162 event = {163 body: JSON.stringify({164 commit: {165 message: 'Merge x into y',166 remoteOrigin: 'https://path.to.location/owner/repo',167 sha: 'z',168 },169 event: 'RUN_TIMEOUT',170 failures: 0,171 passes: 0,172 runUrl: 'https://path.to.location/',173 wallClockDurationSeconds: 0,174 }),175 } as APIGatewayProxyEvent;176 });177 it('should send the correct payload', async () => {178 await handler(event, context, callback);179 expect(octokit.repos.createCommitStatus).toHaveBeenCalledWith({180 context: 'Cypress',181 description: 'Test run has timed out',182 owner: 'owner',183 repo: 'repo',184 sha: 'x',185 state: 'failure',186 target_url: 'https://path.to.location/',187 });188 });189 });190 describe('when an unknown event is received', () => {191 beforeEach(() => {192 event = {193 body: JSON.stringify({194 commit: {195 message: 'Merge x into y',196 remoteOrigin: 'https://path.to.location/owner/repo',197 sha: 'z',198 },199 event: 'UNKNOWN',200 failures: 0,201 passes: 0,202 runUrl: 'https://path.to.location/',203 wallClockDurationSeconds: 0,204 }),205 } as APIGatewayProxyEvent;206 });207 it('should return an error response', async () => {208 await handler(event, context, callback);209 expect(callback).toHaveBeenCalledWith(null, {210 body: JSON.stringify({211 message: 'Invalid request',212 statusCode: 400,213 }),214 statusCode: 400,215 });216 });217 });218 describe('when payload is invalid', () => {219 beforeEach(() => {220 event = {221 body: JSON.stringify({}),222 } as APIGatewayProxyEvent;223 });224 it('should return an error response', async () => {225 await handler(event, context, callback);226 expect(callback).toHaveBeenCalledWith(null, {227 body: JSON.stringify({228 message: 'Invalid request',229 statusCode: 400,230 }),231 statusCode: 400,232 });233 });234 });...

Full Screen

Full Screen

autoupdater.js

Source:autoupdater.js Github

copy

Full Screen

...43 ...repo,44 sha: pullRequest.head.sha,45 context: `autoupdate from ${pullRequest.base.ref}`,46 };47 await octokit.repos.createCommitStatus({48 ...commitStatusParams,49 state: "pending",50 description: "Updating",51 });52 const timeout = setTimeout(() => {53 throw Error("Timed out waiting for status checks.");54 }, 30000);55 // await waitForStatusChecks(pullRequest, repo, octokit);56 clearTimeout(timeout);57 let error;58 try {59 await octokit.pulls.updateBranch({60 ...repo,61 pull_number: pullRequest.number,62 });63 } catch (e) {64 error = e;65 core.error(e.message);66 }67 await octokit.repos.createCommitStatus({68 ...commitStatusParams,69 state: error ? "error" : "success",70 description: error71 ? "There was an error. Check the action output for more information."72 : "Successfully updated",73 });74 core.endGroup();75}76async function fetchPullRequests(octokit, repo, base) {77 core.startGroup("Fetching PRs");78 const response = await octokit.pulls.list({ ...repo, base, state: "open" });79 const prs = response.data;80 if (!prs) {81 core.info(`No PRs have ${base} as their base branch.`);...

Full Screen

Full Screen

githubUtils.ts

Source:githubUtils.ts Github

copy

Full Screen

...13 repoOwner: owner,14 repoName: repo,15 commitHash: sha16 } = githubCommit17 await octokit.repos.createCommitStatus({18 owner,19 repo,20 sha,21 state: 'success',22 description: 'CI has completed successfully, all is fine',23 context: 'CI test',24 target_url: buildLink25 });26}27export async function createFailedCommitStatus(githubCommit: GithubCommit, buildLink?: string) {28 let {29 repoOwner: owner,30 repoName: repo,31 commitHash: sha32 } = githubCommit33 await octokit.repos.createCommitStatus({34 owner,35 repo,36 sha,37 state: 'failure',38 description: 'CI Build failed, all is fine. Please check CodeBuild for details',39 context: 'CI test',40 target_url: buildLink41 });42}43export async function createPendingCommitStatus(githubCommit: GithubCommit, buildLink?: string) {44 let {45 repoOwner: owner,46 repoName: repo,47 commitHash: sha48 } = githubCommit49 await octokit.repos.createCommitStatus({50 owner,51 repo,52 sha,53 state: 'pending',54 description: 'CI started, check details for status updates',55 context: 'CI test',56 target_url: buildLink57 })58}59export async function createCommitStatusForBuild(github: GithubCommit, build: AwsBuild) {60 let buildLink = build.getBuildLink()61 if (!await build.isCompleted()) {62 await this.createPendingCommitStatus(github, buildLink)63 } else {...

Full Screen

Full Screen

index.ts

Source:index.ts Github

copy

Full Screen

...7 }8 const statusArgs1 = context.repo({sha: context.payload.after, context: "great-app"});9 const statusArgs2 = context.repo({sha: context.payload.after, context: "great-app-2"});10 const statusArgs3 = context.repo({sha: context.payload.after, context: "great-app-3"});11 await context.octokit.repos.createCommitStatus({state: "pending", description: "started 1", ...statusArgs1});12 await context.octokit.repos.createCommitStatus({state: "pending", description: "started 2", ...statusArgs2});13 await context.octokit.repos.createCommitStatus({state: "pending", description: "started 3", ...statusArgs3});14 await delay(10000);15 await context.octokit.repos.createCommitStatus({state: "success", description: "AOK BOSS 1", ...statusArgs1});16 context.octokit.repos.createCommitStatus({state: "failure", description: "AOK BOSS 2", ...statusArgs2});17 context.octokit.repos.createCommitStatus({state: "success", description: "AOK BOSS 3", ...statusArgs3});18 });19};20function delay(ms: number) {21 return new Promise( resolve => setTimeout(resolve, ms) );...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Octokit } = require("@octokit/rest");2const { createCommitStatus } = require("@qawolf/octokit-plugin");3const octokit = new Octokit({4});5octokit.plugin(createCommitStatus);6async function main() {7 const commitStatus = await octokit.repos.createCommitStatus({8 });9 console.log(commitStatus

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createCommitStatus } = require("@qawolf/octokit");2const { create } = require("@qawolf/web");3const { GITHUB_TOKEN } = process.env;4const run = async () => {5 const browser = await create();6 const context = browser.context();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Octokit } = require("@octokit/rest");2const octokit = new Octokit({3});4const owner = process.env.OWNER;5const repo = process.env.REPO;6const sha = process.env.SHA;7const state = process.env.STATE;8const context = process.env.CONTEXT;9const description = process.env.DESCRIPTION;10const target_url = process.env.TARGET_URL;11const options = octokit.repos.createCommitStatus.endpoint.merge({12});13 .request(options)14 .then((res) => {15 console.log(res.data);16 })17 .catch((err) => {18 console.log(err);19 });

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createCommitStatus } = require("@qawolf/octokit");2const { GITHUB_TOKEN, GITHUB_REPOSITORY, GITHUB_SHA } = process.env;3async function createCommitStatus() {4 const octokit = new Octokit({5 });6 const [owner, repo] = GITHUB_REPOSITORY.split("/");7 await octokit.repos.createCommitStatus({8 });9}10createCommitStatus().catch((error) => {11 console.error(error);12 process.exit(1);13});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Octokit } = require("@octokit/rest");2const octokit = new Octokit({3});4const owner = process.argv[2];5const repo = process.argv[3];6const sha = process.argv[4];7const state = process.argv[5];8const target_url = process.argv[6];9const description = process.argv[7];10const context = process.argv[8];11const token = process.argv[9];12async function main() {13 try {14 const params = {15 };16 const result = await octokit.repos.createCommitStatus(params);17 console.log(result);18 } catch (error) {19 console.log(error);20 }21}22main();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Octokit } = require("@octokit/rest");2const { Command } = require("commander");3const program = new Command();4 .requiredOption("--owner <owner>")5 .requiredOption("--repo <repo>")6 .requiredOption("--sha <sha>")7 .requiredOption("--state <state>")8 .requiredOption("--target_url <target_url>")9 .requiredOption("--description <description>");10program.parse(process.argv);11const options = program.opts();12const octokit = new Octokit({13});14 .createCommitStatus({15 })16 .then(() => console.log("Success"))17 .catch((e) => console.log(e));

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