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

fix: added gofmt to action #660

Merged
merged 3 commits into from
Jul 13, 2021
Merged

fix: added gofmt to action #660

merged 3 commits into from
Jul 13, 2021

Conversation

burntcarrot
Copy link
Member

@burntcarrot burntcarrot commented Jul 13, 2021

Related #563.

Added gofmt check to make sure every PR has been formatted.

@xxchan
Copy link
Contributor

xxchan commented Jul 13, 2021

Oops. It turns out that some files are not formatted via make build! To be more specific, gofmt . covers more than go fmt ./...

❯ gofmt -l .
cmd/definitions/bindata/bindata.go
cmd/definitions/parse.go
cmd/definitions/tools.go
cmd/definitions/type.go

❯ go fmt -n ./...  
/usr/local/go/bin/gofmt -l -w pkg/credential/credential.go
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/storage.go
/usr/local/go/bin/gofmt -l -w pkg/credential/error.go
/usr/local/go/bin/gofmt -l -w pkg/fswrap/doc.go
/usr/local/go/bin/gofmt -l -w pkg/fswrap/fileinfo.go
/usr/local/go/bin/gofmt -l -w pkg/fswrap/httpfs.go
/usr/local/go/bin/gofmt -l -w pkg/fswrap/iofs.go
/usr/local/go/bin/gofmt -l -w pairs/generated.go
/usr/local/go/bin/gofmt -l -w pkg/headers/range.go
/usr/local/go/bin/gofmt -l -w pkg/httpclient/client.go
/usr/local/go/bin/gofmt -l -w pkg/httpclient/conn.go
/usr/local/go/bin/gofmt -l -w pkg/httpclient/dialer.go
/usr/local/go/bin/gofmt -l -w pairs/error.go
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/generated.go
/usr/local/go/bin/gofmt -l -w pkg/iowrap/mock_test.go
/usr/local/go/bin/gofmt -l -w pkg/iowrap/pipe.go
/usr/local/go/bin/gofmt -l -w pkg/iowrap/interface.go
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/doc.go
/usr/local/go/bin/gofmt -l -w pkg/iowrap/pipe_test.go
/usr/local/go/bin/gofmt -l -w pkg/iowrap/reader.go
/usr/local/go/bin/gofmt -l -w pkg/iowrap/doc.go
/usr/local/go/bin/gofmt -l -w pairs/doc.go
/usr/local/go/bin/gofmt -l -w pkg/iowrap/writer_test.go
/usr/local/go/bin/gofmt -l -w pkg/randbytes/randbytes.go
/usr/local/go/bin/gofmt -l -w doc.go
/usr/local/go/bin/gofmt -l -w services/error.go
/usr/local/go/bin/gofmt -l -w services/new.go
/usr/local/go/bin/gofmt -l -w types/doc.go
/usr/local/go/bin/gofmt -l -w types/error.go
/usr/local/go/bin/gofmt -l -w types/info.generated.go
/usr/local/go/bin/gofmt -l -w types/info.go
/usr/local/go/bin/gofmt -l -w types/interceptor.go
/usr/local/go/bin/gofmt -l -w types/iterator.generated.go
/usr/local/go/bin/gofmt -l -w pkg/iowrap/pipe_bench_test.go
/usr/local/go/bin/gofmt -l -w types/object.generated.go
/usr/local/go/bin/gofmt -l -w types/object.go
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/connstr_test.go
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/service.go
/usr/local/go/bin/gofmt -l -w types/pair.go
/usr/local/go/bin/gofmt -l -w types/object_test.go
/usr/local/go/bin/gofmt -l -w types/iterator.go
/usr/local/go/bin/gofmt -l -w pkg/headers/headers.go
/usr/local/go/bin/gofmt -l -w pkg/credential/credential_test.go
/usr/local/go/bin/gofmt -l -w pkg/randbytes/randbytes_test.go
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/utils.go
/usr/local/go/bin/gofmt -l -w docs/rfcs/1/main_test.go
/usr/local/go/bin/gofmt -l -w pkg/iowrap/writer.go
/usr/local/go/bin/gofmt -l -w types/operation.go
/usr/local/go/bin/gofmt -l -w pkg/iowrap/reader_test.go
/usr/local/go/bin/gofmt -l -w types/operation.generated.go

Why only cmd/definitions/tests are formatted instead of cmd/definitions?

❯ go fmt -n ./cmd/...
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/connstr_test.go
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/doc.go
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/generated.go
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/service.go
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/storage.go
/usr/local/go/bin/gofmt -l -w cmd/definitions/tests/utils.go

@Xuanwo
Copy link
Contributor

Xuanwo commented Jul 13, 2021

go fmt ./... == gofmt -l -w, but without -s which means simplify code.

I prefer to use go fmt ./... here. (See next comment)

@Xuanwo
Copy link
Contributor

Xuanwo commented Jul 13, 2021

Oops. It turns out that some files are not formatted via make build!

Why only cmd/definitions/tests are formatted instead of cmd/definitions?

I think it's affected by the package's tag. (definitions are under tools tag), and gofmt doesn't care about the package tag.

Maybe use gofmt is a good choice, and we need to update make build too.

@Xuanwo
Copy link
Contributor

Xuanwo commented Jul 13, 2021

How about moving the format check in a separate action called gofmt instead of in unittests? In the new action, we can only run it in Linux instead of adding extra if statement.

@Xuanwo Xuanwo mentioned this pull request Jul 13, 2021
14 tasks
@burntcarrot
Copy link
Member Author

I was thinking about the same. Should I go on and create a new action for gofmt?

It would make the workflow much more cleaner and easier to maintain.

@Xuanwo
Copy link
Contributor

Xuanwo commented Jul 13, 2021

I was thinking about the same. Should I go on and create a new action for gofmt?

It would make the workflow much more cleaner and easier to maintain.

So nice!

I have updated #563 and please take a look.

@Xuanwo
Copy link
Contributor

Xuanwo commented Jul 13, 2021

I will create a pr to fix the code format.

@Xuanwo
Copy link
Contributor

Xuanwo commented Jul 13, 2021

Can you merge the master branch so that we can get the CI passed?

@codecov
Copy link

codecov bot commented Jul 13, 2021

Codecov Report

Merging #660 (4b041e1) into master (a8674d8) will increase coverage by 0.51%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #660      +/-   ##
==========================================
+ Coverage   17.57%   18.09%   +0.51%     
==========================================
  Files          19       19              
  Lines         768      746      -22     
==========================================
  Hits          135      135              
+ Misses        626      604      -22     
  Partials        7        7              
Flag Coverage Δ
unittests 18.09% <ø> (+0.51%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/definitions/tests/service.go 0.00% <0.00%> (ø)
cmd/definitions/tests/storage.go 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8674d8...4b041e1. Read the comment docs.

@Xuanwo Xuanwo merged commit 96ab6c0 into beyondstorage:master Jul 13, 2021
@Xuanwo
Copy link
Contributor

Xuanwo commented Jul 13, 2021

Thanks for your contribution! 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants