Giter Site home page Giter Site logo

Comments (6)

robburger avatar robburger commented on August 11, 2024 1

This should now be resolved in v1.3.0. The default v1 tag has also been moved to the latest commit c455396

I've tested in a few plans on v0.12/v0.13/v0.14 and it seems to work consistently, but please feel free to re-open this issue if there's anything weird going on with the formatting or I've missed a test case!

from terraform-pr-commenter.

Fresa avatar Fresa commented on August 11, 2024

Yeah something is wrong with the parsing of the input somewhere. If TF_IN_AUTOMATION: true is not set I get the following output:

image

I cherry picked the plan parsing parts from

INPUT=$(echo "$2" | sed 's/\x1b\[[0-9;]*m//g')

and
CLEAN_PLAN=$(echo "$INPUT" | sed -n '/Refreshing state\.\.\./!p') # Strip refresh section
CLEAN_PLAN=$(echo "$CLEAN_PLAN" | sed -nr '/-{72}/q;p') # Ignore everything after the 72 dashes (happens when saving a plan to file)
CLEAN_PLAN=${CLEAN_PLAN::65300} # GitHub has a 65535-char comment limit - truncate plan, leaving space for comment wrapper
CLEAN_PLAN=$(echo "$CLEAN_PLAN" | sed -r 's/^([[:blank:]]*)([-+~])/\2\1/g') # Move any diff characters to start of line
if [[ $COLOURISE == 'true' ]]; then
CLEAN_PLAN=$(echo "$CLEAN_PLAN" | sed -r 's/^~/!/g') # Replace ~ with ! to colourise the diff in GitHub comments
fi

which became

INPUT=$(terraform plan | sed 's/\x1b\[[0-9;]*m//g')
CLEAN_PLAN=$(echo "$INPUT" | sed -n '/Refreshing state\.\.\./!p') # Strip refresh section
CLEAN_PLAN=$(echo "$CLEAN_PLAN" | sed -nr '/-{72}/q;p') # Ignore everything after the 72 dashes (happens when saving a plan to file)
CLEAN_PLAN=${CLEAN_PLAN::65300} # GitHub has a 65535-char comment limit - truncate plan, leaving space for comment wrapper
CLEAN_PLAN=$(echo "$CLEAN_PLAN" | sed -r 's/^([[:blank:]]*)([-+~])/\2\1/g') # Move any diff characters to start of line
CLEAN_PLAN=$(echo "$CLEAN_PLAN" | sed -r 's/^~/!/g') # Replace ~ with ! to colourise the diff in GitHub comments
echo "$CLEAN_PLAN"

and ran it locally, and the output looked correct (incl removing the 72 dashes and the text after that).

The input to Docker looks fine as far as I can tell when viewing it in the output of the Post Plan step.

It seems like all the output before the 72 dashes is removed for some reason. Maybe steps.plan.outputs.stdout formats weirdly or something happens with the formatting when sending it to Docker?

from terraform-pr-commenter.

robburger avatar robburger commented on August 11, 2024

Apologies, these notifications went to spam and I missed this thread!

@tamccall or @Fresa would you be able to confirm which version of Terraform you're using in the preceding steps?

My immediate suspicion is that this is related to Terraform v0.14's change to the way the output is formatted after a plan (they dropped the 72 -'s.) I've not yet moved my personal Terraform config over from v0.13 to v0.14 yet and it seems to still be running fine on both v0.12 and v0.13 - at least in the quick checks that I've done now.

I'll have a look in the next day or two to see if there's a backwards-compatible way of stripping off that refresh section.

from terraform-pr-commenter.

Fresa avatar Fresa commented on August 11, 2024

v0.14.5

from terraform-pr-commenter.

tamccall avatar tamccall commented on August 11, 2024
      - name: Setup Terraform
        uses: hashicorp/setup-terraform@v1
        with:
          cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
          terraform_version: 0.14.5

from terraform-pr-commenter.

Fresa avatar Fresa commented on August 11, 2024

Can confirm that it works like a charm now! Great work @robburger! 🎉

from terraform-pr-commenter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.