Specify gofumpt version in the Makefile #1266

Closed
opened 2024-07-23 07:45:26 +00:00 by fyrchik · 5 comments
Owner

#1265 occurred, because one of the team members was using 0.6.0, while the others used the previous version.
In this task introduce fumpt-install target to install the specified version and add a separate action to tests.yml workflow.
gofumpt is already skipped by pre-commit on CI, but not used in another action, currently.

#1265 occurred, because one of the team members was using 0.6.0, while the others used the previous version. In this task introduce `fumpt-install` target to install the specified version and add a separate action to `tests.yml` workflow. `gofumpt` is already skipped by pre-commit on CI, but not used in another action, currently.
fyrchik added the
Infrastructure
label 2024-07-23 07:45:26 +00:00
elebedeva was assigned by fyrchik 2024-07-23 07:53:08 +00:00
fyrchik added this to the v0.43.0 milestone 2024-07-23 07:53:41 +00:00
fyrchik added the
internal
label 2024-07-23 07:53:49 +00:00
fyrchik reopened this issue 2024-09-12 07:58:01 +00:00
Author
Owner

@elebedeva #1370 fixes the gofumpt issue. It was introduced in #1362 where the action
https://git.frostfs.info/TrueCloudLab/frostfs-node/actions/runs/11191/jobs/6 succeded, even though we can see the unformatted file in its output.
Please, tell me how have you tested #1286?
I am reopening this issue to investigate.

@elebedeva #1370 fixes the gofumpt issue. It was introduced in #1362 where the action https://git.frostfs.info/TrueCloudLab/frostfs-node/actions/runs/11191/jobs/6 succeded, even though we can see the unformatted file in its output. Please, tell me how have you tested #1286? I am reopening this issue to investigate.
Member

Interestingly, gofumpt always returns an exit code of 0, even when it finds misformatted files (see this issue). Currently, we list all found files, so we can check if the gofumpt output is empty with a command like this:

$ test -z "$(gofumpt -l -w pkg/)"

# another syntax for `test` command
$ [ -z "$(gofumpt -l -w pkg/)" ]

However, we not only need to check the gofumpt output, but also print it. It's getting harder🫠. What about this approach?

$ gofumpt -l -w pkg/ | tee >(cat >&2) | xargs test -z

I'm unsure how hard it will be to add this into the Makefile

Interestingly, `gofumpt` always returns an exit code of 0, even when it finds misformatted files (see [this issue](https://github.com/mvdan/gofumpt/issues/114)). Currently, we list all found files, so we can check if the `gofumpt` output is empty with a command like this: ```sh $ test -z "$(gofumpt -l -w pkg/)" # another syntax for `test` command $ [ -z "$(gofumpt -l -w pkg/)" ] ``` However, we not only need to check the `gofumpt` output, but also print it. It's getting harder🫠. What about this approach? ```sh $ gofumpt -l -w pkg/ | tee >(cat >&2) | xargs test -z ``` I'm unsure how hard it will be to add this into the Makefile
Member

@fyrchik I probably missed this case because of pre-commit hook failing if any files were changed and I falsely assumed workflows operate the same way. Now I see that fumt target should fail explicitly if gofumt changed any files.

@fyrchik I probably missed this case because of `pre-commit` hook failing if any files were changed and I falsely assumed workflows operate the same way. Now I see that `fumt` target should fail explicitly if `gofumt` changed any files.
Author
Owner

make fumpt should not fail, it should format.
But fumpt action should fail.

`make fumpt` should not fail, it should format. But `fumpt` action should fail.
Member

@elebedeva I've found forgejo-runner really handy for debugging actions.

@elebedeva I've found [forgejo-runner](https://forgejo.org/docs/v1.20/user/actions/#debugging-workflows-with-forgejo-runner-exec) really handy for debugging actions.
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#1266
No description provided.