Skip to content

Add github action terraform workflows for format checks and tests #11

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

Merged
merged 4 commits into from
Feb 21, 2024

Conversation

kris004
Copy link
Contributor

@kris004 kris004 commented Feb 12, 2024

Description of changes

  • Add terraform fmt check to ci workflow
  • Add terraofrm init check for modules
  • Add terraform init check for examples
  • Add terraform test for modules
  • Add terraform test for examples

NOTE: The init and test workflows will fail until the provider configuration is updated and the provider is available on the terraform registry.

Tests

  • Very terraform format runs successfully, expect init and test runs to fail

Checklist

By submitting the PR you confirm that you are going to do what follows before merging your code.

  1. I have read CONTRIBUTING.
  2. I have made the PR point to the right branch.
  3. I have added the right labels to the PR.
  4. I have checked that all commits' messages are clear, describing what and why vs how.
  5. I have successfully executed lint and tests to prove the quality and correctness of the change.
  6. I have added tests to validate the proposed change.
  7. I have added the documentation to describe my changes (if appropriate).
  8. I have added the necessary entries to the changelog (if appropriate).
  9. Any dependent changes have been merged and published in downstream modules.

Please review the guidelines for contributing and Pull Request Instructions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@kris004 kris004 requested a review from gmarciani February 12, 2024 20:17
@kris004 kris004 requested a review from a team as a code owner February 12, 2024 20:17
@github-actions github-actions bot added Documentation Improvements or additions to documentation Developer Experience Improves the Developer Experience labels Feb 12, 2024
  - Add terraform fmt check to ci workflow
  - Add terraofrm init check for modules
  - Add terraform init check for examples
  - Add terraform test for modules
  - Add terraform test for examples
@gmarciani gmarciani added the Skip Changelog Does not require a changelog update label Feb 13, 2024
gmarciani
gmarciani previously approved these changes Feb 14, 2024
@@ -77,3 +82,35 @@ jobs:
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false

# Run terraform init
- name: Terraform Init (Main Module)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: would it be possible to define all these steps by looping on a matrix where every element is a module folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, however then we would download and install go and terraform 16 times

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm looks like we can add dependancies between jobs, will test this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems to work, updated to use a matrix for the init and test steps

Copy link
Contributor

Choose a reason for hiding this comment

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

Great! Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry didn't look close enough, we cannot reuse the setup job since it cleans up before it finishes. See actions/checkout#1149. Will try with the setup in the same job, but if it works will be redoing those steps for each test.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it is complex, nevermind. Just a minor

@kris004 kris004 force-pushed the main branch 6 times, most recently from f543cb5 to 0dd07d6 Compare February 15, 2024 18:53
  - Move infra_only to required_infra to match naming convention
@kris004 kris004 merged commit 36d8517 into aws-tf:main Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Experience Improves the Developer Experience Documentation Improvements or additions to documentation Skip Changelog Does not require a changelog update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants