Skip to content

ci: install Terraform to fix CI failure that Terraform is not found - #717

Merged
Kevin (kevcube) merged 1 commit into
cloudposse:mainfrom
suzuki-shunsuke:ci-install-terraform
Oct 13, 2024
Merged

Kevin (kevcube) merged 1 commit into
cloudposse:mainfrom
suzuki-shunsuke:ci-install-terraform

Conversation

@suzuki-shunsuke

@suzuki-shunsuke Shunsuke Suzuki (suzuki-shunsuke) commented Oct 13, 2024 •

Copy link
Copy Markdown
Contributor

what

Install Terraform using hashicorp/setup-terraform action in CI.

why

CI failed because Terraform wasn't found.

https://github.com/cloudposse/atmos/actions/runs/11307359580/job/31449045566
https://github.com/cloudposse/atmos/actions/runs/11307359580/job/31449046010

Run cd examples/demo-context
all stacks validated successfully
exec: "terraform": executable file not found in $PATH

This is because ubuntu-latest was updated to ubuntu-24.04 and Terraform was removed from it.

https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md

On the other hand, Ubuntu 22.04 has Terraform.

https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md

references

Summary by CodeRabbit

  • Chores
    • Enhanced workflow for testing and linting by integrating Terraform setup in multiple job sections.
    • Updated the lint job to dynamically retrieve the Terraform version for improved flexibility.

@suzuki-shunsuke Shunsuke Suzuki (suzuki-shunsuke) changed the title ci: install Terraform to solve the bug that Terraform is not found ci: install Terraform to fix CI failure that Terraform is not found Oct 13, 2024
@suzuki-shunsuke
Shunsuke Suzuki (suzuki-shunsuke) marked this pull request as ready for review October 13, 2024 15:33
@coderabbitai

coderabbitai Bot commented Oct 13, 2024 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The pull request modifies the GitHub Actions workflow file .github/workflows/test.yml to incorporate Terraform setup in three job sections: localstack, mock, and lint. The localstack and mock jobs now include a step to set up Terraform version "1.9.7" using the hashicorp/setup-terraform@v3 action. The lint job has been updated to retrieve the Terraform version dynamically from a previous step's output instead of using a hardcoded value.

Changes

File Path Change Summary
.github/workflows/test.yml Added Terraform setup step in localstack and mock jobs; updated lint job to use dynamic Terraform version.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHub Actions
    participant Terraform

    User->>GitHub Actions: Trigger workflow
    GitHub Actions->>Terraform: Setup Terraform (v1.9.7) in localstack
    GitHub Actions->>Terraform: Setup Terraform (v1.9.7) in mock
    GitHub Actions->>Terraform: Lint with version from previous step
Loading

🐇 "In the workflow's dance, we set the stage,
Terraform's here, turning a new page.
Localstack and mock, ready to play,
Linting with care, come what may!
Hopping along, we code with delight,
In our burrow of changes, everything's bright!" 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range comments (2)
.github/workflows/test.yml (2)

Line range hint 1-324: Overall LGTM with suggestions for improvement

The changes successfully address the PR objectives by adding Terraform setup steps across multiple jobs, which should resolve the CI failure due to missing Terraform.

To improve consistency and maintainability, consider the following suggestions:

  1. Centralize the Terraform version management by using a GitHub Actions variable or environment variable at the workflow level.
  2. Ensure all jobs use the same method for setting the Terraform version, either all using the centralized variable or all using the steps.config.outputs.terraform-version approach.
  3. If using the config step approach, make sure it's clearly defined and visible in the workflow file.

These changes would make future updates easier and reduce the risk of version inconsistencies across jobs.


Action Required: Define the config step to provide terraform-version.

The lint job references steps.config.outputs.terraform-version, but the config step is not defined in .github/workflows/test.yml. Please ensure that the config step is properly defined to set the Terraform version.

  • File: .github/workflows/test.yml
  • Lines: 157-166
🔗 Analysis chain

Line range hint 322-324: LGTM, but please clarify the source of the Terraform version.

The use of a dynamic Terraform version (${{ steps.config.outputs.terraform-version }}) in the lint job is a good practice for flexibility. However, it differs from the hardcoded versions used in other jobs.

Could you please clarify where the config step is defined and how the terraform-version output is set? This information is crucial for understanding the version management across the workflow.

To verify the existence and output of the config step, you can run the following:

This will help ensure that the config step is properly defined and its output is consistently used throughout the workflow.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and output of the config step

# Test: Search for the config step definition
echo "Searching for config step definition:"
rg --type yaml 'id:\s*config' .github/workflows/test.yml

# Test: Search for uses of steps.config.outputs.terraform-version
echo "Searching for uses of steps.config.outputs.terraform-version:"
rg --type yaml 'steps\.config\.outputs\.terraform-version' .github/workflows/test.yml

Length of output: 439

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 8c6591b and de63fa4.

📒 Files selected for processing (1)
  • .github/workflows/test.yml (2 hunks)
🧰 Additional context used
🔇 Additional comments (1)
.github/workflows/test.yml (1)

269-272: LGTM! Consider centralizing the Terraform version.

The addition of the Terraform setup step in the mock job is consistent with the changes in the localstack job and addresses the CI failure mentioned in the PR objectives.

As mentioned in the previous comment, consider using a centralized variable for the Terraform version to ensure consistency and ease of updates across all jobs.

Comment thread .github/workflows/test.yml Resolved

@kevcube Kevin (kevcube) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks for the fix!

@github-actions

Copy link
Copy Markdown

These changes were released in v1.90.0.

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