Skip to content

Commit

Permalink
chore: Add an action to test
Browse files Browse the repository at this point in the history
  • Loading branch information
riosje committed May 23, 2024
1 parent ef463e9 commit ddb008a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
12 changes: 4 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123523,17 +123523,13 @@ var core = __nccwpck_require__(2186);
// EXTERNAL MODULE: ./node_modules/@aws-sdk/client-ec2/dist-cjs/index.js
var dist_cjs = __nccwpck_require__(3802);
;// CONCATENATED MODULE: ./src/lib/utils.js
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}

function consoleTable(data){
data = data.reduce((instance, {InstanceId, ...data}) => { instance[InstanceId] = data; return instance}, {})
console.table(data)
}

;// CONCATENATED MODULE: external "timers/promises"
const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("timers/promises");
;// CONCATENATED MODULE: ./src/lib/ec2Handler.js


Expand All @@ -123552,7 +123548,7 @@ try {
// TODO -Implement a loop to check the status of the instances until they are in the desired state
// Suggest to not use describeInstanceStatus apisince it requires permission too open.
// Wait for 5 seconds and send the request again to retrieve the status of the instances
await sleep(5000);
await (0,promises_namespaceObject.setTimeout)(5000);
response = await client.send(command);
consoleTable(response.StartingInstances)
return response;
Expand All @@ -123570,7 +123566,7 @@ async function stop(InstanceIds) {
// TODO -Implement a loop to check the status of the instances until they are in the desired state
// Suggest to not use describeInstanceStatus API since it requires permission to open.
// Wait for 5 seconds and send the request again to retrieve the status of the instances
await sleep(5000);
await (0,promises_namespaceObject.setTimeout)(5000);
response = await client.send(command);
consoleTable(response.StoppingInstances)
return response;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ec2Handler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EC2Client, StopInstancesCommand, StartInstancesCommand } from "@aws-sdk/client-ec2";
import core from "@actions/core";
import { sleep, consoleTable } from "./utils.js";

import { consoleTable } from "./utils.js";
import { setTimeout as sleep } from "timers/promises";

const client = new EC2Client();

Expand Down
6 changes: 0 additions & 6 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
export function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}

export function consoleTable(data){
data = data.reduce((instance, {InstanceId, ...data}) => { instance[InstanceId] = data; return instance}, {})
console.table(data)
Expand Down

0 comments on commit ddb008a

Please sign in to comment.