Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot]
407e071408 build(deps): bump json5 from 2.2.1 to 2.2.3
Bumps [json5](https://github.com/json5/json5) from 2.2.1 to 2.2.3.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v2.2.1...v2.2.3)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-09 02:31:57 +00:00
4 changed files with 47 additions and 75 deletions

View File

@@ -1,16 +1,12 @@
name: CI/CD
on:
# only on PRs into and merge to default branch
pull_request:
branches:
- master
push:
branches:
- master
jobs:
# runs on branch pushes only
ci_unit:
name: Run Unit Tests
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -30,6 +26,7 @@ jobs:
ci_integration:
name: Run Integration Tests
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -140,6 +137,7 @@ jobs:
ci_integration_envvar:
name: Run Integration Env Var Tests
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -161,6 +159,7 @@ jobs:
ci_integration_large_output:
name: Run Integration Large Output Tests
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -192,6 +191,7 @@ jobs:
ci_integration_retry_on_exit_code:
name: Run Integration retry_on_exit_code Tests
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -240,6 +240,7 @@ jobs:
ci_integration_continue_on_error:
name: Run Integration continue_on_error Tests
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -287,6 +288,7 @@ jobs:
ci_integration_retry_wait_seconds:
name: Run Integration Tests (retry_wait_seconds)
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -323,6 +325,7 @@ jobs:
ci_integration_on_retry_cmd:
name: Run Integration Tests (on_retry_command)
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -366,6 +369,7 @@ jobs:
# timeout tests take longer to run so run in parallel
ci_integration_timeout_seconds:
name: Run Integration Timeout Tests (seconds)
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -396,6 +400,7 @@ jobs:
ci_integration_timeout_retry_on_timeout:
name: Run Integration Timeout Tests (retry_on timeout)
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -427,6 +432,7 @@ jobs:
ci_integration_timeout_retry_on_error:
name: Run Integration Timeout Tests (retry_on error)
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -462,6 +468,7 @@ jobs:
ci_integration_timeout_minutes:
name: Run Integration Timeout Tests (minutes)
if: startsWith(github.ref, 'refs/heads')
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -492,6 +499,7 @@ jobs:
ci_windows:
name: Run Windows Tests
if: startsWith(github.ref, 'refs/heads')
runs-on: windows-latest
steps:
- name: Checkout
@@ -563,7 +571,7 @@ jobs:
steps:
- run: echo "If this is hit, all tests successfully passed"
# runs on merge to default only
# runs on push to master only
cd:
name: Publish Action
needs: [ci_all_tests_passed]
@@ -580,7 +588,7 @@ jobs:
run: npm ci
- name: Release
id: semantic
uses: cycjimmy/semantic-release-action@v4
uses: cycjimmy/semantic-release-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag

53
dist/index.js vendored
View File

@@ -891,21 +891,6 @@ exports.retryWait = retryWait;
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
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) {
@@ -956,26 +941,14 @@ var OS = process.platform;
var OUTPUT_TOTAL_ATTEMPTS_KEY = 'total_attempts';
var OUTPUT_EXIT_CODE_KEY = 'exit_code';
var OUTPUT_EXIT_ERROR_KEY = 'exit_error';
var exit;
var done;
var ErrorWithCode = /** @class */ (function (_super) {
__extends(ErrorWithCode, _super);
function ErrorWithCode(message, code) {
var _this = _super.call(this) || this;
_this.message = message;
_this.code = code;
_this.code = code;
_this.message = message;
return _this;
}
return ErrorWithCode;
}(Error));
function getExecutable(inputs) {
if (!inputs.shell) {
return OS === 'win32' ? 'powershell' : 'bash';
}
var executable;
var shellName = inputs.shell.split(' ')[0];
switch (shellName) {
switch (inputs.shell) {
case 'bash':
case 'python':
case 'pwsh': {
@@ -984,7 +957,7 @@ function getExecutable(inputs) {
}
case 'sh': {
if (OS === 'win32') {
throw new Error("Shell ".concat(shellName, " not allowed on OS ").concat(OS));
throw new Error("Shell ".concat(inputs.shell, " not allowed on OS ").concat(OS));
}
executable = inputs.shell;
break;
@@ -992,13 +965,13 @@ function getExecutable(inputs) {
case 'cmd':
case 'powershell': {
if (OS !== 'win32') {
throw new Error("Shell ".concat(shellName, " not allowed on OS ").concat(OS));
throw new Error("Shell ".concat(inputs.shell, " not allowed on OS ").concat(OS));
}
executable = shellName + '.exe' + inputs.shell.replace(shellName, '');
executable = inputs.shell + '.exe';
break;
}
default: {
throw new Error("Shell ".concat(shellName, " not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells"));
throw new Error("Shell ".concat(inputs.shell, " not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells"));
}
}
return executable;
@@ -1032,7 +1005,7 @@ function runRetryCmd(inputs) {
function runCmd(attempt, inputs) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var end_time, executable, exit, timeout, child;
var end_time, executable, timeout, child;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
@@ -1082,13 +1055,13 @@ function runCmd(attempt, inputs) {
return [4 /*yield*/, (0, util_1.retryWait)(milliseconds_1.default.seconds(inputs.retry_wait_seconds))];
case 5:
_c.sent();
throw new ErrorWithCode("Timeout of ".concat((0, inputs_1.getTimeout)(inputs), "ms hit"), exit);
throw new Error("Timeout of ".concat((0, inputs_1.getTimeout)(inputs), "ms hit"));
case 6:
if (!(exit > 0)) return [3 /*break*/, 8];
return [4 /*yield*/, (0, util_1.retryWait)(milliseconds_1.default.seconds(inputs.retry_wait_seconds))];
case 7:
_c.sent();
throw new ErrorWithCode("Child_process exited with error code ".concat(exit), exit);
throw new Error("Child_process exited with error code ".concat(exit));
case 8: return [2 /*return*/];
}
});
@@ -1096,7 +1069,7 @@ function runCmd(attempt, inputs) {
}
function runAction(inputs) {
return __awaiter(this, void 0, void 0, function () {
var attempt, error_2, exit;
var attempt, error_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, inputs_1.validateInputs)(inputs)];
@@ -1118,9 +1091,8 @@ function runAction(inputs) {
return [3 /*break*/, 13];
case 5:
error_2 = _a.sent();
exit = error_2 instanceof ErrorWithCode ? error_2.code : 1;
if (!(attempt === inputs.max_attempts)) return [3 /*break*/, 6];
throw new ErrorWithCode("Final attempt failed. ".concat(error_2.message), exit);
throw new Error("Final attempt failed. ".concat(error_2.message));
case 6:
if (!(!done && inputs.retry_on === 'error')) return [3 /*break*/, 7];
// error: timeout
@@ -1158,7 +1130,8 @@ runAction(inputs)
process.exit(0); // success
})
.catch(function (err) {
var exitCode = err instanceof ErrorWithCode ? err.code : 1;
// exact error code if available, otherwise just 1
var exitCode = exit > 0 ? exit : 1;
if (inputs.continue_on_error) {
(0, core_1.warning)(err.message);
}

12
package-lock.json generated
View File

@@ -7479,9 +7479,9 @@
"dev": true
},
"node_modules/json5": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"dev": true,
"bin": {
"json5": "lib/cli.js"
@@ -18643,9 +18643,9 @@
"dev": true
},
"json5": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"dev": true
},
"jsonfile": {

View File

@@ -11,25 +11,16 @@ const OUTPUT_TOTAL_ATTEMPTS_KEY = 'total_attempts';
const OUTPUT_EXIT_CODE_KEY = 'exit_code';
const OUTPUT_EXIT_ERROR_KEY = 'exit_error';
let exit: number;
let done: boolean;
class ErrorWithCode extends Error {
constructor(readonly message: string, readonly code: number) {
super();
this.code = code;
this.message = message;
}
}
function getExecutable(inputs: Inputs): string {
if (!inputs.shell) {
return OS === 'win32' ? 'powershell' : 'bash';
}
let executable: string;
const shellName = inputs.shell.split(' ')[0];
switch (shellName) {
switch (inputs.shell) {
case 'bash':
case 'python':
case 'pwsh': {
@@ -38,7 +29,7 @@ function getExecutable(inputs: Inputs): string {
}
case 'sh': {
if (OS === 'win32') {
throw new Error(`Shell ${shellName} not allowed on OS ${OS}`);
throw new Error(`Shell ${inputs.shell} not allowed on OS ${OS}`);
}
executable = inputs.shell;
break;
@@ -46,14 +37,14 @@ function getExecutable(inputs: Inputs): string {
case 'cmd':
case 'powershell': {
if (OS !== 'win32') {
throw new Error(`Shell ${shellName} not allowed on OS ${OS}`);
throw new Error(`Shell ${inputs.shell} not allowed on OS ${OS}`);
}
executable = shellName + '.exe' + inputs.shell.replace(shellName, '');
executable = inputs.shell + '.exe';
break;
}
default: {
throw new Error(
`Shell ${shellName} not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells`
`Shell ${inputs.shell} not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells`
);
}
}
@@ -78,7 +69,7 @@ async function runCmd(attempt: number, inputs: Inputs) {
const end_time = Date.now() + getTimeout(inputs);
const executable = getExecutable(inputs);
let exit = 0;
exit = 0;
done = false;
let timeout = false;
@@ -124,10 +115,10 @@ async function runCmd(attempt: number, inputs: Inputs) {
timeout = true;
kill(child.pid);
await retryWait(ms.seconds(inputs.retry_wait_seconds));
throw new ErrorWithCode(`Timeout of ${getTimeout(inputs)}ms hit`, exit);
throw new Error(`Timeout of ${getTimeout(inputs)}ms hit`);
} else if (exit > 0) {
await retryWait(ms.seconds(inputs.retry_wait_seconds));
throw new ErrorWithCode(`Child_process exited with error code ${exit}`, exit);
throw new Error(`Child_process exited with error code ${exit}`);
} else {
return;
}
@@ -145,9 +136,8 @@ async function runAction(inputs: Inputs) {
break;
// eslint-disable-next-line
} catch (error: any) {
const exit = error instanceof ErrorWithCode ? error.code : 1;
if (attempt === inputs.max_attempts) {
throw new ErrorWithCode(`Final attempt failed. ${error.message}`, exit);
throw new Error(`Final attempt failed. ${error.message}`);
} else if (!done && inputs.retry_on === 'error') {
// error: timeout
throw error;
@@ -176,7 +166,8 @@ runAction(inputs)
process.exit(0); // success
})
.catch((err) => {
const exitCode = err instanceof ErrorWithCode ? err.code : 1;
// exact error code if available, otherwise just 1
const exitCode = exit > 0 ? exit : 1;
if (inputs.continue_on_error) {
warning(err.message);