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:
Jonathan Camara 2022-05-09 12:19:28 -05:00 committed by GitHub
parent 8b4c280fc8
commit 8aaee7fab8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

13
dist/index.js vendored
View file

@ -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) {

View file

@ -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) {

View file

@ -94,6 +94,8 @@ describe('Setup Terraform', () => {
.fn()
.mockReturnValueOnce('file.zip');
io.mv = jest.fn();
tc.extractZip = jest
.fn()
.mockReturnValueOnce('file');