Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added waitForJobCompletion input parameter and result-url output parameter #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
# accelq-ci-github-actions

Github Actions ACCELQ CI Plugin

## Inputs

### `appURL`
**Required**
Your ACCELQ application URL in the format: https://hostname:port

### `userName`
**Required**
Your ACCELQ User ID

### `apiKey`
**Required**
API key available in the Profile section of ACCELQ

### `tenantCode`
**Required**
Tenant Code displayed in the Profile section of ACCELQ

### `jobId`
**Required**
This ID should come from the job saved in ACCELQ

### `runParam`
Run parameters in JSON string format. Example:
```
{
"username": "John Todd",
"password": "bxW&=UVw"
}
```

### `proxyHost`
Proxy Host

### `proxyPort`
Proxy Port

### `stepFailureThreshold`
Percentage of ACCELQ test case failure, beyond which this step will be marked as a failure in the CI pipeline.
If this is zero, even a single failed test will cause the step to fail. If you never want to fail this step due to failing automation tests, input -1.
Allowed values: integer between 0 and 100 or. Default is -1.

### `maxWaitTimeInMins`
Maximum time to wait for the job to be picked up by an ACCELQ Agent. Default is 15 mins.

### `waitForJobCompletion`
If true, wait for the job to be completed. If false, run the job and exit. Default is true.


## Outputs

### `result-url`
The ACCELQ url to access the job results
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ inputs:
maxWaitTimeInMins:
description: "Maximum time to wait for the job to be picked up by an ACCELQ Agent. Default is 15 mins."
required: false

waitForJobCompletion:
description: 'If true, wait for the job to be completed. If false, run the job and exit. Default is true.'
required: false
outputs:
result-url:
description: "The ACCELQ url to access the job results"
runs:
using: 'node12'
main: 'index.js'
Expand Down
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

export NODE_OPTIONS=--openssl-legacy-provider
npm run build
2 changes: 1 addition & 1 deletion index.js

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function getMaxWaitTime(maxWaitTimeInMins: string) {
}

async function executeJob(appURL:string, userName:string, apiKey:string, tenantCode:string, jobId:string,
runParam:string, proxyHost:string, proxyPort:string, stepFailureThreshold: string, maxWaitTimeInMins: string) {
runParam:string, proxyHost:string, proxyPort:string, stepFailureThreshold: string, maxWaitTimeInMins: string, waitForJobCompletion: boolean) {
let summaryObj = null;
let realJobPid = 0;
let failureThreshold = +stepFailureThreshold;
Expand Down Expand Up @@ -71,7 +71,8 @@ async function executeJob(appURL:string, userName:string, apiKey:string, tenantC
const resultAccessURL = AQRestClient.getResultExternalAccessURL(realJobPid.toString(), tenantCode);
let error = false;
let hasLoggedLinks = false;
while(true) {
console.log("Wait for job completion: " + waitForJobCompletion)
while(waitForJobCompletion) {
try {
summaryObj = await AQRestClient.getJobSummary(realJobPid, apiKey, userName);
error = false;
Expand Down Expand Up @@ -160,6 +161,7 @@ async function executeJob(appURL:string, userName:string, apiKey:string, tenantC
}
return {
jobId: realJobPid,
resultUrl: resultAccessURL,
status: true,
error: null
};
Expand All @@ -175,6 +177,7 @@ async function executeJob(appURL:string, userName:string, apiKey:string, tenantC
console.log("Pass: " + summaryObj["pass"]);
return {
jobId: realJobPid,
resultUrl: "",
status: false,
error: e,
};
Expand All @@ -193,10 +196,11 @@ async function run() {
const proxyPort = core.getInput('proxyPort') || "";
const stepFailureThreshold = core.getInput('stepFailureThreshold') || "";
const maxWaitTimeInMins = core.getInput('maxWaitTimeInMins') || "";
const waitForJobCompletion = (core.getInput('waitForJobCompletion') || "true").toLowerCase() === "true";

// validateFORM
let res: string | null | {
jobId: number; status: boolean, error?: any };
jobId: number; resultUrl: string, status: boolean, error?: any };
res = AQFormValidate.validateAppURL(appURL);
if (res != null) {
throw new Error('ACCELQ App URL: ' + res);
Expand Down Expand Up @@ -227,12 +231,13 @@ async function run() {
throw new Error(res);
}
// executeJob
res = await executeJob(appURL, userName, apiKey, tenantCode, jobId, runParam, proxyHost, proxyPort, stepFailureThreshold, maxWaitTimeInMins);
res = await executeJob(appURL, userName, apiKey, tenantCode, jobId, runParam, proxyHost, proxyPort, stepFailureThreshold, maxWaitTimeInMins, waitForJobCompletion);
if (res.status) {
console.log('Run Completed!!!');
} else {
core.setFailed(res.error?.message || "Job Failed!!!");
}
core.setOutput("result-url", res.resultUrl);
}
catch (err: any) {
core.setFailed(err.message);
Expand Down
Empty file modified node_modules/.bin/webpack
100644 → 100755
Empty file.