Copilot commented on code in PR #269:
URL: https://github.com/apache/skywalking-eyes/pull/269#discussion_r3036778429


##########
.github/workflows/lint.yaml:
##########
@@ -0,0 +1,64 @@
+# 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.
+
+name: Lint
+
+on:
+  pull_request:
+    branches: [ main ]
+
+jobs:
+  lint:
+    name: Go
+    runs-on: ubuntu-latest
+    permissions:
+      # Required: allow read access to the content for analysis.
+      contents: read
+    steps:
+
+      - name: Check out code into the Go module directory
+        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 
v6.0.2
+
+      - name: Set up Go
+        uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # 
v6.4.0
+        with:
+          go-version-file: go.mod
+
+      - name: Go formatting
+        run: |
+          if [ -z "$(gofmt -l .)" ]; then
+            echo -e "All '*.go' files are properly formatted."
+          else
+            echo -e "Please run 'gofmt -w .' to fix. Some files need 
formatting:"
+            gofmt -d -l .
+            exit 1
+          fi
+
+      - name: Read golangci-lint version from Makefile
+        id: lint-version
+        run: |
+          version=$(sed -n 's/^GOLANGCI_LINT_VERSION\s*=\s*//p' Makefile)
+          echo "golangci-lint version: ${version}"
+          echo "version=${version}" >> $GITHUB_OUTPUT

Review Comment:
   The `sed` expression uses `\s`, which isn’t a portable/standard whitespace 
matcher in `sed` regexes (it will typically be treated as a literal `s`). With 
`-n ... /p`, this likely yields an empty `version`, causing 
golangci-lint-action to run with a blank/incorrect version. Use `[[:space:]]*` 
(or another robust parse like `awk -F=`) and consider trimming/validating 
non-empty output before writing to `$GITHUB_OUTPUT`.
   ```suggestion
             version=$(sed -n 
's/^GOLANGCI_LINT_VERSION[[:space:]]*=[[:space:]]*//p' Makefile)
             if [ -z "${version}" ]; then
               echo "Failed to read GOLANGCI_LINT_VERSION from Makefile" >&2
               exit 1
             fi
             echo "golangci-lint version: ${version}"
             echo "version=${version}" >> "$GITHUB_OUTPUT"
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to