Skip to content

Commit

Permalink
v1.11 release
Browse files Browse the repository at this point in the history
  • Loading branch information
twistedpair committed Apr 12, 2022
1 parent 24e98bd commit 0ba313a
Show file tree
Hide file tree
Showing 780 changed files with 105,114 additions and 64,618 deletions.
29 changes: 22 additions & 7 deletions lib/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down Expand Up @@ -118,7 +122,7 @@ function run() {
properties.repository_pull_request_merged_at = pullRequest.merged_at;
}
}
const baseApiUrl = (_a = process.env.APP_URL) !== null && _a !== void 0 ? _a : DEFAULT_MABL_APP_URL;
const baseAppUrl = (_a = process.env.MABL_APP_URL) !== null && _a !== void 0 ? _a : DEFAULT_MABL_APP_URL;
const revision = process.env.GITHUB_EVENT_NAME === 'pull_request'
? (_c = (_b = github.context.payload.pull_request) === null || _b === void 0 ? void 0 : _b.head) === null || _c === void 0 ? void 0 : _c.sha
: process.env.GITHUB_SHA;
Expand All @@ -142,12 +146,12 @@ function run() {
core.setFailed('Invalid configuration. Valid "application-id" or "environment-id" must be set. No tests started.');
return;
}
const outputLink = `${baseApiUrl}/workspaces/${appOrEnv.organization_id}/events/${deployment.id}`;
const outputLink = `${baseAppUrl}/workspaces/${appOrEnv.organization_id}/events/${deployment.id}`;
core.info(`Deployment triggered. View output at: ${outputLink}`);
core.startGroup('Await completion of tests');
let executionComplete = false;
while (!executionComplete) {
yield new Promise((resolve) => setTimeout(resolve, EXECUTION_POLL_INTERVAL_MILLIS));
yield sleep(EXECUTION_POLL_INTERVAL_MILLIS);
const executionResult = yield apiClient.getExecutionResults(deployment.id);
if (executionResult === null || executionResult === void 0 ? void 0 : executionResult.executions) {
const pendingExecutions = getExecutionsStillPending(executionResult);
Expand All @@ -164,7 +168,7 @@ function run() {
core.startGroup('Fetch execution results');
const finalExecutionResult = yield apiClient.getExecutionResults(deployment.id);
finalExecutionResult.executions.forEach((execution) => {
core.info(table_1.prettyFormatExecution(execution));
core.info((0, table_1.prettyFormatExecution)(execution));
});
core.setOutput(constants_1.ActionOutputs.PlansRun, '' + finalExecutionResult.plan_execution_metrics.total);
core.setOutput(constants_1.ActionOutputs.PlansPassed, '' + finalExecutionResult.plan_execution_metrics.passed);
Expand All @@ -189,6 +193,16 @@ function run() {
});
}
exports.run = run;
function sleep(milliseconds) {
return new Promise((resolve, reject) => {
try {
setTimeout(resolve, milliseconds);
}
catch (error) {
reject(error);
}
});
}
function getExecutionsStillPending(executionResult) {
return executionResult.executions.filter((execution) => {
return !(EXECUTION_COMPLETED_STATUSES.includes(execution.status) &&
Expand Down Expand Up @@ -217,8 +231,9 @@ function getRelatedPullRequest() {
return (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a[0];
}
catch (error) {
if (error.status !== 404) {
core.warning(error.message);
const maybeAxiosError = error;
if (maybeAxiosError.status !== 404) {
core.warning(maybeAxiosError.message);
}
}
return;
Expand Down
20 changes: 12 additions & 8 deletions lib/src/mablApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ exports.MablApiClient = void 0;
const async_retry_1 = __importDefault(require("async-retry"));
const axios_1 = __importDefault(require("axios"));
const constants_1 = require("./constants");
const GET_REQUEST_TIMEOUT_MILLIS = 600000;
const POST_REQUEST_TIMEOUT_MILLIS = 900000;
class MablApiClient {
constructor(apiKey) {
var _a;
this.baseUrl = (_a = process.env.APP_URL) !== null && _a !== void 0 ? _a : 'https://api.mabl.com';
this.baseUrl = (_a = process.env.MABL_REST_API_URL) !== null && _a !== void 0 ? _a : 'https://api.mabl.com';
const config = {
headers: {
'User-Agent': constants_1.USER_AGENT,
Expand All @@ -35,9 +37,11 @@ class MablApiClient {
}
makeGetRequest(url) {
return __awaiter(this, void 0, void 0, function* () {
return async_retry_1.default(() => __awaiter(this, void 0, void 0, function* () {
return (0, async_retry_1.default)(() => __awaiter(this, void 0, void 0, function* () {
var _a;
const response = yield this.httpClient.get(url);
const response = yield this.httpClient.get(url, {
timeout: GET_REQUEST_TIMEOUT_MILLIS,
});
if (((_a = response.status) !== null && _a !== void 0 ? _a : 400) >= 400) {
throw new Error(`[${response.status} - ${response.statusText}]`);
}
Expand All @@ -49,9 +53,9 @@ class MablApiClient {
}
makePostRequest(url, requestBody) {
return __awaiter(this, void 0, void 0, function* () {
return async_retry_1.default(() => __awaiter(this, void 0, void 0, function* () {
return (0, async_retry_1.default)(() => __awaiter(this, void 0, void 0, function* () {
var _a;
const response = yield this.httpClient.post(url, JSON.stringify(requestBody));
const response = yield this.httpClient.post(url, JSON.stringify(requestBody), { timeout: POST_REQUEST_TIMEOUT_MILLIS });
if (((_a = response.status) !== null && _a !== void 0 ? _a : 400) >= 400) {
throw new Error(`[${response.status} - ${response.statusText}]`);
}
Expand Down Expand Up @@ -102,7 +106,7 @@ class MablApiClient {
}
});
}
buildRequestBody(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, event_time, properties, applicationId, environmentId, uri, revision, mablBranch) {
buildRequestBody(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, uri, revision, mablBranch) {
const requestBody = {};
if (environmentId) {
requestBody.environment_id = environmentId;
Expand Down Expand Up @@ -138,8 +142,8 @@ class MablApiClient {
if (revision) {
requestBody.revision = revision;
}
if (event_time) {
requestBody.event_time = event_time;
if (eventTime) {
requestBody.event_time = eventTime;
}
if (properties) {
requestBody.properties = properties;
Expand Down
6 changes: 5 additions & 1 deletion lib/src/table.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down
28 changes: 14 additions & 14 deletions lib/test/suite.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,40 @@ describe('GitHub Action tests', () => {
it('handles invalid application/environment ids', () => __awaiter(void 0, void 0, void 0, function* () {
setGithubInput(constants_1.ActionInputs.ApplicationId, '');
setGithubInput(constants_1.ActionInputs.EnvironmentId, '');
yield src_1.run();
yield (0, src_1.run)();
assertExitCode(1);
}));
it('parses array inputs', () => {
setGithubInput(constants_1.ActionInputs.BrowserTypes, '');
expect(src_1.optionalArrayInput(constants_1.ActionInputs.BrowserTypes)).toEqual([]);
expect((0, src_1.optionalArrayInput)(constants_1.ActionInputs.BrowserTypes)).toEqual([]);
setGithubInput(constants_1.ActionInputs.BrowserTypes, 'chrome ');
expect(src_1.optionalArrayInput(constants_1.ActionInputs.BrowserTypes)).toEqual(['chrome']);
expect((0, src_1.optionalArrayInput)(constants_1.ActionInputs.BrowserTypes)).toEqual(['chrome']);
setGithubInput(constants_1.ActionInputs.BrowserTypes, 'chrome, firefox ');
expect(src_1.optionalArrayInput(constants_1.ActionInputs.BrowserTypes)).toEqual(['chrome', 'firefox']);
expect((0, src_1.optionalArrayInput)(constants_1.ActionInputs.BrowserTypes)).toEqual(['chrome', 'firefox']);
setGithubInput(constants_1.ActionInputs.BrowserTypes, 'chrome\nfirefox\nsafari ');
expect(src_1.optionalArrayInput(constants_1.ActionInputs.BrowserTypes)).toEqual(['chrome', 'firefox', 'safari']);
expect((0, src_1.optionalArrayInput)(constants_1.ActionInputs.BrowserTypes)).toEqual(['chrome', 'firefox', 'safari']);
});
it('parses boolean inputs', () => {
setGithubInput(constants_1.ActionInputs.RebaselineImages, '');
expect(src_1.booleanInput(constants_1.ActionInputs.RebaselineImages)).toEqual(false);
expect((0, src_1.booleanInput)(constants_1.ActionInputs.RebaselineImages)).toEqual(false);
setGithubInput(constants_1.ActionInputs.RebaselineImages, 'false ');
expect(src_1.booleanInput(constants_1.ActionInputs.RebaselineImages)).toEqual(false);
expect((0, src_1.booleanInput)(constants_1.ActionInputs.RebaselineImages)).toEqual(false);
setGithubInput(constants_1.ActionInputs.RebaselineImages, 'False ');
expect(src_1.booleanInput(constants_1.ActionInputs.RebaselineImages)).toEqual(false);
expect((0, src_1.booleanInput)(constants_1.ActionInputs.RebaselineImages)).toEqual(false);
setGithubInput(constants_1.ActionInputs.RebaselineImages, 'True ');
expect(src_1.booleanInput(constants_1.ActionInputs.RebaselineImages)).toEqual(true);
expect((0, src_1.booleanInput)(constants_1.ActionInputs.RebaselineImages)).toEqual(true);
setGithubInput(constants_1.ActionInputs.RebaselineImages, 'true ');
expect(src_1.booleanInput(constants_1.ActionInputs.RebaselineImages)).toEqual(true);
expect((0, src_1.booleanInput)(constants_1.ActionInputs.RebaselineImages)).toEqual(true);
setGithubInput(constants_1.ActionInputs.RebaselineImages, 'TRUE');
expect(src_1.booleanInput(constants_1.ActionInputs.RebaselineImages)).toEqual(true);
expect((0, src_1.booleanInput)(constants_1.ActionInputs.RebaselineImages)).toEqual(true);
});
it('parses optional string inputs', () => {
setGithubInput(constants_1.ActionInputs.ApplicationId, '');
expect(src_1.optionalInput(constants_1.ActionInputs.ApplicationId)).toBeUndefined();
expect((0, src_1.optionalInput)(constants_1.ActionInputs.ApplicationId)).toBeUndefined();
setGithubInput(constants_1.ActionInputs.ApplicationId, 'baz ');
expect(src_1.optionalInput(constants_1.ActionInputs.ApplicationId)).toEqual('baz');
expect((0, src_1.optionalInput)(constants_1.ActionInputs.ApplicationId)).toEqual('baz');
setGithubInput(constants_1.ActionInputs.ApplicationId, 'BAZ');
expect(src_1.optionalInput(constants_1.ActionInputs.ApplicationId)).toEqual('BAZ');
expect((0, src_1.optionalInput)(constants_1.ActionInputs.ApplicationId)).toEqual('BAZ');
});
it('builds the request correctly with all options', () => {
const expected = {
Expand Down
120 changes: 115 additions & 5 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0ba313a

Please sign in to comment.