[DEV-000000] DO NOT MERGE IT - TESTING #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI - iOS | |
on: | |
pull_request: | |
types: [opened, edited, reopened, synchronize] | |
workflow_dispatch: | |
env: | |
GH_TOKEN: ${{ secrets.GIT_TOKEN_SECRET }} | |
OWNER: ${{ github.repository_owner }} | |
REPO: ${{ github.event.repository.name }} | |
PR_NUMBER: ${{ github.event.number }} | |
SONAR_HOST_URL: "https://sonarqube.trustly.one" | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_SECRET }} | |
SONAR_PROJECT_KEY: "trustly-ios" | |
SONAR_PROJECT_NAME: "trustly-ios" | |
jobs: | |
SonarQube: | |
runs-on: macOS-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install dependencies | |
run: | | |
# Update Homebrew | |
brew update | |
# Install SwiftLint | |
brew install swiftlint | |
# Install Tailor | |
brew install tailor | |
# Install xcpretty | |
sudo gem install -n /usr/local/bin xcpretty | |
# Install Lizard | |
brew install lizard | |
# Ensure xcodebuild is available (part of Xcode Command Line Tools) | |
xcode-select --install || echo "Xcode Command Line Tools already installed" | |
# Install NVM (Node Version Manager) | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash | |
# Source nvm to make it available in the current session | |
source ~/.bash_profile || source ~/.zshrc | |
# Install a specific version of Node.js (example: v16) | |
nvm install 16 | |
nvm use 16 | |
# Optionally, you can set a default version | |
nvm alias default 16 | |
# Verify Node and NVM installation | |
node -v | |
npm -v | |
- name: Clean Xcode Caches | |
run: | | |
# Remove Xcode caches | |
rm -rf ~/Library/Caches/com.apple.dt.Xcode | |
# Remove Xcode derived data | |
rm -rf ~/Library/Developer/Xcode/DerivedData | |
# Remove Xcode build caches | |
rm -rf ~/Library/Developer/Xcode/Archives | |
rm -rf ~/Library/Developer/Xcode/iOS\ Device\ Logs | |
# Optionally: Remove Xcode preferences | |
rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist | |
echo "Xcode caches and temporary files cleared!" | |
- name: Run Sonar-Swift Script | |
run: | | |
chmod +x ./run-sonar-swift.sh | |
./run-sonar-swift.sh | |
- name: Verify Coverage Report | |
run: | | |
if [ -f "sonar-reports/generic-coverage.xml" ]; then | |
echo "Coverage report generated successfully: sonar-reports/generic-coverage.xml" | |
else | |
echo "Coverage report not found!" && exit 1 | |
fi | |
- name: Run SonarQube Analysis | |
run: | | |
sonar-scanner -X \ | |
-Dsonar.host.url=${SONAR_HOST_URL} \ | |
-Dsonar.login=${SONAR_TOKEN} \ | |
-Dsonar.projectKey=${SONAR_PROJECT_KEY} \ | |
-Dsonar.projectName=${SONAR_PROJECT_NAME} \ | |
-Dsonar.pullrequest.base="${{ github.base_ref }}" \ | |
-Dsonar.pullrequest.branch="${{ github.head_ref }}" \ | |
-Dsonar.pullrequest.key="${{ github.event.pull_request.number }}" \ | |
-Dsonar.scm.revision="${{ github.event.pull_request.head.sha }}" \ | |
-Dsonar.coverageReportPaths=sonar-reports/generic-coverage.xml \ | |
-Dsonar.scm.disabled=true \ | |
-Dsonar.language=swift \ | |
-Dsonar.sources="." \ | |
-Dsonar.verbose=true |