Skip to content

Build and Analyze

Build and Analyze #664

Workflow file for this run

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:

Check failure on line 73 in .github/workflows/xcode-build.yml

View workflow run for this annotation

GitHub Actions / Build and Analyze

Invalid workflow file

The workflow is not valid. .github/workflows/xcode-build.yml (Line: 73, Col: 14): Unexpected value '' .github/workflows/xcode-build.yml (Line: 74, Col: 9): Unexpected value 'distribution'
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