-
Notifications
You must be signed in to change notification settings - Fork 79
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
ci-test: Fix syntax/formatting check so it actually emits an exit code #237
base: master
Are you sure you want to change the base?
Conversation
@Maytha8 or @n-peugnet Can you review/approve this? |
f8f6193
to
4a27042
Compare
Looks OK, but gofmt is more about code formatting/prettify than syntax errors. In this case the syntax errors are caught in the next step, so this is more or less the same thing as before. |
If the step is useless, should we remove it instead of fixing it? |
This step is not useless, it checks that the code is formatted with |
But it is part of a CI pipeline, so if the job can and will never fail, nobody will ever look at it. |
$ diff -u <(echo -n) <(gofmt -d -s .)
--- /dev/fd/63 2025-01-14 19:01:56.993862536 +0100
+++ /dev/fd/62 2025-01-14 19:01:57.005862508 +0100
@@ -0,0 +1,12 @@
+diff main.go.orig main.go
+--- main.go.orig
++++ main.go
+@@ -15,7 +15,7 @@
+ )
+
+ func usage() {
+-fmt.Fprintf(os.Stderr, "%s\n", buildVersionString())
++ fmt.Fprintf(os.Stderr, "%s\n", buildVersionString())
+ fmt.Fprintf(os.Stderr, "\n")
+ fmt.Fprintf(os.Stderr, "%s is a tool that converts Go packages into Debian package source.\n", program)
+ fmt.Fprintf(os.Stderr, "\n")
$ echo $?
1 But I agree that the result is not very beautiful with the double diff. In my own projects I usually use Instead we could use |
Here is an exemple of what it does that just happened to me 😅: https://github.com/Debian/dh-make-golang/actions/runs/12845745463/job/35820145357?pr=243 |
The old format didn't emit any exit codes and thus did not cause CI to fail: $ diff -u <(echo -n) <(gofmt -d -s .) make.go:513:46: missing ',' before newline in composite literal $ echo $? 0 The old code would have an failure only if `gofmt` ran successfully AND outputted changes. With the new structure both `gofmt` and `git` needs to pass, thus capturing exit codes and error of any kind of failures.
4a27042
to
efb6240
Compare
Updated latest version to use the double command you suggested. It seems like the most solid option. Thanks! |
I noticed this bug while working on #225 and I saw this:
https://github.com/Debian/dh-make-golang/actions/runs/12617186618/job/35159206853
The old format didn't emit any exit codes and thus did not cause CI to fail:
The smallest possible fix to this is to ensure gofmt output actually goes to stdout as the original test expected: