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

Use toolcache properly to download terraform #202

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

shahariaazam
Copy link

@shahariaazam shahariaazam commented May 18, 2022

Properly use GitHub toolcache to avoid repeated download each time. Previously toolcache was just used to download the binary but it was not storing the downloaded binary to cache.

Now, it will check if the tool is exist in GitHub toolcache or not. If exists, it will not download the binary again and use the cache path instead.

Debug logs when tool not exists in cache

root@ffe405d4da32:/home/app/src# RUNNER_TEMP=/tmp RUNNER_TOOL_CACHE=/tmp/toolcache node index.js
::debug::Finding releases for Terraform version 0.11.14
::debug::Getting build for Terraform version 0.11.14: linux amd64
::debug::isExplicit: 0.11.14
::debug::explicit? true
::debug::checking cache: /tmp/toolcache/terraform/0.11.14/amd64
::debug::not found
::debug::Downloading Terraform CLI from https://releases.hashicorp.com/terraform/0.11.14/terraform_0.11.14_linux_amd64.zip
::debug::Downloading https://releases.hashicorp.com/terraform/0.11.14/terraform_0.11.14_linux_amd64.zip
::debug::Destination /tmp/3f4e19fb-5713-410d-a67a-fe2dd3a6636e
::debug::download complete
::debug::Extracting Terraform CLI zip file
[command]/usr/bin/unzip -o -q /tmp/3f4e19fb-5713-410d-a67a-fe2dd3a6636e
::debug::Terraform CLI path is /tmp/a202733a-04c1-440d-b8fe-75c2bebe0e28.
::debug::Caching tool terraform 0.11.14 amd64
::debug::source dir: /tmp/a202733a-04c1-440d-b8fe-75c2bebe0e28
::debug::destination /tmp/toolcache/terraform/0.11.14/amd64
::debug::finished caching tool
::add-path::/tmp/toolcache/terraform/0.11.14/amd64
::add-path::

Debug logs when the tool already in cache.

root@ffe405d4da32:/home/app/src# RUNNER_TEMP=/tmp RUNNER_TOOL_CACHE=/tmp/toolcache node index.js
::debug::Finding releases for Terraform version 0.11.14
::debug::Getting build for Terraform version 0.11.14: linux amd64
::debug::isExplicit: 0.11.14
::debug::explicit? true
::debug::checking cache: /tmp/toolcache/terraform/0.11.14/amd64
::debug::Found tool in cache terraform 0.11.14 amd64
::add-path::/tmp/toolcache/terraform/0.11.14/amd64

@hashicorp-cla
Copy link

hashicorp-cla commented May 18, 2022

CLA assistant check
All committers have signed the CLA.

@shahariaazam shahariaazam marked this pull request as ready for review May 18, 2022 10:44
@jpogran
Copy link
Collaborator

jpogran commented May 18, 2022

Thank you for the contribution @shahariaazam! There is an existing PR #94 that is attempting to do the same work as yours. Can you comment on how your approach is different?

I also think you'll need to run the build step to generate the dist files.

@shahariaazam
Copy link
Author

Thank you for the contribution @shahariaazam! There is an existing PR #94 that is attempting to do the same work as yours. Can you comment on how your approach is different?

I also think you'll need to run the build step to generate the dist files.

Cool! I didn't see that PR. #94 this also covered wrapper stuff as well. You can review any one of the PRs. If the author respond quickly you can review and merge that, otherwise I can add tests and cover wrapper stuff here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants