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

Error: Uncommitted change(s) has been found! #124

Open
arivictor opened this issue Feb 9, 2024 · 3 comments
Open

Error: Uncommitted change(s) has been found! #124

arivictor opened this issue Feb 9, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@arivictor
Copy link

Describe the bug

I am trying to do a fail-on-diff check for a terraform module doc on a pull request. The GHA fails with

 * [new tag]         1.0.0      -> 1.0.0
 * [new tag]         1.1.0      -> 1.1.0
::debug working_dir=.
::debug config_file=.terraform-docs.yml
::debug output_mode=replace
::debug output_file=README.md
::debug terraform-docs markdown table --config .terraform-docs.yml --output-mode replace --output-file README.md --output-template <!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS --> .
README.md updated successfully
::debug No change in ./ detected

Error: Uncommitted change(s) has been found!

There is no change between my current README.md and the generated one (well, there shouldn't be in theory).

How can we reproduce it?

workflow

name: 'terraform docs'

on:
  pull_request:

permissions:
  contents: read

jobs:
  docs:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        ref: ${{ github.event.pull_request.head.ref }}

    - name: Generate TF Docs
      uses: terraform-docs/[email protected]
      with:
        config-file: .terraform-docs.yml
        working-dir: .
        output-file: README.md
        output-method: replace
        fail-on-diff: true

config

formatter: markdown table
header-from: main.tf
footer-from: ""
sections:
  show:
    - all
output:
  file: README.md
  mode: replace
  template: |-
    <!-- BEGIN_TF_DOCS -->
    
    {{ .Content }}

    <!-- END_TF_DOCS -->

sort:
  enabled: true
  by: required

settings:
  anchor: true
  indent: 2
  escape: false
  default: true
  required: true
  type: true

Environment information

@arivictor arivictor added the bug Something isn't working label Feb 9, 2024
@arivictor
Copy link
Author

I've also attempted to manually install terraform docs:
workflow

jobs:
  docs:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.sha }}

      - name: Check README.md is up to date
        run: |
            curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.17.0/terraform-docs-v0.17.0-linux-amd64.tar.gz
            tar -xzf terraform-docs.tar.gz
            chmod +x terraform-docs
            ./terraform-docs . --output-check

output

Run curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.17.0/terraform-docs-v0.17.0-linux-amd64.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100 6014k  100 6014k    0     0  19.7M      0 --:--:-- --:--:-- --:--:-- 19.7M
Error: README.md is out of date
Error: Process completed with exit code 1.

But when I run it locally

» terraform-docs . --output-check
README.md is up to date

I'm not sure what the remote is picking up that's causing a difference...

@arivictor
Copy link
Author

I saved the results the remote is giving me and then did a diff with my local copy:

diff README.md README2.md
< | <a name="provider_google"></a> [google](#provider_google) | 4.84.0 |
< | <a name="provider_google-beta"></a> [google-beta](#provider_google-beta) | 4.84.0 |
---
> | <a name="provider_google"></a> [google](#provider_google) | < 5.0 |
> | <a name="provider_google-beta"></a> [google-beta](#provider_google-beta) | < 5.0 |

🤔 why

@arivictor
Copy link
Author

AHA!

if I run terraform-docs without initialising terraform terraform init it takes the exact provider version from my terraform. If I initialise first, it uses whatever it downloads which happened to be 4.84.0.

So locally I had initialised, but remotely its just running terraform-docs as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant