Skip to content

Commit

Permalink
1.13.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
twistedpair committed Oct 21, 2022
1 parent abf9fb8 commit 8424530
Show file tree
Hide file tree
Showing 285 changed files with 52,048 additions and 9,294 deletions.
269 changes: 127 additions & 142 deletions lib/src/index.js

Large diffs are not rendered by default.

122 changes: 49 additions & 73 deletions lib/src/mablApiClient.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Expand All @@ -20,8 +11,7 @@ const GET_REQUEST_TIMEOUT_MILLIS = 600000;
const POST_REQUEST_TIMEOUT_MILLIS = 900000;
class MablApiClient {
constructor(apiKey) {
var _a;
this.baseUrl = (_a = process.env.MABL_REST_API_URL) !== null && _a !== void 0 ? _a : 'https://api.mabl.com';
this.baseUrl = process.env.MABL_REST_API_URL ?? 'https://api.mabl.com';
const config = {
headers: {
'User-Agent': constants_1.USER_AGENT,
Expand All @@ -47,76 +37,62 @@ class MablApiClient {
throw new Error(`[${response.status} - ${response.statusText}]`);
}
}
makeGetRequest(url) {
return __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, {
timeout: GET_REQUEST_TIMEOUT_MILLIS,
});
if (((_a = response.status) !== null && _a !== void 0 ? _a : 400) >= 400) {
MablApiClient.throwHumanizedError(response);
}
return response.data;
}), {
retries: 3,
});
});
}
makePostRequest(url, requestBody) {
return __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), { timeout: POST_REQUEST_TIMEOUT_MILLIS });
if (((_a = response.status) !== null && _a !== void 0 ? _a : 400) >= 400) {
throw new Error(`[${response.status} - ${response.statusText}]`);
}
return response.data;
}), {
retries: 3,
async makeGetRequest(url) {
return (0, async_retry_1.default)(async () => {
const response = await this.httpClient.get(url, {
timeout: GET_REQUEST_TIMEOUT_MILLIS,
});
});
}
getApplication(id) {
return __awaiter(this, void 0, void 0, function* () {
try {
return yield this.makeGetRequest(`${this.baseUrl}/applications/${id}`);
}
catch (error) {
throw new Error(`failed to get mabl application (${id}) from the API ${error}`);
if ((response.status ?? 400) >= 400) {
MablApiClient.throwHumanizedError(response);
}
return response.data;
}, {
retries: 3,
});
}
getEnvironment(id) {
return __awaiter(this, void 0, void 0, function* () {
try {
return yield this.makeGetRequest(`${this.baseUrl}/environments/${id}`);
}
catch (error) {
throw new Error(`failed to get mabl environment (${id}) from the API ${error}`);
async makePostRequest(url, requestBody) {
return (0, async_retry_1.default)(async () => {
const response = await this.httpClient.post(url, JSON.stringify(requestBody), { timeout: POST_REQUEST_TIMEOUT_MILLIS });
if ((response.status ?? 400) >= 400) {
throw new Error(`[${response.status} - ${response.statusText}]`);
}
return response.data;
}, {
retries: 3,
});
}
getExecutionResults(eventId) {
return __awaiter(this, void 0, void 0, function* () {
try {
return yield this.makeGetRequest(`${this.baseUrl}/execution/result/event/${eventId}`);
}
catch (error) {
throw new Error(`failed to get mabl execution results for event ${eventId} from the API ${error}`);
}
});
async getApplication(id) {
try {
return await this.makeGetRequest(`${this.baseUrl}/applications/${id}`);
}
catch (error) {
throw new Error(`failed to get mabl application (${id}) from the API ${error}`);
}
}
postDeploymentEvent(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, uri, revision, mablBranch) {
return __awaiter(this, void 0, void 0, function* () {
try {
const requestBody = this.buildRequestBody(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, uri, revision, mablBranch);
return yield this.makePostRequest(`${this.baseUrl}/events/deployment/`, requestBody);
}
catch (e) {
throw new Error(`failed to create deployment through mabl API ${e}`);
}
});
async getEnvironment(id) {
try {
return await this.makeGetRequest(`${this.baseUrl}/environments/${id}`);
}
catch (error) {
throw new Error(`failed to get mabl environment (${id}) from the API ${error}`);
}
}
async getExecutionResults(eventId) {
try {
return await this.makeGetRequest(`${this.baseUrl}/execution/result/event/${eventId}`);
}
catch (error) {
throw new Error(`failed to get mabl execution results for event ${eventId} from the API ${error}`);
}
}
async postDeploymentEvent(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, uri, revision, mablBranch) {
try {
const requestBody = this.buildRequestBody(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, uri, revision, mablBranch);
return await this.makePostRequest(`${this.baseUrl}/events/deployment/`, requestBody);
}
catch (e) {
throw new Error(`failed to create deployment through mabl API ${e}`);
}
}
buildRequestBody(browserTypes, planLabels, httpHeaders, rebaselineImages, setStaticBaseline, eventTime, properties, applicationId, environmentId, uri, revision, mablBranch) {
const requestBody = {};
Expand Down
15 changes: 3 additions & 12 deletions lib/test/suite.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const mablApiClient_1 = require("../src/mablApiClient");
const src_1 = require("../src");
Expand All @@ -19,12 +10,12 @@ describe('GitHub Action tests', () => {
function assertExitCode(expected) {
expect(process.exitCode).toEqual(expected);
}
it('handles invalid application/environment ids', () => __awaiter(void 0, void 0, void 0, function* () {
it('handles invalid application/environment ids', async () => {
setGithubInput(constants_1.ActionInputs.ApplicationId, '');
setGithubInput(constants_1.ActionInputs.EnvironmentId, '');
yield (0, src_1.run)();
await (0, src_1.run)();
assertExitCode(1);
}));
});
it('parses array inputs', () => {
setGithubInput(constants_1.ActionInputs.BrowserTypes, '');
expect((0, src_1.optionalArrayInput)(constants_1.ActionInputs.BrowserTypes)).toEqual([]);
Expand Down
25 changes: 24 additions & 1 deletion node_modules/@actions/core/README.md

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

12 changes: 12 additions & 0 deletions node_modules/@actions/core/lib/core.d.ts

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

44 changes: 34 additions & 10 deletions node_modules/@actions/core/lib/core.js

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

Loading

0 comments on commit 8424530

Please sign in to comment.