From 70f942f045f45349593ad77f21dad94c8686c1b2 Mon Sep 17 00:00:00 2001 From: Alexandr Yepishev Date: Wed, 27 Nov 2024 18:46:17 +0000 Subject: [PATCH] Update paths to linter reports --- .github/actions/golangci-lint/action.yml | 31 ++++++++++++++++++++---- .github/workflows/ci-core.yml | 19 ++++++++++----- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/.github/actions/golangci-lint/action.yml b/.github/actions/golangci-lint/action.yml index 73ae4add53b..19bb978fdbf 100644 --- a/.github/actions/golangci-lint/action.yml +++ b/.github/actions/golangci-lint/action.yml @@ -57,16 +57,37 @@ 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 + if: always() + # This validation is needed to set a valid name for the artifact suffix in the following "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: | + echo "Validating if '${{ inputs.go-directory }}' is a valid artifact suffix (no slashes)" + go_directory="${{ inputs.go-directory }}" + if [[ $go_directory == *\/* ]]; then + suffix=$(echo "${go_directory}" | tr '/' '-') + echo "Updated '${{ inputs.go-directory }}' to a valid artifact suffix '${suffix}'" + else + suffix="$go_directory" + echo "No need to update artifact suffix '${go_directory}'" + fi + echo "suffix=${suffix}" | tee -a $GITHUB_OUTPUT - name: Store lint report artifact if: always() uses: actions/upload-artifact@v4.4.3 with: - name: golangci-lint-report-${{ inputs.go-directory }} + # The workflows may generate multiple lint reports, + # so we need to add a suffix to the name of the artifact + # to avoid duplication-related errors + 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 diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index 9859c1ad895..3e5dd93afce 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -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: @@ -414,15 +414,20 @@ 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 "," -) + echo "Coverage report paths: $sonarqube_coverage_report_paths" + echo "Tests report paths: $sonarqube_tests_report_paths" 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 @@ -431,11 +436,13 @@ jobs: fi # Check and assign paths for lint reports - if [ -d "golangci-lint-report" ]; then - sonarqube_lint_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,") - else - sonarqube_lint_report_paths="" - fi + for golang_lint_artifact in golangci-lint-report* + do + echo "Found golangci-lint-report artifacts" + sonarqube_lint_report_paths=$(find -type f -name 'golangci-lint-report.xml' -printf "%p,") + echo "Lint report paths: $sonarqube_lint_report_paths" + break + done ARGS="" if [[ -z "$sonarqube_tests_report_paths" ]]; then