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

git not handling unchanged files properly #69

Closed
jevalenciap opened this issue Dec 19, 2022 · 7 comments
Closed

git not handling unchanged files properly #69

jevalenciap opened this issue Dec 19, 2022 · 7 comments
Assignees
Labels
bugfix Bug needing a fix

Comments

@jevalenciap
Copy link

I tested the Github action against HachiCorp Vault policy files, since it detects the formatting errors in the policies, then it failed because doesn't find tf and tfvars.

=> Searching for .tf and .tfvars files
error: unknown option `staged'

Wanted to see if you can include HCL Vault policies in the action or see if I can omit the step about searching .tf and .tfvars files in order to work with Vault.

@ChristophShyper ChristophShyper self-assigned this Dec 20, 2022
@ChristophShyper
Copy link
Member

@jevalenciap Which version of the action are you using?
git diff --staged was used here in versions prior to v0.3.
Please update it and let me know the result.

@jevalenciap
Copy link
Author

jevalenciap commented Dec 20, 2022

Thanks @ChristophShyper for your prompt response.
I am using V0.3

- name: Fail on malformatted files
        uses: devops-infra/action-format-hcl@v0.3
        with:
          list: true

It detects formatting issues correcly in the Vault HCL policies but then I got an error.
Adding a screenshot of the error that I am getting:
Not sure if the error is because tf and tfvars files are not found (since they are only applicable for Terraform but not for Vault)

HCL formatting_GH_actions

ChristophShyper added a commit that referenced this issue Dec 21, 2022
Fix for #69
Bump release to v0.3.1
@github-actions github-actions bot mentioned this issue Dec 21, 2022
2 tasks
@ChristophShyper ChristophShyper added the bugfix Bug needing a fix label Dec 21, 2022
@ChristophShyper
Copy link
Member

ChristophShyper commented Dec 21, 2022

@jevalenciap I found the issue. Due to how GitHub Actions are constructed the version needs to be always updated in the manifest file. Which I somehow missed for the last release. As a result, even if you had v0.3 in your workflow it still used the image with v0.2.
This line needed to be updated https://github.com/devops-infra/action-format-hcl/pull/70/files#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6R38
I'll release v0.3.1 now which should work properly.

ChristophShyper added a commit that referenced this issue Dec 21, 2022
Fix for #69
Bump release to v0.3.1

Co-authored-by: Krzysztof Szyper <krzysztof.szyper@brainly.com>
@jevalenciap
Copy link
Author

Thanks @ChristophShyper, I updated the GH action to the version 0.3.1

- name: Fail on malformatted files
        uses: devops-infra/action-format-hcl@v0.3.1
        with:
          list: true

But now I am getting a cache error once GH action runs.

image

ChristophShyper added a commit that referenced this issue Dec 21, 2022
Using `find . -newer ...` should give the same results as `git diff` in dockerized environment (minus `M` at beginning of the line).
While still giving empty string when no files where modified.
This will prevent ``error: unknown option `cached'``.

Bump release to v0.3.2

Second finding in #69
@ChristophShyper
Copy link
Member

ChristophShyper commented Dec 21, 2022

Looks like git even on Ubuntu acts different than on my host and in some cases (issue with .git) it throws this error.
So from now I'll use find instead of it, while maintaining similar functionality.
This change should do the trick https://github.com/devops-infra/action-format-hcl/pull/71/files#diff-6f9d41d046756f0ddc2fcee0626bdb50100d12b88f293734eff742818e03efa2R58

I'm releasing it with v0.3.3 version together with newest Terraform.

ChristophShyper added a commit that referenced this issue Dec 21, 2022
Using `find . -newer ...` should give the same results as `git diff` in dockerized environment (minus `M` at beginning of the line).
While still giving empty string when no files where modified.
This will prevent ``error: unknown option `cached'``.

Bump release to v0.3.2

Second finding in #69

Co-authored-by: Krzysztof Szyper <krzysztof.szyper@brainly.com>
@jevalenciap
Copy link
Author

@ChristophShyper
Great!, I tested it, I am not getting the error anymore.

image

Thank you so much! I appreciate your diligence and fast response

@ChristophShyper ChristophShyper changed the title Hachicorp Vault policies git not handling unchanged files properly Dec 21, 2022
@ChristophShyper
Copy link
Member

I'm happy my work is of any help to others 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Bug needing a fix
Development

No branches or pull requests

2 participants