4242 TESTCONTAINERS_RYUK_DISABLED : " ${{ inputs.ryuk-disabled }}"
4343 RYUK_CONNECTION_TIMEOUT : " ${{ inputs.project-directory == 'modules/compose' && '5m' || '60s' }}"
4444 RYUK_RECONNECTION_TIMEOUT : " ${{ inputs.project-directory == 'modules/compose' && '30s' || '10s' }}"
45+ SHOULD_RUN_SONAR : " false"
4546 strategy :
4647 matrix :
4748 platform : ${{ fromJSON(inputs.platforms) }}
@@ -95,20 +96,35 @@ jobs:
9596 paths : " **/${{ inputs.project-directory }}/TEST-unit*.xml"
9697 if : always()
9798
99+ - name : Decide if Sonar must be run
100+ if : ${{ matrix.platform == 'ubuntu-latest' }}
101+ run : |
102+ if [[ "1.23.x" == "${{ inputs.go-version }}" ]] && \
103+ [[ "true" != "${{ inputs.rootless-docker }}" ]] && \
104+ [[ "true" != "${{ inputs.ryuk-disabled }}" ]] && \
105+ [[ "main" == "${{ github.ref_name }}" ]] && \
106+ [[ "testcontainers" == "${{ github.repository_owner }}" ]]; then
107+ echo "SHOULD_RUN_SONAR=true" >> $GITHUB_ENV
108+ fi
109+
98110 - name : Set Sonar Cloud environment variables
99- if : ${{ !inputs.rootless-docker && !inputs.ryuk-disabled && github.ref_name == 'main' && github.repository_owner == 'testcontainers ' }}
111+ if : ${{ env.SHOULD_RUN_SONAR == 'true ' }}
100112 run : |
101113 echo "PROJECT_VERSION=$(grep 'latest_version' mkdocs.yml | cut -d':' -f2 | tr -d ' ')" >> $GITHUB_ENV
102114 if [ "${{ inputs.project-directory }}" == "" ]; then
103115 echo "PROJECT_KEY=testcontainers_testcontainers-go" >> $GITHUB_ENV
104116 echo "PROJECT_NAME=testcontainers-go" >> $GITHUB_ENV
117+ echo "PROJECT_SRC_EXCLUSIONS=**/*_test.go,**/vendor/**,**/testdata/**,modules/**,examples/**,modulegen/**" >> $GITHUB_ENV
118+ echo "PROJECT_TEST_EXCLUSIONS=**/vendor/**,modules/**,examples/**,modulegen/**" >> $GITHUB_ENV
105119 else
106120 echo "PROJECT_KEY=testcontainers_testcontainers-go_$(echo ${{ inputs.project-directory }} | tr '/' '_')" >> $GITHUB_ENV
107121 echo "PROJECT_NAME=testcontainers-go-$(echo ${{ inputs.project-directory }} | tr '/' '-')" >> $GITHUB_ENV
122+ echo "PROJECT_SRC_EXCLUSIONS=**/*_test.go,**/vendor/**,**/testdata/**" >> $GITHUB_ENV
123+ echo "PROJECT_TEST_EXCLUSIONS=**/vendor/**" >> $GITHUB_ENV
108124 fi
109125
110126 - name : SonarQube Scan
111- if : ${{ !inputs.rootless-docker && !inputs.ryuk-disabled && github.ref_name == 'main' && github.repository_owner == 'testcontainers ' }}
127+ if : ${{ env.SHOULD_RUN_SONAR == 'true ' }}
112128 uses : SonarSource/sonarqube-scan-action@0303d6b62e310685c0e34d0b9cde218036885c4d # v5.0.0
113129 env :
114130 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
@@ -121,9 +137,9 @@ jobs:
121137 -Dsonar.projectVersion=${{ env.PROJECT_VERSION }}
122138 -Dsonar.project.monorepo.enabled=true
123139 -Dsonar.sources=.
124- -Dsonar.exclusions=**/*_test.go,**/vendor/**,**/testdata/**
140+ -Dsonar.exclusions=${{ env.PROJECT_SRC_EXCLUSIONS }}
125141 -Dsonar.tests=.
126142 -Dsonar.test.inclusions=**/*_test.go
127- -Dsonar.test.exclusions=**/vendor/**
143+ -Dsonar.test.exclusions=${{ env.PROJECT_TEST_EXCLUSIONS }}
128144 -Dsonar.go.coverage.reportPaths=coverage.out
129145 -Dsonar.go.tests.reportPaths=TEST-unit.xml
0 commit comments