Run tests with allure report #21
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: Run tests with allure report | |
on: | |
pull_request: | |
branches: | |
- master | |
paths: | |
- 'Aquality.Appium.Mobile.Template/**' | |
- 'scripts/**' | |
push: | |
branches: [ master ] | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: choice | |
description: 'App environment' | |
required: true | |
default: 'stage' | |
options: | |
- prod | |
- stage | |
jobs: | |
build-and-test-android: | |
env: | |
platformName: android | |
BUILD_CONFIGURATION: Release | |
SOLUTION_NAME: Aquality.Appium.Mobile.Template/Aquality.Appium.Mobile.Template.sln | |
ALLURE_RESULTS: Aquality.Appium.Mobile.Template/Aquality.Appium.Mobile.Template.SpecFlow/bin/android/Release/net6.0/allure-results | |
ENVIRONMENT: ${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }} | |
ANDROID_PROFILE: Nexus 6 | |
ANDROID_TARGET: google_apis | |
ANDROID_API_LEVEL: 28 | |
ANDROID_ARCH: x86_64 | |
concurrency: test-android-${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }} | |
name: Run tests against Android | |
runs-on: macos-latest | |
outputs: | |
dotnet_tests: ${{ steps.dotnet_tests.outcome }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 6.0.x | |
- name: Install and Run Appium Server | |
run: | | |
chmod +x ./scripts/PrepareAppiumServerForAndroid.sh | |
./scripts/PrepareAppiumServerForAndroid.sh | |
- name: Build | |
run: dotnet build ${{ env.SOLUTION_NAME }} -c ${{ env.BUILD_CONFIGURATION }} | |
- name: Test against Android | |
id: dotnet_tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ env.ANDROID_API_LEVEL }} | |
target: ${{ env.ANDROID_TARGET }} | |
arch: ${{ env.ANDROID_ARCH }} | |
profile: ${{ env.ANDROID_PROFILE }} | |
script: dotnet test --no-build ${{ env.SOLUTION_NAME }} -c ${{ env.BUILD_CONFIGURATION }} | |
- name: Upload results as artifacts | |
if: always() | |
uses: actions/upload-artifact@master | |
with: | |
name: allure-results-android | |
path: ${{ env.ALLURE_RESULTS }} | |
build-and-test-ios: | |
env: | |
platformName: ios | |
BUILD_CONFIGURATION: Release | |
SOLUTION_NAME: Aquality.Appium.Mobile.Template/Aquality.Appium.Mobile.Template.sln | |
ALLURE_RESULTS: Aquality.Appium.Mobile.Template/Aquality.Appium.Mobile.Template.SpecFlow/bin/ios/Release/net6.0/allure-results | |
ENVIRONMENT: ${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }} | |
IOS_SIM_MODEL: iPhone SE (3rd generation) | |
concurrency: test-ios-${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }} | |
name: Run tests against iOS | |
runs-on: macos-latest | |
outputs: | |
dotnet_tests: ${{ steps.dotnet_tests.outcome }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install and Run Appium Server | |
run: | | |
chmod +x ./scripts/PrepareAppiumServerForIos.sh | |
./scripts/PrepareAppiumServerForIos.sh | |
- name: Setup iOS simulator | |
if: always() | |
uses: futureware-tech/simulator-action@v2 | |
with: | |
model: ${{ env.IOS_SIM_MODEL }} | |
shutdown_after_job: false | |
- name: "Wait for simulator to be ready" | |
run: | | |
SIM_UID="$(xcrun simctl list devices | grep -m 1 "$IOS_SIM_MODEL" | grep -E -o -i "([0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12})")" | |
xcrun simctl bootstatus $SIM_UID | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 6.0.x | |
- name: Build | |
run: dotnet build ${{ env.SOLUTION_NAME }} -c ${{ env.BUILD_CONFIGURATION }} | |
- name: Test against iOS | |
if: always() | |
id: dotnet_tests | |
run: dotnet test --no-build ${{ env.SOLUTION_NAME }} -c ${{ env.BUILD_CONFIGURATION }} | |
- name: Upload results as artifacts | |
if: always() | |
uses: actions/upload-artifact@master | |
with: | |
name: allure-results-ios | |
path: ${{ env.ALLURE_RESULTS }} | |
deploy-report: | |
if: always() | |
name: Generate and deploy Allure Report | |
needs: [build-and-test-android, build-and-test-ios] | |
runs-on: ubuntu-latest | |
env: | |
GH_PAGES_URL: https://aquality-automation.github.io/aquality-appium-mobile-dotnet-template | |
steps: | |
- name: Get Allure history | |
uses: actions/checkout@v3 | |
if: always() | |
continue-on-error: true | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Download Android results artifacts | |
if: always() | |
uses: actions/download-artifact@master | |
with: | |
name: allure-results-android | |
path: target/allure-results | |
- name: Download iOS results artifacts | |
if: always() | |
uses: actions/download-artifact@master | |
with: | |
name: allure-results-ios | |
path: target/allure-results | |
- name: Generate Allure Report | |
uses: simple-elf/allure-report-action@master | |
if: always() | |
id: allure-report | |
with: | |
allure_results: target/allure-results | |
gh_pages: gh-pages | |
allure_report: allure-report | |
allure_history: allure-history | |
keep_reports: 20 | |
- name: Deploy report to Github Pages | |
if: always() | |
uses: peaceiris/actions-gh-pages@v2 | |
env: | |
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PUBLISH_BRANCH: gh-pages | |
PUBLISH_DIR: allure-history | |
- name: Post the link to the report | |
if: always() | |
uses: Sibz/github-status-action@v1 | |
with: | |
authToken: ${{secrets.GITHUB_TOKEN}} | |
context: 'Test report' | |
state: ${{ needs.build-and-test-android.outputs.dotnet_tests == 'success' && needs.build-and-test-ios.outputs.dotnet_tests == 'success' && 'success' || 'failure' }} | |
sha: ${{github.event.pull_request.head.sha || github.sha}} | |
target_url: ${{ env.GH_PAGES_URL }}/${{github.run_number}}/ |