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

Fix terraform extract #187

Merged
merged 11 commits into from May 9, 2022
13 changes: 12 additions & 1 deletion dist/index.js
Expand Up @@ -38,8 +38,19 @@ async function downloadCLI (url) {
core.debug(`Downloading Terraform CLI from ${url}`);
const pathToCLIZip = await tc.downloadTool(url);

let pathToCLI = '';

core.debug('Extracting Terraform CLI zip file');
const pathToCLI = await tc.extractZip(pathToCLIZip);
if (os.platform().startsWith('win')) {
core.debug(`Terraform CLI Download Path is ${pathToCLIZip}`);
const fixedPathToCLIZip = `${pathToCLIZip}.zip`;
io.mv(pathToCLIZip, fixedPathToCLIZip);
core.debug(`Moved download to ${fixedPathToCLIZip}`);
pathToCLI = await tc.extractZip(fixedPathToCLIZip);
} else {
pathToCLI = await tc.extractZip(pathToCLIZip);
}

core.debug(`Terraform CLI path is ${pathToCLI}.`);

if (!pathToCLIZip || !pathToCLI) {
Expand Down
13 changes: 12 additions & 1 deletion lib/setup-terraform.js
Expand Up @@ -32,8 +32,19 @@ async function downloadCLI (url) {
core.debug(`Downloading Terraform CLI from ${url}`);
const pathToCLIZip = await tc.downloadTool(url);

let pathToCLI = '';

core.debug('Extracting Terraform CLI zip file');
const pathToCLI = await tc.extractZip(pathToCLIZip);
if (os.platform().startsWith('win')) {
core.debug(`Terraform CLI Download Path is ${pathToCLIZip}`);
const fixedPathToCLIZip = `${pathToCLIZip}.zip`;
io.mv(pathToCLIZip, fixedPathToCLIZip);
core.debug(`Moved download to ${fixedPathToCLIZip}`);
pathToCLI = await tc.extractZip(fixedPathToCLIZip);
} else {
pathToCLI = await tc.extractZip(pathToCLIZip);
}

core.debug(`Terraform CLI path is ${pathToCLI}.`);

if (!pathToCLIZip || !pathToCLI) {
Expand Down
2 changes: 2 additions & 0 deletions test/setup-terraform.test.js
Expand Up @@ -94,6 +94,8 @@ describe('Setup Terraform', () => {
.fn()
.mockReturnValueOnce('file.zip');

io.mv = jest.fn();

tc.extractZip = jest
.fn()
.mockReturnValueOnce('file');
Expand Down