mirror of
https://github.com/hashicorp/setup-terraform.git
synced 2025-12-15 16:12:35 +00:00
Fix terraform extract (#187)
On Windows runners, extracting the downloaded CLI zip file was failing because the file didn't have a .zip extension. This commit attempts to solve the problem by adding the extension to the downloaded file before extraction.
This commit is contained in:
parent
8b4c280fc8
commit
8aaee7fab8
3 changed files with 26 additions and 2 deletions
13
dist/index.js
vendored
13
dist/index.js
vendored
|
|
@ -38,8 +38,19 @@ async function downloadCLI (url) {
|
||||||
core.debug(`Downloading Terraform CLI from ${url}`);
|
core.debug(`Downloading Terraform CLI from ${url}`);
|
||||||
const pathToCLIZip = await tc.downloadTool(url);
|
const pathToCLIZip = await tc.downloadTool(url);
|
||||||
|
|
||||||
|
let pathToCLI = '';
|
||||||
|
|
||||||
core.debug('Extracting Terraform CLI zip file');
|
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}.`);
|
core.debug(`Terraform CLI path is ${pathToCLI}.`);
|
||||||
|
|
||||||
if (!pathToCLIZip || !pathToCLI) {
|
if (!pathToCLIZip || !pathToCLI) {
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,19 @@ async function downloadCLI (url) {
|
||||||
core.debug(`Downloading Terraform CLI from ${url}`);
|
core.debug(`Downloading Terraform CLI from ${url}`);
|
||||||
const pathToCLIZip = await tc.downloadTool(url);
|
const pathToCLIZip = await tc.downloadTool(url);
|
||||||
|
|
||||||
|
let pathToCLI = '';
|
||||||
|
|
||||||
core.debug('Extracting Terraform CLI zip file');
|
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}.`);
|
core.debug(`Terraform CLI path is ${pathToCLI}.`);
|
||||||
|
|
||||||
if (!pathToCLIZip || !pathToCLI) {
|
if (!pathToCLIZip || !pathToCLI) {
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,8 @@ describe('Setup Terraform', () => {
|
||||||
.fn()
|
.fn()
|
||||||
.mockReturnValueOnce('file.zip');
|
.mockReturnValueOnce('file.zip');
|
||||||
|
|
||||||
|
io.mv = jest.fn();
|
||||||
|
|
||||||
tc.extractZip = jest
|
tc.extractZip = jest
|
||||||
.fn()
|
.fn()
|
||||||
.mockReturnValueOnce('file');
|
.mockReturnValueOnce('file');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue