Build and Analyze #665
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: Build and Analyze | |
on: | |
pull_request: | |
paths: | |
- 'SlimHUD/**' | |
- 'SlimHUDTests/**' | |
- 'SlimHUDUITests/**' | |
push: | |
paths: | |
- 'SlimHUD/**' | |
- 'SlimHUDTests/**' | |
- 'SlimHUDUITests/**' | |
branches: | |
- develop | |
workflow_dispatch: | |
concurrency: | |
group: "unitests${{ github.head_ref || github.run_id }}" | |
cancel-in-progress: true | |
env: | |
test-results-check-name: Test results | |
jobs: | |
unit-tests-run: | |
runs-on: macos-12 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Switch Xcode version | |
run: sudo xcode-select -s "/Applications/Xcode_14.2.app" | |
- name: Build and Test | |
continue-on-error: true | |
id: run-tests | |
run: | | |
xcodebuild clean test \ | |
-project SlimHUD.xcodeproj \ | |
-scheme SlimHUD-Unit-Only \ | |
-destination platform=macOS \ | |
-resultBundlePath TestResults \ | |
-test-iterations 20 -retry-tests-on-failure \ | |
CODE_SIGNING_ALLOWED=NO || exit 1 | |
- name: Post test results | |
uses: AlexPerathoner/xcresulttool-alternative-action@v0.2 | |
if: ${{ (success() || failure()) && github.event_name == 'pull_request' }} | |
with: | |
path: "TestResults.xcresult" | |
title: ${{ env.test-results-check-name }} | |
upload-bundles: never | |
show-code-coverage: true | |
- name: Generate coverage report | |
run: | | |
bash ./Configuration/xccov-to-sonarqube-generic.sh TestResults.xcresult/ > sonarqube-generic-coverage.xml | |
sed -i '' "s/projectVersion=1.0/projectVersion=$(xcrun agvtool what-version -terse) /g" sonar-project.properties | |
- name: Save coverage report | |
uses: actions/upload-artifact@master | |
with: | |
name: sonarqube-generic-coverage | |
path: sonarqube-generic-coverage.xml | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
# Disabling shallow clone is recommended for improving relevancy of reporting | |
fetch-depth: 0 | |
- name: Replace version | |
run: sed -i '' "s/projectVersion=1.0/projectVersion=$(xcrun agvtool what-version -terse)/g" sonar-project.properties | |
- uses: actions/download-artifact@master # download all previously generated artifacts | |
with: | |
name: sonarqube-generic-coverage | |
# Setup java 17 to be default (sonar-scanner requirement as of 5.x) | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' # See 'Supported distributions' for available options | |
java-version: '17' | |
- name: Setup sonarqube | |
uses: warchant/setup-sonar-scanner@v8 | |
- name: Run sonarqube | |
run: | | |
sonar-scanner -X | |
-Dsonar.login=${{ secrets.SONAR_TOKEN }} | |
- name: Check failures | |
# Flaky tests make the output status generated by xcresulttool not reliable. Using xcodebuild's status directly. | |
# This means that this workflow could and will fail if some test don't pass, even after retrying them | |
if: steps.run-tests.outcome != 'success' | |
run: exit 1 |