Skip to content

Commit 160321e

Browse files
fix: parse interval and backoff as integers
1 parent 2ffcfe8 commit 160321e

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

code-build.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,15 @@ function githubInputs() {
198198
.filter((i) => i !== "");
199199

200200
const updateInterval =
201-
core.getInput("update-interval", { required: false }) || 1000 * 30;
201+
parseInt(
202+
core.getInput("update-interval", { required: false }) || "30",
203+
10
204+
) * 1000;
202205
const updateBackOff =
203-
core.getInput("update-back-off", { required: false }) || 1000 * 15;
206+
parseInt(
207+
core.getInput("update-back-off", { required: false }) || "15",
208+
10
209+
) * 1000;
204210

205211
return {
206212
projectName,

test/code-build-test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ describe("githubInputs", () => {
5454
const sha = "1234abcd-12ab-34cd-56ef-1234567890ab";
5555
const pullRequestSha = "181600acb3cfb803f4570d0018928be5d730c00d";
5656

57-
const updateInterval = "5";
58-
const updateBackOff = "10";
57+
const updateInterval = 5;
58+
const updateBackOff = 10;
5959

6060
it("build basic parameters for codeBuild.startBuild", () => {
6161
// This is how GITHUB injects its input values.
@@ -157,8 +157,8 @@ describe("githubInputs", () => {
157157
});
158158
it("can handle configuring update call-rate", () => {
159159
process.env[`INPUT_PROJECT-NAME`] = projectName;
160-
process.env[`INPUT_UPDATE-INTERVAL`] = updateInterval;
161-
process.env[`INPUT_UPDATE-BACK-OFF`] = updateBackOff;
160+
process.env[`INPUT_UPDATE-INTERVAL`] = `${updateInterval}`;
161+
process.env[`INPUT_UPDATE-BACK-OFF`] = `${updateBackOff}`;
162162
process.env[`GITHUB_REPOSITORY`] = repoInfo;
163163
process.env[`GITHUB_SHA`] = sha;
164164
const { context } = require("@actions/github");
@@ -168,10 +168,10 @@ describe("githubInputs", () => {
168168

169169
expect(test)
170170
.to.haveOwnProperty("updateInterval")
171-
.and.to.equal(updateInterval);
171+
.and.to.equal(updateInterval * 1000);
172172
expect(test)
173173
.to.haveOwnProperty("updateBackOff")
174-
.and.to.equal(updateBackOff);
174+
.and.to.equal(updateBackOff * 1000);
175175
});
176176
});
177177

@@ -358,7 +358,7 @@ describe("inputs2Parameters", () => {
358358
});
359359

360360
describe("waitForBuildEndTime", () => {
361-
const defaultConfig = { updateInterval: 30, updateBackOff: 15 };
361+
const defaultConfig = { updateInterval: 10, updateBackOff: 10 }; // NOTE: milliseconds
362362
it("basic usages", async () => {
363363
let count = 0;
364364
const buildID = "buildID";

0 commit comments

Comments
 (0)