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

[terraform] add cache layer to CI for modules and providers #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yohanb
Copy link
Contributor

@yohanb yohanb commented Nov 12, 2024

Description

Changes

  • feat(lint): add caching layer to terraform

🚀 PR created with fotingo

@yohanb yohanb changed the title CLOUD-676: [terraform] add cache layer to CI for modules and providers [terraform] add cache layer to CI for modules and providers Nov 12, 2024
@yohanb yohanb force-pushed the c/cloud-676_terraform_add_cache_layer_to_ci_for_modules_and_providers branch 9 times, most recently from 4a2074c to 20099b8 Compare November 15, 2024 23:00
@yohanb yohanb marked this pull request as ready for review November 15, 2024 23:09
@yohanb yohanb requested a review from a team as a code owner November 15, 2024 23:09
Copy link
Contributor

@tagoro9 tagoro9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting! Just some thoughts about not using $HOME

- name: Configure Terraform plugin cache
shell: bash
run: |
echo "TF_PLUGIN_CACHE_DIR=$HOME/.terraform.d/plugin-cache" >>"$GITHUB_ENV"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in the home our would it be better to use a tmp folder that is different for each agent?

In case agents are not ephemeral to avoid any pollution

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could replace $HOME refs with ${{ runner.temp }}

Copy link
Contributor Author

@yohanb yohanb Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that folder is emptied after each job.. wouldn't that defeat the purpose of the cache?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be fine. You load from S3 into that folder before tf runs and you isolate runs between jobs of different repos as you are not using the runner home folders, which for not epehemeral runners is not cleaned up.

with:
bucket: ${{ inputs.s3-bucket-name }}
use-fallback: false
path: ~/.terraform.d/plugin-cache
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ${{ runner.temp }} here as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what we set it to in the pre-commit cache: ${{ runner.temp }}/${{ github.event.repository.name }}/cache-pre-commit-${{ steps.pre_commit_cache_key.outputs.key }}

https://github.com/open-turo/action-pre-commit/blob/main/action.yaml

@yohanb yohanb force-pushed the c/cloud-676_terraform_add_cache_layer_to_ci_for_modules_and_providers branch from 20099b8 to dabb2e9 Compare November 18, 2024 21:39
@yohanb yohanb force-pushed the c/cloud-676_terraform_add_cache_layer_to_ci_for_modules_and_providers branch from dabb2e9 to 0538023 Compare November 18, 2024 22:04
Copy link

Release notes preview

Below is a preview of the release notes if your PR gets merged.


3.9.0 (2024-11-18)

Features

  • lint: add caching layer to terraform (0538023)

Miscellaneous

  • deps: update pre-commit hook alessandrojcm/commitlint-pre-commit-hook to v9.17.0 (8f1555c)
  • deps: update pre-commit hook alessandrojcm/commitlint-pre-commit-hook to v9.18.0 (e083d19)
  • deps: update pre-commit hook pre-commit/pre-commit-hooks to v5 (2601abb)
  • deps: update pre-commit hook rhysd/actionlint to v1.7.2 (4c72651)
  • deps: update pre-commit hook rhysd/actionlint to v1.7.3 (4749adf)
  • deps: update pre-commit hook rhysd/actionlint to v1.7.4 (aaeed94)

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.

2 participants