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

Does not honor -detailed-exitcode #42

Open
madchap opened this issue Nov 27, 2024 · 3 comments
Open

Does not honor -detailed-exitcode #42

madchap opened this issue Nov 27, 2024 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@madchap
Copy link

madchap commented Nov 27, 2024

Hi,

I have this GHA causing me grief... for brevity, the pieces that I believe matter.

The problem does not happen when I run locally with the same version of tofu and terragrunt (of course).

env:
  tofu_version: 1.8.5
  tg_version: 0.69.1

I install the tofu action with the latest version.

      - name: Setup Tofu with specified version on the runner
         uses: opentofu/setup-opentofu@v1
         with:
           tofu_version: ${{ env.tofu_version }}

yields success with

  with:
    tofu_version: 1.8.5
    cli_config_credentials_hostname: app.terraform.io
    tofu_wrapper: true

Below, if it returns 2, meaning a change, I want to capture that to apply later, for example.

      - name: TG plan
        id: plan
        if: matrix.folder != 'app_accounts'
        run: |
          cd ${{ github.workspace }}/infra/${{ matrix.folder }}
          terragrunt plan --terragrunt-non-interactive \
            -detailed-exitcode \
            -compact-warnings \
          || PLAN_STATUS=$?  # we want to continue even if the plan fails to detect changes
          [[ -z "$PLAN_STATUS" ]] && PLAN_STATUS=0
          echo "exit code for tofu plan is actually: $PLAN_STATUS"
          echo "plan_status=$PLAN_STATUS" >> $GITHUB_OUTPUT
          [[ $PLAN_STATUS -eq 2 ]] && exit 0 || exit $PLAN_STATUS

The exit code will always be 0 if run with tofu.

image

However, In that same GHA and all else being equals, if I just comment out the setup-opentofu stanza, terragrunt is forced to use terraform instead. And then, it works as expected.

image
@madchap
Copy link
Author

madchap commented Nov 27, 2024

Workaround:
Comment out the action, and install tofu directly.

      - name: Install Tofu
        run: |
          mkdir -p ${{ github.workspace }}/.local/bin && cd ${{ github.workspace }}/.local/bin
          wget -q -O tofu.tar.gz https://github.com/opentofu/opentofu/releases/download/v${{ env.tofu_version }}/tofu_${{ env.tofu_version }}_linux_amd64.tar.gz
          tar xf tofu.tar.gz
          chmod +x tofu
          tofu -v

@abstractionfactory
Copy link
Contributor

Hello and thank you for this issue! The core team regularly reviews new issues and discusses them, but this can take a little time. Please bear with us while we get to your issue. If you're interested, the contribution guide has a section about the decision-making process.

@cam72cam cam72cam added good first issue Good for newcomers help wanted Extra attention is needed labels Dec 3, 2024
@abstractionfactory
Copy link
Contributor

Thank you for the patience. We discussed this issue with the core team and would be happy to review a community PR for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants