From b3efc63e7e47f084c95668d70ff997cfd63db27e Mon Sep 17 00:00:00 2001 From: Asa Gayle Date: Tue, 8 Feb 2022 11:08:15 -0500 Subject: [PATCH 1/7] Added version validation check --- src/run.test.ts | 4 ++++ src/run.ts | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/run.test.ts b/src/run.test.ts index d50930d7..0dcea785 100644 --- a/src/run.test.ts +++ b/src/run.test.ts @@ -60,6 +60,10 @@ describe("run.ts", () => { expect(os.arch).toBeCalled(); }); + test("getValidVersion() - return version with v prepended", () => { + expect(run.getValidVersion("3.8.0")).toBe("v3.8.0"); + }); + test("getHelmDownloadURL() - return the URL to download helm for Windows", () => { jest.spyOn(os, "type").mockReturnValue("Windows_NT"); diff --git a/src/run.ts b/src/run.ts index 1e58f01c..0d6760f2 100644 --- a/src/run.ts +++ b/src/run.ts @@ -17,6 +17,9 @@ const helmAllReleasesUrl = "https://api.github.com/repos/helm/helm/releases"; export async function run() { let version = core.getInput("version", { required: true }); + if(version[0] !== "v"){ + version = getValidVersion(version); + } if (version.toLocaleLowerCase() === "latest") { version = await getLatestHelmVersion(); } @@ -38,6 +41,11 @@ export async function run() { core.setOutput("helm-path", cachedPath); } +//Returns version with proper v before it +export function getValidVersion(version:string): string { + return "v" + version; +} + // Downloads the helm releases JSON and parses all the recent versions of helm from it. // Defaults to sending stable helm version if none are valid or if it fails From 969d177f06f84fad20bfa1f29abcb969a8d9efb6 Mon Sep 17 00:00:00 2001 From: Asa Gayle Date: Tue, 8 Feb 2022 11:10:03 -0500 Subject: [PATCH 2/7] Added check for latest --- src/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/run.ts b/src/run.ts index 0d6760f2..82a5b3b9 100644 --- a/src/run.ts +++ b/src/run.ts @@ -17,7 +17,7 @@ const helmAllReleasesUrl = "https://api.github.com/repos/helm/helm/releases"; export async function run() { let version = core.getInput("version", { required: true }); - if(version[0] !== "v"){ + if(version !== "latest" && version[0] !== "v"){ version = getValidVersion(version); } if (version.toLocaleLowerCase() === "latest") { From 1fcb0558891aefcb273e3b90b2eeb14ca58f3206 Mon Sep 17 00:00:00 2001 From: Asa Gayle Date: Tue, 8 Feb 2022 13:44:12 -0500 Subject: [PATCH 3/7] Changed Helm 3.5.0 test to also test lack of v in version --- .github/workflows/integration-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index f33fdeef..9014f61e 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -11,7 +11,7 @@ jobs: env: HELM_3_8_0: "v3.8.0" HELM_3_7_2: "v3.7.2" - HELM_3_5_0: "v3.5.0" + HELM_NO_V: "3.5.0" PR_BASE_REF: ${{ github.event.pull_request.base.ref }} steps: - name: Check out repository @@ -53,10 +53,10 @@ jobs: - name: Setup helm 3.5.0 uses: ./ with: - version: ${{ env.HELM_3_5_0 }} + version: ${{ env.HELM_NO_V }} - name: Validate 3.5.0 run: | - if [[ $(helm version) != *$HELM_3_5_0* ]]; then + if [[ $(helm version) != *$HELM_NO_V* ]]; then echo "HELM VERSION INCORRECT: HELM VERSION DOES NOT CONTAIN v3.5.0" echo "HELM VERSION OUTPUT: $(helm version)" exit 1 From 2428fbaef6c9fcda451d381c8dcb4eeede4947d3 Mon Sep 17 00:00:00 2001 From: Asa Gayle Date: Tue, 8 Feb 2022 13:49:35 -0500 Subject: [PATCH 4/7] Pushing integration tests --- .github/workflows/integration-tests-push.yml | 62 ++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/integration-tests-push.yml diff --git a/.github/workflows/integration-tests-push.yml b/.github/workflows/integration-tests-push.yml new file mode 100644 index 00000000..a40a78f4 --- /dev/null +++ b/.github/workflows/integration-tests-push.yml @@ -0,0 +1,62 @@ +name: "Trigger Integration tests" +on: + push: +jobs: + trigger-integration-tests: + name: Trigger Integration tests + runs-on: ubuntu-latest + env: + HELM_3_8_0: "v3.8.0" + HELM_3_7_2: "v3.7.2" + HELM_NO_V: "3.5.0" + PR_BASE_REF: ${{ github.event.pull_request.base.ref }} + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: npm install and build + id: action-npm-build + run: | + echo $PR_BASE_REF + if [[ $PR_BASE_REF != releases/* ]]; then + npm install + npm run build + fi + - name: Setup helm + uses: ./ + with: + version: ${{ env.HELM_3_8_0 }} + - name: Validate helm 3.8.0 + run: | + if [[ $(helm version) != *$HELM_3_8_0* ]]; then + echo "HELM VERSION INCORRECT: HELM VERSION DOES NOT CONTAIN v3.8.0" + echo "HELM VERSION OUTPUT: $(helm version)" + exit 1 + else + echo "HELM VERSION $HELM_3_8_0 INSTALLED SUCCESSFULLY" + fi + - name: Setup helm 3.7.2 + uses: ./ + with: + version: ${{ env.HELM_3_7_2 }} + - name: Validate 3.7.2 + run: | + if [[ $(helm version) != *$HELM_3_7_2* ]]; then + echo "HELM VERSION INCORRECT: HELM VERSION DOES NOT CONTAIN v3.7.2" + echo "HELM VERSION OUTPUT: $(helm version)" + exit 1 + else + echo "HELM VERSION $HELM_3_7_2 INSTALLED SUCCESSFULLY" + fi + - name: Setup helm 3.5.0 + uses: ./ + with: + version: ${{ env.HELM_NO_V }} + - name: Validate 3.5.0 + run: | + if [[ $(helm version) != *$HELM_NO_V* ]]; then + echo "HELM VERSION INCORRECT: HELM VERSION DOES NOT CONTAIN v3.5.0" + echo "HELM VERSION OUTPUT: $(helm version)" + exit 1 + else + echo "HELM VERSION $HELM_3_5_0 INSTALLED SUCCESSFULLY" + fi From 70aba947b463acb6772437ec4678108b040de1e2 Mon Sep 17 00:00:00 2001 From: Asa Gayle Date: Tue, 8 Feb 2022 13:56:27 -0500 Subject: [PATCH 5/7] Removed push integration test --- .github/workflows/integration-tests-push.yml | 62 -------------------- 1 file changed, 62 deletions(-) delete mode 100644 .github/workflows/integration-tests-push.yml diff --git a/.github/workflows/integration-tests-push.yml b/.github/workflows/integration-tests-push.yml deleted file mode 100644 index a40a78f4..00000000 --- a/.github/workflows/integration-tests-push.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: "Trigger Integration tests" -on: - push: -jobs: - trigger-integration-tests: - name: Trigger Integration tests - runs-on: ubuntu-latest - env: - HELM_3_8_0: "v3.8.0" - HELM_3_7_2: "v3.7.2" - HELM_NO_V: "3.5.0" - PR_BASE_REF: ${{ github.event.pull_request.base.ref }} - steps: - - name: Check out repository - uses: actions/checkout@v2 - - name: npm install and build - id: action-npm-build - run: | - echo $PR_BASE_REF - if [[ $PR_BASE_REF != releases/* ]]; then - npm install - npm run build - fi - - name: Setup helm - uses: ./ - with: - version: ${{ env.HELM_3_8_0 }} - - name: Validate helm 3.8.0 - run: | - if [[ $(helm version) != *$HELM_3_8_0* ]]; then - echo "HELM VERSION INCORRECT: HELM VERSION DOES NOT CONTAIN v3.8.0" - echo "HELM VERSION OUTPUT: $(helm version)" - exit 1 - else - echo "HELM VERSION $HELM_3_8_0 INSTALLED SUCCESSFULLY" - fi - - name: Setup helm 3.7.2 - uses: ./ - with: - version: ${{ env.HELM_3_7_2 }} - - name: Validate 3.7.2 - run: | - if [[ $(helm version) != *$HELM_3_7_2* ]]; then - echo "HELM VERSION INCORRECT: HELM VERSION DOES NOT CONTAIN v3.7.2" - echo "HELM VERSION OUTPUT: $(helm version)" - exit 1 - else - echo "HELM VERSION $HELM_3_7_2 INSTALLED SUCCESSFULLY" - fi - - name: Setup helm 3.5.0 - uses: ./ - with: - version: ${{ env.HELM_NO_V }} - - name: Validate 3.5.0 - run: | - if [[ $(helm version) != *$HELM_NO_V* ]]; then - echo "HELM VERSION INCORRECT: HELM VERSION DOES NOT CONTAIN v3.5.0" - echo "HELM VERSION OUTPUT: $(helm version)" - exit 1 - else - echo "HELM VERSION $HELM_3_5_0 INSTALLED SUCCESSFULLY" - fi From ed7a21d5891382339abd744e6816a6ece34a9fa2 Mon Sep 17 00:00:00 2001 From: Asa Gayle Date: Tue, 8 Feb 2022 13:59:33 -0500 Subject: [PATCH 6/7] Added more context to integration test --- .github/workflows/integration-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 9014f61e..a3b1b92f 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -50,11 +50,11 @@ jobs: else echo "HELM VERSION $HELM_3_7_2 INSTALLED SUCCESSFULLY" fi - - name: Setup helm 3.5.0 + - name: Setup helm 3.5.0 with no v in version uses: ./ with: version: ${{ env.HELM_NO_V }} - - name: Validate 3.5.0 + - name: Validate 3.5.0 without v in version run: | if [[ $(helm version) != *$HELM_NO_V* ]]; then echo "HELM VERSION INCORRECT: HELM VERSION DOES NOT CONTAIN v3.5.0" From 7deffe0415c6d703dc1cdbfc54998dc4f12e562f Mon Sep 17 00:00:00 2001 From: Asa Gayle Date: Tue, 8 Feb 2022 16:17:06 -0500 Subject: [PATCH 7/7] Addressing comment --- src/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/run.ts b/src/run.ts index 82a5b3b9..f59cb48e 100644 --- a/src/run.ts +++ b/src/run.ts @@ -42,7 +42,7 @@ export async function run() { } //Returns version with proper v before it -export function getValidVersion(version:string): string { +export function getValidVersion(version: string): string { return "v" + version; }