Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version fix #66

Merged
merged 7 commits into from Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/integration-tests.yml
Expand Up @@ -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
Expand Down Expand Up @@ -50,13 +50,13 @@ 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_3_5_0 }}
- name: Validate 3.5.0
version: ${{ env.HELM_NO_V }}
- name: Validate 3.5.0 without v in version
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
Expand Down
4 changes: 4 additions & 0 deletions src/run.test.ts
Expand Up @@ -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");

Expand Down
8 changes: 8 additions & 0 deletions src/run.ts
Expand Up @@ -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 !== "latest" && version[0] !== "v"){
version = getValidVersion(version);
}
if (version.toLocaleLowerCase() === "latest") {
version = await getLatestHelmVersion();
}
Expand All @@ -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

Expand Down