Skip to content

Commit

Permalink
exit the process to avoid awaiting 60 seconds timeout introduced with…
Browse files Browse the repository at this point in the history
… node20
  • Loading branch information
masci committed Jan 31, 2024
1 parent 1549e52 commit 98184cf
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 54 deletions.
93 changes: 62 additions & 31 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,45 @@ function sendLogs(logApiURL, apiKey, logs) {
exports.sendLogs = sendLogs;


/***/ }),

/***/ 3109:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

"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]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186));
const run_1 = __nccwpck_require__(7884);
run_1.run()
.catch(err => {
core.setFailed(err.message);
process.exit(1);
})
.then(() => {
process.exit(0);
});


/***/ }),

/***/ 7884:
Expand Down Expand Up @@ -179,27 +218,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.run = void 0;
const core = __importStar(__nccwpck_require__(2186));
const dd = __importStar(__nccwpck_require__(1401));
const yaml = __importStar(__nccwpck_require__(1917));
const dd = __importStar(__nccwpck_require__(1401));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const apiKey = core.getInput('api-key', { required: true });
const apiURL = core.getInput('api-url') || 'https://api.datadoghq.com';
const metrics = yaml.safeLoad(core.getInput('metrics')) || [];
yield dd.sendMetrics(apiURL, apiKey, metrics);
const events = yaml.safeLoad(core.getInput('events')) || [];
yield dd.sendEvents(apiURL, apiKey, events);
const serviceChecks = yaml.safeLoad(core.getInput('service-checks')) ||
[];
yield dd.sendServiceChecks(apiURL, apiKey, serviceChecks);
const logApiURL = core.getInput('log-api-url') || 'https://http-intake.logs.datadoghq.com';
const logs = yaml.safeLoad(core.getInput('logs')) || [];
yield dd.sendLogs(logApiURL, apiKey, logs);
}
catch (error) {
core.setFailed(`Run failed: ${error.message}`);
}
// try {
const apiKey = core.getInput('api-key', { required: true });
const apiURL = core.getInput('api-url') || 'https://api.datadoghq.com';
const metrics = yaml.safeLoad(core.getInput('metrics')) || [];
yield dd.sendMetrics(apiURL, apiKey, metrics);
const events = yaml.safeLoad(core.getInput('events')) || [];
yield dd.sendEvents(apiURL, apiKey, events);
const serviceChecks = yaml.safeLoad(core.getInput('service-checks')) || [];
yield dd.sendServiceChecks(apiURL, apiKey, serviceChecks);
const logApiURL = core.getInput('log-api-url') || 'https://http-intake.logs.datadoghq.com';
const logs = yaml.safeLoad(core.getInput('logs')) || [];
yield dd.sendLogs(logApiURL, apiKey, logs);
// } catch (error) {
// core.setFailed(`Run failed: ${error.message}`)
// }
});
}
exports.run = run;
Expand Down Expand Up @@ -7800,18 +7837,12 @@ module.exports = require("util");
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
(() => {
"use strict";
var exports = __webpack_exports__;

Object.defineProperty(exports, "__esModule", ({ value: true }));
const run_1 = __nccwpck_require__(7884);
run_1.run();

})();

module.exports = __webpack_exports__;
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __nccwpck_require__(3109);
/******/ module.exports = __webpack_exports__;
/******/
/******/ })()
;
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as core from '@actions/core'
import {run} from './run'

run()
.catch(err => {
core.setFailed(err.message)
process.exit(1)
})
.then(() => {
Expand Down
40 changes: 17 additions & 23 deletions src/run.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
import * as core from '@actions/core'
import * as dd from './datadog'
import * as yaml from 'js-yaml'
import * as dd from './datadog'

export async function run(): Promise<void> {
try {
const apiKey: string = core.getInput('api-key', {required: true})
const apiURL: string =
core.getInput('api-url') || 'https://api.datadoghq.com'
const apiKey: string = core.getInput('api-key', {required: true})
const apiURL: string = core.getInput('api-url') || 'https://api.datadoghq.com'

const metrics: dd.Metric[] =
(yaml.safeLoad(core.getInput('metrics')) as dd.Metric[]) || []
await dd.sendMetrics(apiURL, apiKey, metrics)
const metrics: dd.Metric[] =
(yaml.safeLoad(core.getInput('metrics')) as dd.Metric[]) || []
await dd.sendMetrics(apiURL, apiKey, metrics)

const events: dd.Event[] =
(yaml.safeLoad(core.getInput('events')) as dd.Event[]) || []
await dd.sendEvents(apiURL, apiKey, events)
const events: dd.Event[] =
(yaml.safeLoad(core.getInput('events')) as dd.Event[]) || []
await dd.sendEvents(apiURL, apiKey, events)

const serviceChecks: dd.ServiceCheck[] =
(yaml.safeLoad(core.getInput('service-checks')) as dd.ServiceCheck[]) ||
[]
await dd.sendServiceChecks(apiURL, apiKey, serviceChecks)
const serviceChecks: dd.ServiceCheck[] =
(yaml.safeLoad(core.getInput('service-checks')) as dd.ServiceCheck[]) || []
await dd.sendServiceChecks(apiURL, apiKey, serviceChecks)

const logApiURL: string =
core.getInput('log-api-url') || 'https://http-intake.logs.datadoghq.com'
const logs: dd.Log[] =
(yaml.safeLoad(core.getInput('logs')) as dd.Log[]) || []
await dd.sendLogs(logApiURL, apiKey, logs)
} catch (error) {
core.setFailed(`Run failed: ${error.message}`)
}
const logApiURL: string =
core.getInput('log-api-url') || 'https://http-intake.logs.datadoghq.com'
const logs: dd.Log[] =
(yaml.safeLoad(core.getInput('logs')) as dd.Log[]) || []
await dd.sendLogs(logApiURL, apiKey, logs)
}

0 comments on commit 98184cf

Please sign in to comment.