Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 79c21ca

Browse files
author
Iddo Gino
committed
add logic
1 parent 066146a commit 79c21ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+6333
-5
lines changed

index.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const core = require('@actions/core');
22
const github = require('@actions/github');
3+
const axios = require('axios');
34

45
// CONSTS
56
const WAIT_TIME = 1000;
@@ -27,8 +28,33 @@ function sleep(time) {
2728
}
2829

2930
core.group('Execute Test', async () => {
30-
await sleep(2000);
31-
console.log("AAAAA")
32-
core.setOutput("time", 123);
33-
return true
31+
// 1. Trigger Test
32+
const envString = ENVIRONMENT ? `&enviroment=${ENVIRONMENT}` : '';
33+
const testTrigger = (await axios.get(`${API_URL}/test/${TEST_ID}/execute?location=${LOCATION}${envString}`)).data;
34+
console.log(testTrigger.message);
35+
const executionId = testTrigger.executionId;
36+
37+
// 2. Perform initial wait -- this is to avoid multiple checks while test is ramping up
38+
await sleep(FIRST_WAIT-WAIT_TIME);
39+
40+
let testResult = null;
41+
let tries = 0;
42+
while (
43+
(!testResult || testResult.status == 'pending') &&
44+
tries < MAX_TRIES // safety
45+
) {
46+
await sleep(WAIT_TIME);
47+
testResult = (await axios.get(`${API_URL}/execution/${executionId}/status`)).data;
48+
}
49+
delete testResult.report;
50+
console.log(testResult);
51+
52+
// 3. Set Response Data
53+
core.setOutput("time", testResult.executionTime);
54+
core.setOutput("succesful", testResult.succesful);
55+
56+
// 4. Fail action if test failed
57+
if (!testResult.succesful) {
58+
core.setFailed(`Test execution failed. View report here: ${testTrigger.reportUrl}`);
59+
}
3460
});

node_modules/axios/CHANGELOG.md

Lines changed: 632 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/axios/LICENSE

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)