You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/09/28 22:46:47 UTC

[GitHub] [trafficcontrol] ocket8888 opened a new pull request #5077: Go fmt action

ocket8888 opened a new pull request #5077:
URL: https://github.com/apache/trafficcontrol/pull/5077


   ## What does this PR (Pull Request) do?
   - [x] This PR is not related to any Issue
   
   This PR adds a new check to GHA for Go Format problems. It outputs annotations containing a diff chunk at each problematic part of the codebase. It also adds a supporting python script for the action (which could potentially be used with other linters, Pylint, ESLint etc.) and a badge for the action to the repository's README.
   
   ## Which Traffic Control components are affected by this PR?
   - CI tests
   
   ## What is the best way to verify this PR?
   Make a branch from this PR's branch, make some go-fmt invalidating change and push. Also, as it happens, there is currently a file in violation of `go fmt` in the `tc3` tool, so in addition to whatever change you make you should see that, too.
   
   The Python script comes with some doctests, so to test it run `python -m doctest path/to/parse_diffs.py`.
   
   ## The following criteria are ALL met by this PR
   - [x] This PR includes tests
   - [x] This PR includes documentation in the form of docstrings
   - [x] An update to CHANGELOG.md is not necessary
   - [x] This PR includes any and all required license headers
   - [x] This PR does not include a database migration
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY**


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5077: Go fmt action

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5077:
URL: https://github.com/apache/trafficcontrol/pull/5077#discussion_r496294792



##########
File path: .github/actions/go-fmt/Dockerfile
##########
@@ -0,0 +1,25 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+FROM golang:1.14.2-alpine
+
+RUN apk add --no-cache git python3
+
+COPY entrypoint.sh /entrypoint.sh
+RUN chmod a+x /entrypoint.sh

Review comment:
       I've had problems with that in the past, but I suppose the only relevant question is: does it matter to the GHA runner? We'll soon find out.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5077: Go fmt action

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5077:
URL: https://github.com/apache/trafficcontrol/pull/5077#discussion_r496295978



##########
File path: misc/parse_diffs.py
##########
@@ -0,0 +1,262 @@
+#!/usr/bin/env python3
+
+"""
+This script parses git diffs and outputs a set of GitHub Action annotations where each section of
+each file is an annotation containing the diff chunk as a message. All annotations are error-level.
+"""
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import re
+import sys
+import typing
+
+from enum import Enum
+
+class Level(Enum):
+	"""
+	Level encodes the level of an annotation.
+	"""
+
+	error = "error"
+	notice = "notice" # notice not implemented (yet?)
+	warn = "warning" # warning unused - diffs are assumed errors
+
+class Annotation(typing.NamedTuple):
+	"""
+	Annotation represents a GitHub Actions Annotation. To preview the GitHub Annotation string,
+	coerce it to a string value. For a fully sanitized, printable Annotation, use the sanitize
+	method.
+
+	>>> print(Annotation(level=Level.error, file='test', line=1, message='test'))
+	::error file=test,line=1::test
+	"""
+	level: Level
+	file: str
+	line: int
+	message: str
+
+	def __str__(self) -> str:
+		msg = self.message.replace("]", "%5D").replace(";", "%3B")
+		return f"::{self.level.value} file={self.file},line={self.line}::{msg}"
+
+	def __repr__(self) -> str:
+		return f"Annotation(level={self.level}, file='{self.file}', line={self.line})"
+
+	def sanitize(self) -> str:
+		"""
+		sanitize returns a sanitized string, suitable for GHA, but not for humans to read because
+		all newlines have been replaced with their URL percent-encoded code points.
+		"""
+		return str(self).replace("\r", "%0D").replace("\n", "%0A")
+
+CHUNK_HEADER_PATTERN = re.compile(r"^@@ -\d+,\d+ \+(\d+),(\d+) @@")
+
+def parse_chunk(chunk: str, file: str) -> Annotation:
+	"""
+	parse_chunk parses a single diff chunk and produces a corresponding annotation.
+
+	>>> chunk = '''@@ -1,3 +1,3 @@
+	...  {
+	... +    "test": "quest"
+	... -    "foo": "bar"
+	...  }'''
+	>>> ann = parse_chunk(chunk, "test")
+	>>> ann
+	Annotation(level=Level.error, file='test', line=2)
+	>>> print(ann)
+	::error file=test,line=2::Format error
+	```diff
+	@@ -1,3 +1,3 @@
+	 {
+	+    "test": "quest"
+	-    "foo": "bar"
+	 }
+	```

Review comment:
       Annotations aren't markdown-formatted _today_, but they could be. I'm sort of hoping they add support, although [the related support community post](https://github.community/t/checks-ability-to-include-markdown-in-line-annotations/14736/3) only has three hearts, so that may be a pipe dream. I can get rid of the formatting if you think it's ugly.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5077: Go fmt action

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #5077:
URL: https://github.com/apache/trafficcontrol/pull/5077#discussion_r496296057



##########
File path: .github/actions/go-fmt/entrypoint.sh
##########
@@ -0,0 +1,37 @@
+#!/bin/sh -l
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+
+GOPATH="$(mktemp -d)"
+SRCDIR="$GOPATH/src/github.com/apache"
+mkdir -p "$SRCDIR"
+ln -s "$PWD" "$SRCDIR/trafficcontrol"
+cd "$SRCDIR/trafficcontrol"
+
+/usr/local/go/bin/go fmt ./...
+DIFF_FILE="$(mktemp)"
+git --no-pager diff >"$DIFF_FILE"
+
+if [ -s "$DIFF_FILE" ]; then
+	./misc/parse_diffs.py <"$DIFF_FILE";
+	rm "$DIFF_FILE";
+	exit 1;
+fi
+echo "No diff found, exiting" >&2
+exit 0;

Review comment:
       right. That if statement logic was reversed in an earlier revision.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #5077: Go fmt action

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on a change in pull request #5077:
URL: https://github.com/apache/trafficcontrol/pull/5077#discussion_r496297395



##########
File path: misc/parse_diffs.py
##########
@@ -0,0 +1,262 @@
+#!/usr/bin/env python3
+
+"""
+This script parses git diffs and outputs a set of GitHub Action annotations where each section of
+each file is an annotation containing the diff chunk as a message. All annotations are error-level.
+"""
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import re
+import sys
+import typing
+
+from enum import Enum
+
+class Level(Enum):
+	"""
+	Level encodes the level of an annotation.
+	"""
+
+	error = "error"
+	notice = "notice" # notice not implemented (yet?)
+	warn = "warning" # warning unused - diffs are assumed errors
+
+class Annotation(typing.NamedTuple):
+	"""
+	Annotation represents a GitHub Actions Annotation. To preview the GitHub Annotation string,
+	coerce it to a string value. For a fully sanitized, printable Annotation, use the sanitize
+	method.
+
+	>>> print(Annotation(level=Level.error, file='test', line=1, message='test'))
+	::error file=test,line=1::test
+	"""
+	level: Level
+	file: str
+	line: int
+	message: str
+
+	def __str__(self) -> str:
+		msg = self.message.replace("]", "%5D").replace(";", "%3B")
+		return f"::{self.level.value} file={self.file},line={self.line}::{msg}"
+
+	def __repr__(self) -> str:
+		return f"Annotation(level={self.level}, file='{self.file}', line={self.line})"
+
+	def sanitize(self) -> str:
+		"""
+		sanitize returns a sanitized string, suitable for GHA, but not for humans to read because
+		all newlines have been replaced with their URL percent-encoded code points.
+		"""
+		return str(self).replace("\r", "%0D").replace("\n", "%0A")
+
+CHUNK_HEADER_PATTERN = re.compile(r"^@@ -\d+,\d+ \+(\d+),(\d+) @@")
+
+def parse_chunk(chunk: str, file: str) -> Annotation:
+	"""
+	parse_chunk parses a single diff chunk and produces a corresponding annotation.
+
+	>>> chunk = '''@@ -1,3 +1,3 @@
+	...  {
+	... +    "test": "quest"
+	... -    "foo": "bar"
+	...  }'''
+	>>> ann = parse_chunk(chunk, "test")
+	>>> ann
+	Annotation(level=Level.error, file='test', line=2)
+	>>> print(ann)
+	::error file=test,line=2::Format error
+	```diff
+	@@ -1,3 +1,3 @@
+	 {
+	+    "test": "quest"
+	-    "foo": "bar"
+	 }
+	```

Review comment:
       Fair enough




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] zrhoffman merged pull request #5077: Go fmt action

Posted by GitBox <gi...@apache.org>.
zrhoffman merged pull request #5077:
URL: https://github.com/apache/trafficcontrol/pull/5077


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] zrhoffman commented on a change in pull request #5077: Go fmt action

Posted by GitBox <gi...@apache.org>.
zrhoffman commented on a change in pull request #5077:
URL: https://github.com/apache/trafficcontrol/pull/5077#discussion_r496286382



##########
File path: .github/actions/go-fmt/entrypoint.sh
##########
@@ -0,0 +1,37 @@
+#!/bin/sh -l
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+
+GOPATH="$(mktemp -d)"
+SRCDIR="$GOPATH/src/github.com/apache"
+mkdir -p "$SRCDIR"
+ln -s "$PWD" "$SRCDIR/trafficcontrol"
+cd "$SRCDIR/trafficcontrol"
+
+/usr/local/go/bin/go fmt ./...
+DIFF_FILE="$(mktemp)"
+git --no-pager diff >"$DIFF_FILE"

Review comment:
       `--no-pager` is not necessary, it only adds the pager when stdout is a TTY

##########
File path: .github/actions/go-fmt/Dockerfile
##########
@@ -0,0 +1,25 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+FROM golang:1.14.2-alpine
+
+RUN apk add --no-cache git python3
+
+COPY entrypoint.sh /entrypoint.sh
+RUN chmod a+x /entrypoint.sh

Review comment:
       If the file is executable, this layer can be removed

##########
File path: misc/parse_diffs.py
##########
@@ -0,0 +1,262 @@
+#!/usr/bin/env python3
+
+"""
+This script parses git diffs and outputs a set of GitHub Action annotations where each section of
+each file is an annotation containing the diff chunk as a message. All annotations are error-level.
+"""
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import re
+import sys
+import typing
+
+from enum import Enum
+
+class Level(Enum):
+	"""
+	Level encodes the level of an annotation.
+	"""
+
+	error = "error"
+	notice = "notice" # notice not implemented (yet?)
+	warn = "warning" # warning unused - diffs are assumed errors
+
+class Annotation(typing.NamedTuple):
+	"""
+	Annotation represents a GitHub Actions Annotation. To preview the GitHub Annotation string,
+	coerce it to a string value. For a fully sanitized, printable Annotation, use the sanitize
+	method.
+
+	>>> print(Annotation(level=Level.error, file='test', line=1, message='test'))
+	::error file=test,line=1::test
+	"""
+	level: Level
+	file: str
+	line: int
+	message: str
+
+	def __str__(self) -> str:
+		msg = self.message.replace("]", "%5D").replace(";", "%3B")
+		return f"::{self.level.value} file={self.file},line={self.line}::{msg}"
+
+	def __repr__(self) -> str:
+		return f"Annotation(level={self.level}, file='{self.file}', line={self.line})"
+
+	def sanitize(self) -> str:
+		"""
+		sanitize returns a sanitized string, suitable for GHA, but not for humans to read because
+		all newlines have been replaced with their URL percent-encoded code points.
+		"""
+		return str(self).replace("\r", "%0D").replace("\n", "%0A")
+
+CHUNK_HEADER_PATTERN = re.compile(r"^@@ -\d+,\d+ \+(\d+),(\d+) @@")
+
+def parse_chunk(chunk: str, file: str) -> Annotation:
+	"""
+	parse_chunk parses a single diff chunk and produces a corresponding annotation.
+
+	>>> chunk = '''@@ -1,3 +1,3 @@
+	...  {
+	... +    "test": "quest"
+	... -    "foo": "bar"
+	...  }'''
+	>>> ann = parse_chunk(chunk, "test")
+	>>> ann
+	Annotation(level=Level.error, file='test', line=2)
+	>>> print(ann)
+	::error file=test,line=2::Format error
+	```diff
+	@@ -1,3 +1,3 @@
+	 {
+	+    "test": "quest"
+	-    "foo": "bar"
+	 }
+	```
+	"""
+	lines = chunk.splitlines()
+	if len(lines) < 2:
+		raise ValueError(f"invalid diff chunk: {chunk}")
+
+	match = CHUNK_HEADER_PATTERN.match(lines[0])
+	if not match or len(match.groups()) != 2:
+		raise ValueError(f"invalid diff chunk header: {lines[0]}")
+
+	line = int(match.groups()[0]) + int(match.groups()[1])//2
+
+	content = "\n".join(["Format error", "```diff", chunk, "```"])
+
+	return Annotation(Level.error, file, line, content)
+
+
+FILE_HEADER_PATTERN = re.compile(r"^diff --git a/(.+) b/(.+)$")
+
+def parse_file(contents: str) -> typing.List[Annotation]:
+	"""
+	parse_file parses the diff for a single file and returns the corresponding annotations.
+
+	>>> file = '''diff --git a/test b/test
+	... index c9072dcb7..2b7686061 100644
+	... --- a/test
+	... +++ b/test
+	... @@ -24,7 +24,7 @@ package tc
+	...  // in: body
+	...  type ASNsResponse struct {
+	...         // in: body
+	... -       Response []ASN `json:"response"`
+	... +Response []ASN `json:"response"`
+	...        Alerts
+	... }
+	...
+	... @@ -85,7 +85,7 @@ type ASNNullable struct {
+	...         // ID of the ASN
+	...         //
+	...         // required: true
+	... -       ID *int `json:"id" db:"id"`
+	... +ID *int `json:"id" db:"id"`
+	...
+	...         // LastUpdated
+	...         //
+	... '''
+	>>> anns = parse_file(file)
+	>>> len(anns)
+	2
+	>>> anns[0]
+	Annotation(level=Level.error, file='test', line=27)
+	>>> anns[1]
+	Annotation(level=Level.error, file='test', line=88)
+	"""
+	lines = contents.splitlines()
+	if len(lines) < 5:
+		raise ValueError(f"'{contents}' does not represent a file diff in git format")
+
+	match = FILE_HEADER_PATTERN.match(lines[0])
+	if not match or len(match.groups()) != 2:
+		raise ValueError(f"invalid git diff file header: '{lines[0]}'")
+
+	fname = match.groups()[1]
+
+	lines = lines[4:]
+	contents = "\n".join(lines)

Review comment:
       This variable is unused

##########
File path: misc/parse_diffs.py
##########
@@ -0,0 +1,262 @@
+#!/usr/bin/env python3
+
+"""
+This script parses git diffs and outputs a set of GitHub Action annotations where each section of
+each file is an annotation containing the diff chunk as a message. All annotations are error-level.
+"""
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import re
+import sys
+import typing
+
+from enum import Enum
+
+class Level(Enum):
+	"""
+	Level encodes the level of an annotation.
+	"""
+
+	error = "error"
+	notice = "notice" # notice not implemented (yet?)
+	warn = "warning" # warning unused - diffs are assumed errors
+
+class Annotation(typing.NamedTuple):
+	"""
+	Annotation represents a GitHub Actions Annotation. To preview the GitHub Annotation string,
+	coerce it to a string value. For a fully sanitized, printable Annotation, use the sanitize
+	method.
+
+	>>> print(Annotation(level=Level.error, file='test', line=1, message='test'))
+	::error file=test,line=1::test
+	"""
+	level: Level
+	file: str
+	line: int
+	message: str
+
+	def __str__(self) -> str:
+		msg = self.message.replace("]", "%5D").replace(";", "%3B")
+		return f"::{self.level.value} file={self.file},line={self.line}::{msg}"
+
+	def __repr__(self) -> str:
+		return f"Annotation(level={self.level}, file='{self.file}', line={self.line})"
+
+	def sanitize(self) -> str:
+		"""
+		sanitize returns a sanitized string, suitable for GHA, but not for humans to read because
+		all newlines have been replaced with their URL percent-encoded code points.
+		"""
+		return str(self).replace("\r", "%0D").replace("\n", "%0A")
+
+CHUNK_HEADER_PATTERN = re.compile(r"^@@ -\d+,\d+ \+(\d+),(\d+) @@")
+
+def parse_chunk(chunk: str, file: str) -> Annotation:
+	"""
+	parse_chunk parses a single diff chunk and produces a corresponding annotation.
+
+	>>> chunk = '''@@ -1,3 +1,3 @@
+	...  {
+	... +    "test": "quest"
+	... -    "foo": "bar"
+	...  }'''
+	>>> ann = parse_chunk(chunk, "test")
+	>>> ann
+	Annotation(level=Level.error, file='test', line=2)
+	>>> print(ann)
+	::error file=test,line=2::Format error
+	```diff
+	@@ -1,3 +1,3 @@
+	 {
+	+    "test": "quest"
+	-    "foo": "bar"
+	 }
+	```

Review comment:
       Annotations are not markdown-formatted, so <code>```diff</code> is visible in the annotation itself

##########
File path: .github/actions/go-fmt/entrypoint.sh
##########
@@ -0,0 +1,37 @@
+#!/bin/sh -l
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+
+GOPATH="$(mktemp -d)"
+SRCDIR="$GOPATH/src/github.com/apache"
+mkdir -p "$SRCDIR"
+ln -s "$PWD" "$SRCDIR/trafficcontrol"
+cd "$SRCDIR/trafficcontrol"
+
+/usr/local/go/bin/go fmt ./...
+DIFF_FILE="$(mktemp)"
+git --no-pager diff >"$DIFF_FILE"
+
+if [ -s "$DIFF_FILE" ]; then
+	./misc/parse_diffs.py <"$DIFF_FILE";
+	rm "$DIFF_FILE";
+	exit 1;
+fi
+echo "No diff found, exiting" >&2
+exit 0;

Review comment:
       `exit 0` is not necessary, 0 is the default exit code




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org