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

setup-helm refactor #55

Merged
merged 30 commits into from Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
244104d
Removed empty try catch
aamgayle Dec 6, 2021
102789f
Initial commit
aamgayle Jan 13, 2022
91434c9
Compiled to js
aamgayle Jan 13, 2022
db9832f
Merge pull request #1 from taakleton/asgayle/setup-helm-refactor
aamgayle Jan 13, 2022
db3e6df
Escape slash for nodejs
aamgayle Jan 13, 2022
7b95bcc
Updating getStableHelmVersion test
aamgayle Jan 13, 2022
e468b13
Removing old versions of run
aamgayle Jan 14, 2022
b34dae9
Added comment on getLatestHelmVersion and variable for helm release u…
aamgayle Jan 14, 2022
363e425
Pushing recent changes before computer reset
aamgayle Jan 21, 2022
f1588f7
Latest getLatestHelmVersion iteration
aamgayle Jan 25, 2022
6fb2206
Removed test
aamgayle Jan 25, 2022
822c0c2
Testing async test
aamgayle Jan 25, 2022
45f20ed
getLatestHelmVersion refactor
aamgayle Jan 25, 2022
f89e61b
fixed method to access helm releses JSON
aamgayle Jan 25, 2022
700a7c0
Edited comment on isValidVersion
aamgayle Jan 25, 2022
7184130
Removed old integration tests
aamgayle Jan 26, 2022
73481c6
Small temp test
aamgayle Jan 26, 2022
4c466f0
Removed IntegrationTests path
aamgayle Jan 26, 2022
03759bd
Updated package-lock.json and removed unused dep
aamgayle Jan 26, 2022
49a9aad
Integration testing
aamgayle Jan 26, 2022
49e3211
Fixed if statement in run command
aamgayle Jan 26, 2022
21069d8
Added exit
aamgayle Jan 26, 2022
1d63310
Double brackets for new test
aamgayle Jan 26, 2022
36eb99c
Added version confirmation output and different check for version
aamgayle Jan 26, 2022
64dc736
Helm 3.7.2 test
aamgayle Jan 26, 2022
eb06923
added env to workflow paths
aamgayle Jan 26, 2022
0b18ab3
adjusted env in workflow paths
aamgayle Jan 26, 2022
d2f4a46
3.5.0 tests
aamgayle Jan 26, 2022
a277a45
Requested changes
aamgayle Jan 26, 2022
499b0f3
Fixed downloadHelm test
aamgayle Jan 26, 2022
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
33 changes: 0 additions & 33 deletions .github/workflows/TriggerIntegrationTests.sh

This file was deleted.

56 changes: 51 additions & 5 deletions .github/workflows/integration-tests.yml
Expand Up @@ -8,12 +8,58 @@ 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_3_5_0: "v3.5.0"
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
path: IntegrationTests

- name: Trigger Test run
- name: npm install and build
id: action-npm-build
run: |
bash ./IntegrationTests/.github/workflows/TriggerIntegrationTests.sh ${{ secrets.L2_REPO_TOKEN }} ${{ github.event.pull_request.head.sha }} ${{ github.repository }} ${{ github.event.pull_request.number }} ${{ github.event.pull_request.head.ref }} ${{ github.event.pull_request.base.ref }} ${{ secrets.L2_REPO_USER }}
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_3_5_0 }}
- name: Validate 3.5.0
run: |
if [[ $(helm version) != *$HELM_3_5_0* ]]; 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
45 changes: 12 additions & 33 deletions __tests__/run.test.ts
Expand Up @@ -22,55 +22,34 @@ describe('run.ts', () => {

test('getHelmDownloadURL() - return the URL to download helm for Linux', () => {
jest.spyOn(os, 'type').mockReturnValue('Linux');
const kubectlLinuxUrl = 'https://get.helm.sh/helm-v3.2.1-linux-amd64.zip'
const kubectlLinuxUrl = 'https://get.helm.sh/helm-v3.8.0-linux-amd64.zip'

expect(run.getHelmDownloadURL('v3.2.1')).toBe(kubectlLinuxUrl);
expect(run.getHelmDownloadURL('v3.8.0')).toBe(kubectlLinuxUrl);
expect(os.type).toBeCalled();
});

test('getHelmDownloadURL() - return the URL to download helm for Darwin', () => {
jest.spyOn(os, 'type').mockReturnValue('Darwin');
const kubectlDarwinUrl = 'https://get.helm.sh/helm-v3.2.1-darwin-amd64.zip'
const kubectlDarwinUrl = 'https://get.helm.sh/helm-v3.8.0-darwin-amd64.zip'

expect(run.getHelmDownloadURL('v3.2.1')).toBe(kubectlDarwinUrl);
expect(run.getHelmDownloadURL('v3.8.0')).toBe(kubectlDarwinUrl);
expect(os.type).toBeCalled();
});

test('getHelmDownloadURL() - return the URL to download helm for Windows', () => {
jest.spyOn(os, 'type').mockReturnValue('Windows_NT');

const kubectlWindowsUrl = 'https://get.helm.sh/helm-v3.2.1-windows-amd64.zip'
expect(run.getHelmDownloadURL('v3.2.1')).toBe(kubectlWindowsUrl);
const kubectlWindowsUrl = 'https://get.helm.sh/helm-v3.8.0-windows-amd64.zip'
expect(run.getHelmDownloadURL('v3.8.0')).toBe(kubectlWindowsUrl);
expect(os.type).toBeCalled();
});

test('getStableHelmVersion() - download stable version file, read version and return it', async () => {
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool');
const response = JSON.stringify(
[
{
'tag_name': 'v4.0.0'
}, {
'tag_name': 'v3.0.0'
}, {
'tag_name': 'v2.0.0'
}
]
);
jest.spyOn(fs, 'readFileSync').mockReturnValue(response);

expect(await run.getStableHelmVersion()).toBe('v4.0.0');
expect(toolCache.downloadTool).toBeCalled();
expect(fs.readFileSync).toBeCalledWith('pathToTool', 'utf8');
});

test('getStableHelmVersion() - return default version if error occurs while getting latest version', async () => {
jest.spyOn(toolCache, 'downloadTool').mockRejectedValue('Unable to download');
jest.spyOn(core, 'warning').mockImplementation();

expect(await run.getStableHelmVersion()).toBe('v3.2.1');
expect(toolCache.downloadTool).toBeCalled();
expect(core.warning).toBeCalledWith("Cannot get the latest Helm info from https://api.github.com/repos/helm/helm/releases. Error Unable to download. Using default Helm version v3.2.1.");
test('getLatestHelmVersion() - return the latest version of HELM', async () => {
try{
expect(await run.getLatestHelmVersion()).toBe("v3.8.0");
} catch (e){
return e;
}
});

test('walkSync() - return path to the all files matching fileToFind in dir', () => {
Expand Down