Update tests to run against GitHub actions #6
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: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: choice | |
description: 'App environment' | |
required: true | |
default: 'stage' | |
options: | |
- prod | |
- stage | |
jobs: | |
build-and-test: | |
name: Build solution and run tests | |
runs-on: windows-latest | |
concurrency: test-windows-${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }} | |
env: | |
BUILD_CONFIGURATION: Release | |
SOLUTION_NAME: Aquality.WinAppDriver.Template/Aquality.WinAppDriver.Template.sln | |
ALLURE_RESULTS: Aquality.WinAppDriver.Template/Aquality.WinAppDriver.Template.SpecFlow/bin/Release/net8.0/allure-results | |
ENVIRONMENT: ${{ github.event.inputs.environment == '' && 'stage' || github.event.inputs.environment }} | |
isRemote: false | |
outputs: | |
dotnet_tests: ${{ steps.dotnet_tests.outcome }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- name: Build | |
run: dotnet build ${{ env.SOLUTION_NAME }} -c ${{ env.BUILD_CONFIGURATION }} | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
node-version: 20.x | |
- name: Install Appium Server and Windows Application Driver | |
run: | | |
echo "Installing Appium" | |
npm install -g appium@next | |
appium --version | |
echo "Appium installed" | |
echo "Installing and Running Appium doctor" | |
npm install -g [email protected] | |
npm install -g [email protected] | |
appium-doctor | |
echo "Appium doctor installed and executed" | |
echo "Installing Appium Windows Driver" | |
appium driver install --source=npm appium-windows-driver | |
appium driver list | |
echo "Appium Windows Driver installed" | |
- name: Start Appium Server | |
shell: cmd | |
run: | | |
echo "Starting Appium server" | |
start cmd.exe @cmd /k "appium" | |
echo "Appium server started" | |
- name: Execute Windows tests | |
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-windows | |
path: ${{ env.ALLURE_RESULTS }} | |
deploy-report: | |
if: always() | |
name: Generate and deploy Allure Report | |
needs: [build-and-test] | |
runs-on: ubuntu-latest | |
env: | |
GH_PAGES_URL: https://aquality-automation.github.io/aquality-winappdriver-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 Windows tests results artifacts | |
if: always() | |
uses: actions/download-artifact@master | |
with: | |
name: allure-results-windows | |
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.outputs.dotnet_tests == 'success' && 'success' || 'failure' }} | |
sha: ${{github.event.pull_request.head.sha || github.sha}} | |
target_url: ${{ env.GH_PAGES_URL }}/${{github.run_number}}/ |