-
Notifications
You must be signed in to change notification settings - Fork 4.1k
THRIFT-6011: Make compiled Go code formatting compatible with gofmt #3493
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
Merged
+464
−162
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,12 +202,53 @@ jobs: | |
| with: | ||
| go-version: ${{ matrix.go }} | ||
|
|
||
| - name: Run gofmt | ||
| - name: Install dependencies | ||
| run: | | ||
| sudo apt-get update -yq | ||
| # shellcheck disable=SC2086 | ||
| sudo apt-get install -y --no-install-recommends g++ $BUILD_DEPS | ||
|
|
||
| - name: Configure | ||
| run: | | ||
| ./bootstrap.sh | ||
| # shellcheck disable=SC2086 | ||
| ./configure $(echo $CONFIG_ARGS_FOR_SCA | sed 's/without-go/with-go/') | ||
|
|
||
| - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| name: thrift-compiler | ||
| path: compiler/cpp | ||
|
|
||
| - name: Run gofmt on checked-in Go files | ||
| # Args: | ||
| # -s: Simplify code | ||
| # -d: Display changes, and exit non-zero when changes present | ||
| # -l: List files that would change | ||
| # -e: Report all errors instead of only the first 10 | ||
| run: gofmt -s -d -e $(git ls-files | grep "\.go$") | ||
| run: | | ||
| git ls-files '*.go' > /tmp/go-files.txt | ||
| xargs -r gofmt -s -l -e < /tmp/go-files.txt > /tmp/gofmt-files.txt | ||
| cat /tmp/gofmt-files.txt | ||
| test ! -s /tmp/gofmt-files.txt | ||
|
|
||
| - name: Run gofmt on generated Go files | ||
| run: | | ||
| chmod a+x compiler/cpp/thrift | ||
| thrift_compiler="$PWD/compiler/cpp/thrift" | ||
|
|
||
| make -C lib/go/test THRIFT="$thrift_compiler" gopath | ||
| make -C test/go THRIFT="$thrift_compiler" gopath | ||
| make -C tutorial/go THRIFT="$thrift_compiler" all-local | ||
|
|
||
| { | ||
| find lib/go/test/gopath/src \ | ||
| -path lib/go/test/gopath/src/dontexportrwtest -prune -o \ | ||
| -name '*.go' -type f -print | ||
| find test/go/src/gen tutorial/go/gen-go -name '*.go' -type f -print | ||
| } > /tmp/generated-go-files.txt | ||
|
|
||
| xargs -r gofmt -l -e < /tmp/generated-go-files.txt > /tmp/generated-gofmt-files.txt | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comments here. |
||
| cat /tmp/generated-gofmt-files.txt | ||
| test ! -s /tmp/generated-gofmt-files.txt | ||
|
|
||
| lib-python: | ||
| needs: compiler | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with
xargsshould we use>>over>? with>, if multiple go files have issues, we would only report (caton the next line) issues from the last go file?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not really. The redirection applies to the
xargscommand, not to each subprocess it starts. All output from the invokedgofmtprocesses is collected through that single stdout stream and written to/tmp/gofmt-files.txt.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, an example just came through https://github.com/apache/thrift/actions/runs/26098116881/job/76747159994?pr=3495