Skip to content

TestNG template project with allure report #39

TestNG template project with allure report

TestNG template project with allure report #39

name: Run tests with allure report
on:
pull_request:
branches:
- master
paths:
- 'aquality-appium-mobile-template/**'
- 'aquality-appium-mobile-template-cucumber/**'
- 'aquality-selenium-template-testng/**'
- '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:
CUCUMBER_ALLURE_RESULTS: aquality-appium-mobile-template-cucumber/target/allure-results
TESTNG_ALLURE_RESULTS: aquality-appium-mobile-template-testng/target/allure-results
SUBPROJECT_NAME: aquality-appium-mobile-template-cucumber
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:
maven_tests: ${{ steps.maven_tests.outcome }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: maven
- name: Install and Run Appium Server
run: |
chmod +x ./scripts/PrepareAppiumServerForAndroid.sh
./scripts/PrepareAppiumServerForAndroid.sh
- name: Test against Android
id: maven_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: mvn test -DisRemote=true -DplatformName=android
- name: Copy TestNG allure result to the Cucumber allure result
if: always()
run: cp -r ${{ env.TESTNG_ALLURE_RESULTS }}/. ${{ env.CUCUMBER_ALLURE_RESULTS }}
- name: Upload results as artifacts
if: always()
uses: actions/upload-artifact@master
with:
name: allure-results-android
path: ${{ env.SUBPROJECT_NAME }}/target/allure-results
build-and-test-ios:
env:
CUCUMBER_ALLURE_RESULTS: aquality-appium-mobile-template-cucumber/target/allure-results
TESTNG_ALLURE_RESULTS: aquality-appium-mobile-template-testng/target/allure-results
SUBPROJECT_NAME: aquality-appium-mobile-template-cucumber
ENVIRONMENT: ${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }}
IOS_SIM_MODEL: iPhone 8
concurrency: test-ios-${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }}
name: Run tests against iOS
runs-on: macos-latest
outputs:
maven_tests: ${{ steps.maven_tests.outcome }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: maven
- 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 }}
- 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: Test against iOS
if: always()
id: maven_tests
run: mvn test -DisRemote=true -DplatformName=ios
- name: Copy TestNG allure result to the Cucumber allure result
if: always()
run: cp -r ${{ env.TESTNG_ALLURE_RESULTS }}/. ${{ env.CUCUMBER_ALLURE_RESULTS }}
- name: Upload results as artifacts
if: always()
uses: actions/upload-artifact@master
with:
name: allure-results-ios
path: ${{ env.SUBPROJECT_NAME }}/target/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-java-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.maven_tests == 'success' && needs.build-and-test-ios.outputs.maven_tests == 'success' && 'success' || 'failure' }}
sha: ${{github.event.pull_request.head.sha || github.sha}}
target_url: ${{ env.GH_PAGES_URL }}/${{github.run_number}}/