Skip to content

Add integration UI tests #2

Add integration UI tests

Add integration UI tests #2

Workflow file for this run

name: PerformanceSuite Tests
on:
push:
branches:
- main
pull_request:
branches:
- '*'
jobs:
swiftpm-build:
runs-on: macos-13
steps:
- name: Set Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
- name: Checkout
uses: actions/checkout@v3
- name: SwiftLint
run:
Pods/SwiftLint/swiftlint
# to compile swift package we should remove workspace and xcodeproj
# otherwise xcodebuild takes schemes from them
- name: Remove workspace
run: |
rm -rf Project.xcodeproj
rm -rf Project.xcworkspace
- name: Compile
run: |
xcodebuild -scheme PerformanceSuite -destination 'generic/platform=iOS'
# restore removed files just in case it is needed for the further steps
- name: Restore workspace
run: |
git checkout -- Project.xcodeproj
git checkout -- Project.xcworkspace
unit-tests:
runs-on: macos-latest
steps:
- name: Set Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
- name: Checkout
uses: actions/checkout@v3
- name: Run Unit Tests
env:
scheme: PerformanceSuite-Unit-Tests
destination: platform=iOS Simulator,name=iPhone 14 Pro
workspace: Project.xcworkspace
run: |
xcodebuild test -scheme "$scheme" -workspace "$workspace" -destination "$destination" -test-iterations 3 -run-tests-until-failure -enableCodeCoverage YES
- name: Slather
run: |
gem install slather
slather coverage --simple-output | grep -E '^Test Coverage|^Tested ' > code_coverage.txt
slather coverage --cobertura-xml
- name: Upload code_coverage.txt
uses: actions/upload-artifact@v3
with:
name: code_coverage.txt
path: code_coverage.txt
- name: Upload cobertura.xml
uses: actions/upload-artifact@v3
with:
name: cobertura.xml
path: coverage/cobertura.xml
ui-tests:
runs-on: macos-latest
steps:
- name: Set Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
- name: Checkout
uses: actions/checkout@v3
- name: Run UI Tests
env:
scheme: PerformanceSuite-UI-UITests
destination: platform=iOS Simulator,name=iPhone 14 Pro
workspace: Project.xcworkspace
run: |
xcodebuild test -scheme "$scheme" -workspace "$workspace" -destination "$destination"
coverage-report:
runs-on: ubuntu-latest
needs: unit-tests
steps:
- name: Download cobertura.xml
uses: actions/download-artifact@v3
with:
name: cobertura.xml
- name: Code coverage markdown report
uses: irongut/[email protected]
with:
filename: cobertura.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
output: both
thresholds: '80 85'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
- name: Upload code-coverage-results.md
uses: actions/upload-artifact@v3
with:
name: code-coverage-results.md
path: code-coverage-results.md
coverage-badge:
if: github.ref == 'refs/heads/main'
needs: unit-tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: badges
- name: Download code_coverage.txt
uses: actions/download-artifact@v3
with:
name: code_coverage.txt
- name: Commit code_coverage.txt
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
if [[ `git status --porcelain` ]]; then
git add code_coverage.txt
git commit -m "Update code_coverage.txt"
git push
else
echo "No changes to code coverage"
fi
- name: Load coverage data
id: load-coverage
run: |
echo "coverage=$(cat code_coverage.txt | grep -o -E '[0-9\.]+%' | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Make Coverage Badge
uses: action-badges/[email protected]
with:
label: coverage
message: "${{ steps.load-coverage.outputs.coverage }}"
message-color: brightgreen
file-name: code_coverage.svg
badge-branch: badges
github-token: "${{ secrets.GITHUB_TOKEN }}"