Skip to content

Commit

Permalink
fix: parse interval and backoff as integers
Browse files Browse the repository at this point in the history
  • Loading branch information
vililahtevanoja committed Jan 29, 2023
1 parent 2ffcfe8 commit 160321e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 8 additions & 2 deletions code-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,15 @@ function githubInputs() {
.filter((i) => i !== "");

const updateInterval =
core.getInput("update-interval", { required: false }) || 1000 * 30;
parseInt(
core.getInput("update-interval", { required: false }) || "30",
10
) * 1000;
const updateBackOff =
core.getInput("update-back-off", { required: false }) || 1000 * 15;
parseInt(
core.getInput("update-back-off", { required: false }) || "15",
10
) * 1000;

return {
projectName,
Expand Down
14 changes: 7 additions & 7 deletions test/code-build-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ describe("githubInputs", () => {
const sha = "1234abcd-12ab-34cd-56ef-1234567890ab";
const pullRequestSha = "181600acb3cfb803f4570d0018928be5d730c00d";

const updateInterval = "5";
const updateBackOff = "10";
const updateInterval = 5;
const updateBackOff = 10;

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

expect(test)
.to.haveOwnProperty("updateInterval")
.and.to.equal(updateInterval);
.and.to.equal(updateInterval * 1000);
expect(test)
.to.haveOwnProperty("updateBackOff")
.and.to.equal(updateBackOff);
.and.to.equal(updateBackOff * 1000);
});
});

Expand Down Expand Up @@ -358,7 +358,7 @@ describe("inputs2Parameters", () => {
});

describe("waitForBuildEndTime", () => {
const defaultConfig = { updateInterval: 30, updateBackOff: 15 };
const defaultConfig = { updateInterval: 10, updateBackOff: 10 }; // NOTE: milliseconds
it("basic usages", async () => {
let count = 0;
const buildID = "buildID";
Expand Down

0 comments on commit 160321e

Please sign in to comment.