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

Fixing print of lint errors in golangci-lint action #246

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
19 changes: 12 additions & 7 deletions .github/workflows/golangci_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ jobs:
- name: Install golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2

# go.work makes it necessary to run linter manually
- name: Run golangci-lint
run: find . -name "go.mod" -execdir $(go env GOPATH)/bin/golangci-lint run --enable=gofmt --tests=false --exclude-use-default --timeout=5m0s --out-format checkstyle:golangci-lint-report.xml \;
run: docker run --rm -v ${{ github.workspace }}:/app -w /app golangci/golangci-lint:v1.54.2 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 --out-format checkstyle:golangci-lint-results.xml,json:golangci-lint-results.json || true

- name: Check golangci-lint report for errors
run: find . -name "golangci-lint-report.xml" -exec grep "error" {} + && exit 1 || true
run: |
if jq -e '.Issues | length > 0' golangci-lint-results.json; then
echo "Lint issues found:"
jq '.Issues[] | "\(.FromLinter): \(.Pos.Filename):\(.Pos.Line) \(.Text)"' golangci-lint-results.json
exit 1
else
echo "No issues found"
fi

- name: Upload golangci-lint report
if: always()
uses: actions/upload-artifact@v3
with:
name: golangci-lint-report
path: |
./golangci-lint-report.xml
name: golangci-lint-results
chudilka1 marked this conversation as resolved.
Show resolved Hide resolved
path: ./golangci-lint-results.xml
4 changes: 2 additions & 2 deletions .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
workflow: golangci_lint.yml
workflow_conclusion: ""
name_is_regexp: true
name: golangci-lint-report
name: golangci-lint-results
if_no_artifact_found: warn

- name: Download Go PKG test reports
Expand All @@ -61,7 +61,7 @@ jobs:
shell: bash
run: |
echo "sonarqube_coverage_report_paths=$(find -type f -name '*coverage.out' -printf "%p,")" >> $GITHUB_OUTPUT
echo "sonarqube_golangci_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,")" >> $GITHUB_OUTPUT
echo "sonarqube_golangci_report_paths=$(find -type f -name 'golangci-lint-results.xml' -printf "%p,")" >> $GITHUB_OUTPUT

- name: SonarQube Scan
if: always()
Expand Down
3 changes: 2 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
sonar.projectName=chainlink-common
# projectKey is required (may be found under "Project Information" in Sonar or in project url)
sonar.projectKey=smartcontractkit_chainlink-common
sonar.sources=.
chudilka1 marked this conversation as resolved.
Show resolved Hide resolved

# Full exclusions from the static analysis
sonar.exclusions=**/mocks/**/*, **/testdata/**/*, **/script/**/*, **/generated/**/*, **/fixtures/**/*, **/docs/**/*, **/tools/**/*, **/*.pb.go, **/*report.xml, **/*.txt, **/*.abi, **/*.bin
sonar.exclusions=**/mocks/**/*, **/testdata/**/*, **/script/**/*, **/generated/**/*, **/fixtures/**/*, **/docs/**/*, **/tools/**/*, **/*.pb.go, **/*results, **/*.txt, **/*.abi, **/*.bin
# Coverage exclusions
sonar.coverage.exclusions=**/*_test.go

Expand Down