Template for a good new topic, formatted with Markdown:
ALM used - GitHub
CI system used - XCode Cloud
Languages of the repository - Swift
Error observed - No pull request summary
Steps to reproduce - Build, test and sonar analyze in XCode Cloud environment (as a post build phase - Apple Developer Documentation). Analysis is uploaded to SonarCloud successfully with Pull request reference, it is shown in SonarCloud dashboard. But report summary is not posted to Github Pull Request. It was working with Github Actions before, but stopped after migrating to XCode Cloud.
Yeah, I have succeeded to integrate Sonar with XCode Cloud. Only missing part is summary report comment in the PR
ci_post_xcodebuild.sh
#!/bin/sh
if [[ "$CI_WORKFLOW" == "Analyze branch" ]];
then
(./run_sonar_analysis_branch.sh)
elif [[ "$CI_WORKFLOW" == "Build and test" ]];
then
(./run_sonar_analysis_pr.sh)
else
echo "No test coverage analyze"
fi
run_sonar_analysis_pr.sh
#!/bin/sh
if which fastlane >/dev/null; then
cd $CI_WORKSPACE
fastlane ios testpr \
sonar_login:$SONAR_TOKEN \
workspace:$CI_WORKSPACE \
derived_data_path:$CI_DERIVED_DATA_PATH \
app_scheme:"YOUR_SCHEME" \
target_branch:$CI_PULL_REQUEST_TARGET_BRANCH \
source_branch:$CI_PULL_REQUEST_SOURCE_BRANCH \
pr_number:$CI_PULL_REQUEST_NUMBER
fi
run_sonar_analysis_branch.sh
#!/bin/sh
if which fastlane >/dev/null; then
cd $CI_WORKSPACE
fastlane ios testbranch \
sonar_login:$SONAR_TOKEN \
workspace:$CI_WORKSPACE \
derived_data_path:$CI_DERIVED_DATA_PATH \
app_scheme:"YOUR_SCHEME" \
branch_name:$CI_BRANCH
fi
SONAR_TOKEN - is an environment variable setup at XCode cloud workflow config
I didn’t see any warnings in the UI, except 1 warning in the top right “Shallow clone detected during the analysis. Some files will miss SCM information. This will affect features like auto-assignment of issues. Please configure your build to disable shallow clone.”.
Project is imported long before me, I don’t know which method is applied. I guess this was imported by website sonarcloud. Organization is still bound to the Github. We have 600+ repos and the rest are working fine. Only XCode Cloud integration does not comment anything.
I guess this is related to the GITHUB_TOKEN environment variable, so it is not present in the XCode Cloud server’s environment.
The issue was fixed by bounding project to Sonar dashboard. Project was displaying “not bound” to the Github repo, I have removed and imported as a fresh sonar project. Then the issue was resolved