Skip to content

Commit

Permalink
Update paths to linter reports
Browse files Browse the repository at this point in the history
  • Loading branch information
chudilka1 committed Nov 27, 2024
1 parent 0569164 commit 258cc57
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
25 changes: 20 additions & 5 deletions .github/actions/golangci-lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,31 @@ runs:
with:
version: v1.62.2
only-new-issues: true
args: --out-format colored-line-number,checkstyle:${{ steps.set-working-directory.outputs.golangci-lint-working-directory }}_golangci-lint-report.xml -v
args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml -v
working-directory: ${{ steps.set-working-directory.outputs.golangci-lint-working-directory }}
- name: Print lint report artifact
if: failure()
shell: bashc
run: cat ./${{ inputs.go-directory }}/${{ steps.set-working-directory.outputs.golangci-lint-working-directory }}_golangci-lint-report.xml
shell: bash
run: cat ./${{ inputs.go-directory }}/golangci-lint-report.xml
- name: Get suffix for artifact name
# This is needed set a valid name for the artifact in the upload step
# It helps to avoid the error:
# `The artifact name is not valid: golangci-lint-report-core/scripts Forward slash /`
id: suffix
shell: bash
run: |
if [[ "${{ inputs.go-directory }}" =~ "/" ]]; then
suffix=$(echo "${{ inputs.go-directory }}" | tr '/' '-')
echo "Updated suffix for '${{ inputs.go-directory }}' to '${suffix}'
else
suffix=$(echo "${{ inputs.go-directory }}")
echo "No need to update suffix for '${{ inputs.go-directory }}'"
fi
echo "suffix=${suffix}" | tee -a $GITHUB_OUTPUT
- name: Store lint report artifact
if: always()
uses: actions/[email protected]
with:
name: golangci-lint-report-${{ inputs.go-directory }}
name: golangci-lint-report-${{ steps.suffix.outputs.suffix }}
# The ./ is needed to preserve the valid pattern for the artifact path
path: ./${{ inputs.go-directory }}/${{ inputs.go-directory }}_golangci-lint-report.xml
path: ./${{ inputs.go-directory }}/golangci-lint-report.xml
9 changes: 7 additions & 2 deletions .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ jobs:

scan:
name: SonarQube Scan
needs: [core]
needs: [core, golangci]
if: ${{ always() && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
Expand All @@ -414,15 +414,18 @@ jobs:
run: |
# Check and assign paths for coverage/test reports in go_core_tests_logs
if [ -d "go_core_tests_logs" ]; then
echo "Found go_core_tests_logs"
sonarqube_coverage_report_paths=$(find go_core_tests_logs -name coverage.txt | paste -sd "," -)
sonarqube_tests_report_paths=$(find go_core_tests_logs -name output.txt | paste -sd "," -)
else
echo "Did not find go_core_tests_logs"
sonarqube_coverage_report_paths=""
sonarqube_tests_report_paths=""
fi
# Check and assign paths for coverage/test reports in go_core_tests_integration_logs
if [ -d "go_core_tests_integration_logs" ]; then
echo "Found go_core_tests_integration_logs"
integration_coverage_paths=$(find go_core_tests_integration_logs -name coverage.txt | paste -sd "," -)
integration_tests_paths=$(find go_core_tests_integration_logs -name output.txt | paste -sd "," -)
# Append to existing paths if they are set, otherwise assign directly
Expand All @@ -431,9 +434,11 @@ jobs:
fi
# Check and assign paths for lint reports
if [ -d "golangci-lint-report" ]; then
if [[ -d "golangci-lint-report"* ]]; then
echo "Found golangci-lint-report*"
sonarqube_lint_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,")
else
echo "Did not find golangci-lint-report*"
sonarqube_lint_report_paths=""
fi
Expand Down

0 comments on commit 258cc57

Please sign in to comment.