Skip to content

Commit 43061c6

Browse files
committed
v1.15 release
1 parent 5c79e28 commit 43061c6

File tree

146 files changed

+3949
-4319
lines changed

Some content is hidden

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

146 files changed

+3949
-4319
lines changed

lib/src/constants.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ var ActionInputs;
1515
ActionInputs["RebaselineImages"] = "rebaseline-images";
1616
ActionInputs["SetStaticBaseline"] = "set-static-baseline";
1717
ActionInputs["Uri"] = "uri";
18-
})(ActionInputs = exports.ActionInputs || (exports.ActionInputs = {}));
18+
ActionInputs["UrlApi"] = "api-url";
19+
ActionInputs["UrlApp"] = "app-url";
20+
})(ActionInputs || (exports.ActionInputs = ActionInputs = {}));
1921
var ActionOutputs;
2022
(function (ActionOutputs) {
2123
ActionOutputs["DeploymentId"] = "mabl-deployment-id";
@@ -25,4 +27,4 @@ var ActionOutputs;
2527
ActionOutputs["TestsRun"] = "tests_run";
2628
ActionOutputs["TestsPassed"] = "tests_passed";
2729
ActionOutputs["TestsFailed"] = "tests_failed";
28-
})(ActionOutputs = exports.ActionOutputs || (exports.ActionOutputs = {}));
30+
})(ActionOutputs || (exports.ActionOutputs = ActionOutputs = {}));

lib/src/index.js

+34-15
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,39 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1515
}) : function(o, v) {
1616
o["default"] = v;
1717
});
18-
var __importStar = (this && this.__importStar) || function (mod) {
19-
if (mod && mod.__esModule) return mod;
20-
var result = {};
21-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22-
__setModuleDefault(result, mod);
23-
return result;
24-
};
18+
var __importStar = (this && this.__importStar) || (function () {
19+
var ownKeys = function(o) {
20+
ownKeys = Object.getOwnPropertyNames || function (o) {
21+
var ar = [];
22+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23+
return ar;
24+
};
25+
return ownKeys(o);
26+
};
27+
return function (mod) {
28+
if (mod && mod.__esModule) return mod;
29+
var result = {};
30+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31+
__setModuleDefault(result, mod);
32+
return result;
33+
};
34+
})();
2535
var __importDefault = (this && this.__importDefault) || function (mod) {
2636
return (mod && mod.__esModule) ? mod : { "default": mod };
2737
};
2838
Object.defineProperty(exports, "__esModule", { value: true });
29-
exports.run = exports.booleanInput = exports.optionalInput = exports.optionalArrayInput = void 0;
39+
exports.optionalArrayInput = optionalArrayInput;
40+
exports.optionalInput = optionalInput;
41+
exports.booleanInput = booleanInput;
42+
exports.run = run;
3043
const axios_1 = __importDefault(require("axios"));
3144
const mablApiClient_1 = require("./mablApiClient");
3245
const table_1 = require("./table");
3346
const core = __importStar(require("@actions/core"));
3447
const github = __importStar(require("@actions/github"));
3548
const constants_1 = require("./constants");
3649
const DEFAULT_MABL_APP_URL = 'https://app.mabl.com';
37-
const EXECUTION_POLL_INTERVAL_MILLIS = 10000;
50+
const EXECUTION_POLL_INTERVAL_MILLIS = 10_000;
3851
const EXECUTION_COMPLETED_STATUSES = [
3952
'succeeded',
4053
'failed',
@@ -52,7 +65,6 @@ function optionalArrayInput(name) {
5265
.filter((item) => item.length)
5366
.map((item) => item.trim());
5467
}
55-
exports.optionalArrayInput = optionalArrayInput;
5668
function optionalInput(name) {
5769
const rawValue = core.getInput(name, {
5870
required: false,
@@ -62,15 +74,13 @@ function optionalInput(name) {
6274
}
6375
return;
6476
}
65-
exports.optionalInput = optionalInput;
6677
function booleanInput(name) {
6778
return (core
6879
.getInput(name, {
6980
required: false,
7081
})
7182
.toLowerCase() === 'true');
7283
}
73-
exports.booleanInput = booleanInput;
7484
async function run(enableFailureExitCodes = true) {
7585
const wrappedFailed = (message) => {
7686
if (enableFailureExitCodes) {
@@ -90,13 +100,22 @@ async function run(enableFailureExitCodes = true) {
90100
const browserTypes = optionalArrayInput(constants_1.ActionInputs.BrowserTypes);
91101
const httpHeaders = optionalArrayInput(constants_1.ActionInputs.HttpHeaders);
92102
const uri = optionalInput(constants_1.ActionInputs.Uri);
103+
const apiUrl = optionalInput(constants_1.ActionInputs.UrlApi);
104+
const appUrl = optionalInput(constants_1.ActionInputs.UrlApp);
93105
const mablBranch = optionalInput(constants_1.ActionInputs.MablBranch);
94106
const rebaselineImages = booleanInput(constants_1.ActionInputs.RebaselineImages);
95107
const setStaticBaseline = booleanInput(constants_1.ActionInputs.SetStaticBaseline);
96108
const continueOnPlanFailure = booleanInput(constants_1.ActionInputs.ContinueOnFailure);
97109
const pullRequest = await getRelatedPullRequest();
98110
const eventTimeString = optionalInput(constants_1.ActionInputs.EventTime);
99111
const eventTime = eventTimeString ? parseInt(eventTimeString) : Date.now();
112+
if (uri) {
113+
core.warning(`[${constants_1.ActionInputs.Uri}] has been deprecated. Please use [${constants_1.ActionInputs.UrlApp}] instead.`);
114+
}
115+
if (uri && appUrl) {
116+
core.warning(`Both [${constants_1.ActionInputs.Uri}] and [${constants_1.ActionInputs.UrlApp}] were set. The value for [${constants_1.ActionInputs.UrlApp}] will be used`);
117+
}
118+
const effectiveAppUrl = appUrl ?? uri;
100119
let properties = {
101120
triggering_event_name: process.env.GITHUB_EVENT_NAME,
102121
repository_commit_username: process.env.GITHUB_ACTOR,
@@ -127,7 +146,7 @@ async function run(enableFailureExitCodes = true) {
127146
core.endGroup();
128147
core.startGroup('Creating deployment event');
129148
const apiClient = new mablApiClient_1.MablApiClient(apiKey);
130-
const deployment = await apiClient.postDeploymentEvent(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, uri, revision, mablBranch);
149+
const deployment = await apiClient.postDeploymentEvent(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, effectiveAppUrl, apiUrl, revision, mablBranch);
131150
core.setOutput(constants_1.ActionOutputs.DeploymentId, deployment.id);
132151
let appOrEnv;
133152
if (applicationId) {
@@ -140,7 +159,8 @@ async function run(enableFailureExitCodes = true) {
140159
wrappedFailed('Invalid configuration. Valid "application-id" or "environment-id" must be set. No tests started.');
141160
return;
142161
}
143-
const outputLink = `${baseAppUrl}/workspaces/${appOrEnv.organization_id}/events/${deployment.id}`;
162+
const effectiveWorkspaceId = appOrEnv.workspace_id ?? appOrEnv.organization_id;
163+
const outputLink = `${baseAppUrl}/workspaces/${effectiveWorkspaceId}/events/${deployment.id}`;
144164
core.info(`Deployment triggered. View output at: ${outputLink}`);
145165
core.startGroup('Await completion of tests');
146166
let executionComplete = false;
@@ -185,7 +205,6 @@ async function run(enableFailureExitCodes = true) {
185205
wrappedFailed(`mabl deployment task failed for the following reason: ${err}`);
186206
}
187207
}
188-
exports.run = run;
189208
function sleep(milliseconds) {
190209
return new Promise((resolve, reject) => {
191210
try {

lib/src/mablApiClient.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ exports.MablApiClient = void 0;
77
const async_retry_1 = __importDefault(require("async-retry"));
88
const axios_1 = __importDefault(require("axios"));
99
const constants_1 = require("./constants");
10-
const GET_REQUEST_TIMEOUT_MILLIS = 600000;
11-
const POST_REQUEST_TIMEOUT_MILLIS = 900000;
10+
const GET_REQUEST_TIMEOUT_MILLIS = 600_000;
11+
const POST_REQUEST_TIMEOUT_MILLIS = 900_000;
1212
class MablApiClient {
1313
constructor(apiKey) {
1414
this.baseUrl = process.env.MABL_REST_API_URL ?? 'https://api.mabl.com';
@@ -85,16 +85,16 @@ class MablApiClient {
8585
throw new Error(`failed to get mabl execution results for event ${eventId} from the API ${error}`);
8686
}
8787
}
88-
async postDeploymentEvent(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, uri, revision, mablBranch) {
88+
async postDeploymentEvent(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, appUrl, apiUrl, revision, mablBranch) {
8989
try {
90-
const requestBody = this.buildRequestBody(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, uri, revision, mablBranch);
90+
const requestBody = this.buildRequestBody(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, appUrl, apiUrl, revision, mablBranch);
9191
return await this.makePostRequest(`${this.baseUrl}/events/deployment/`, requestBody);
9292
}
9393
catch (e) {
9494
throw new Error(`failed to create deployment through mabl API ${e}`);
9595
}
9696
}
97-
buildRequestBody(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, uri, revision, mablBranch) {
97+
buildRequestBody(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, appUrl, apiUrl, revision, mablBranch) {
9898
const requestBody = {};
9999
if (environmentId) {
100100
requestBody.environment_id = environmentId;
@@ -109,8 +109,11 @@ class MablApiClient {
109109
if (browserTypes.length) {
110110
planOverrides.browser_types = browserTypes;
111111
}
112-
if (uri) {
113-
planOverrides.uri = uri;
112+
if (appUrl) {
113+
planOverrides.web_url = appUrl;
114+
}
115+
if (apiUrl) {
116+
planOverrides.api_url = apiUrl;
114117
}
115118
if (httpHeaders.length) {
116119
planOverrides.http_headers = httpHeaders.map((header) => {

lib/src/table.js

+18-9
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1515
}) : function(o, v) {
1616
o["default"] = v;
1717
});
18-
var __importStar = (this && this.__importStar) || function (mod) {
19-
if (mod && mod.__esModule) return mod;
20-
var result = {};
21-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22-
__setModuleDefault(result, mod);
23-
return result;
24-
};
18+
var __importStar = (this && this.__importStar) || (function () {
19+
var ownKeys = function(o) {
20+
ownKeys = Object.getOwnPropertyNames || function (o) {
21+
var ar = [];
22+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23+
return ar;
24+
};
25+
return ownKeys(o);
26+
};
27+
return function (mod) {
28+
if (mod && mod.__esModule) return mod;
29+
var result = {};
30+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31+
__setModuleDefault(result, mod);
32+
return result;
33+
};
34+
})();
2535
var __importDefault = (this && this.__importDefault) || function (mod) {
2636
return (mod && mod.__esModule) ? mod : { "default": mod };
2737
};
2838
Object.defineProperty(exports, "__esModule", { value: true });
29-
exports.prettyFormatExecution = void 0;
39+
exports.prettyFormatExecution = prettyFormatExecution;
3040
const cli_table3_1 = __importDefault(require("cli-table3"));
3141
const moment = __importStar(require("moment"));
3242
function prettyFormatExecution(execution) {
@@ -76,7 +86,6 @@ function prettyFormatExecution(execution) {
7686
outputString += outputTable(testTable);
7787
return outputString;
7888
}
79-
exports.prettyFormatExecution = prettyFormatExecution;
8089
function outputTable(table) {
8190
return table.toString().replace(/[\r\n]+/, '\n ');
8291
}

lib/test/suite.test.js

+59-8
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ describe('GitHub Action tests', () => {
2727
expect((0, src_1.optionalArrayInput)(constants_1.ActionInputs.BrowserTypes)).toEqual(['chrome']);
2828
setGithubInput(constants_1.ActionInputs.BrowserTypes, 'chrome, firefox ');
2929
expect((0, src_1.optionalArrayInput)(constants_1.ActionInputs.BrowserTypes)).toEqual(['chrome', 'firefox']);
30-
setGithubInput(constants_1.ActionInputs.BrowserTypes, 'chrome\nfirefox\nsafari ');
31-
expect((0, src_1.optionalArrayInput)(constants_1.ActionInputs.BrowserTypes)).toEqual(['chrome', 'firefox', 'safari']);
30+
setGithubInput(constants_1.ActionInputs.BrowserTypes, 'chrome\nfirefox\nwebkit\nedge ');
31+
expect((0, src_1.optionalArrayInput)(constants_1.ActionInputs.BrowserTypes)).toEqual(['chrome', 'firefox', 'webkit', 'edge']);
3232
});
3333
it('parses boolean inputs', () => {
3434
setGithubInput(constants_1.ActionInputs.RebaselineImages, '');
@@ -99,8 +99,9 @@ describe('GitHub Action tests', () => {
9999
environment_id: 'env',
100100
application_id: 'app',
101101
plan_overrides: {
102-
browser_types: ['firefox', 'chrome', 'internet_explorer'],
103-
uri: 'uri',
102+
browser_types: ['firefox', 'chrome', 'edge'],
103+
web_url: 'fake-app-url',
104+
api_url: 'fake-api-url',
104105
},
105106
actions: { rebaseline_images: true, set_static_baseline: true },
106107
revision: 'abcs',
@@ -119,7 +120,7 @@ describe('GitHub Action tests', () => {
119120
},
120121
};
121122
const apiClient = new mablApiClient_1.MablApiClient('test');
122-
const requestBody = apiClient.buildRequestBody(['firefox', 'chrome', 'internet_explorer'], [], [], true, true, 0, {
123+
const requestBody = apiClient.buildRequestBody(['firefox', 'chrome', 'edge'], [], [], true, true, 0, {
123124
repository_branch_name: 'master',
124125
repository_commit_username: 'gcooney',
125126
repository_action: 'mabl-tests',
@@ -131,15 +132,15 @@ describe('GitHub Action tests', () => {
131132
repository_pull_request_title: 'good pr',
132133
repository_pull_request_merged_at: '2019',
133134
repository_pull_request_created_at: '2019',
134-
}, 'app', 'env', 'uri', 'abcs');
135+
}, 'app', 'env', 'fake-app-url', 'fake-api-url', 'abcs');
135136
expect(expected).toStrictEqual(requestBody);
136137
});
137138
it('builds the request correctly with some options', () => {
138139
const expected = {
139140
application_id: 'app',
140141
plan_labels: ['alpha', 'beta'],
141142
plan_overrides: {
142-
uri: 'uri',
143+
web_url: 'fake-app-url',
143144
browser_types: ['chrome', 'firefox'],
144145
http_headers: [{
145146
name: 'Header-Uno',
@@ -181,7 +182,57 @@ describe('GitHub Action tests', () => {
181182
repository_pull_request_title: 'good pr',
182183
repository_pull_request_merged_at: '2019',
183184
repository_pull_request_created_at: '2019',
184-
}, 'app', '', 'uri', 'abcs');
185+
}, 'app', '', 'fake-app-url', undefined, 'abcs');
186+
expect(expected).toStrictEqual(requestBody);
187+
});
188+
it('builds the request correctly with some options API test override', () => {
189+
const expected = {
190+
application_id: 'app',
191+
plan_labels: ['alpha', 'beta'],
192+
plan_overrides: {
193+
api_url: 'fake-api-url',
194+
browser_types: ['chrome', 'firefox'],
195+
http_headers: [{
196+
name: 'Header-Uno',
197+
value: 'value-uno',
198+
log_header_value: false,
199+
}, {
200+
name: 'Header-Dos',
201+
value: 'value-dos',
202+
log_header_value: false,
203+
}],
204+
http_headers_required: true
205+
},
206+
actions: {},
207+
revision: 'abcs',
208+
properties: {
209+
repository_branch_name: 'master',
210+
repository_commit_username: 'gcooney',
211+
repository_action: 'mabl-tests',
212+
repository_name: 'github-mabl-actions',
213+
repository_url: 'git@github.com:mablhq/github-mabl-actions.git',
214+
triggering_event_name: 'push',
215+
repository_pull_request_url: 'https://github.com/mablhq/repo/pr/1',
216+
repository_pull_request_number: 5,
217+
repository_pull_request_title: 'good pr',
218+
repository_pull_request_merged_at: '2019',
219+
repository_pull_request_created_at: '2019',
220+
},
221+
};
222+
const apiClient = new mablApiClient_1.MablApiClient('test');
223+
const requestBody = apiClient.buildRequestBody(['chrome', 'firefox'], ['alpha', 'beta'], ['Header-Uno:value-uno', 'Header-Dos:value-dos'], false, false, 0, {
224+
repository_branch_name: 'master',
225+
repository_commit_username: 'gcooney',
226+
repository_action: 'mabl-tests',
227+
repository_name: 'github-mabl-actions',
228+
repository_url: 'git@github.com:mablhq/github-mabl-actions.git',
229+
triggering_event_name: 'push',
230+
repository_pull_request_url: 'https://github.com/mablhq/repo/pr/1',
231+
repository_pull_request_number: 5,
232+
repository_pull_request_title: 'good pr',
233+
repository_pull_request_merged_at: '2019',
234+
repository_pull_request_created_at: '2019',
235+
}, 'app', '', undefined, 'fake-api-url', 'abcs');
185236
expect(expected).toStrictEqual(requestBody);
186237
});
187238
});

0 commit comments

Comments
 (0)