Resolve #272 - Try out BrowserStack SDK #106
Workflow file for this run
This file contains hidden or 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: Cross-browser testing | |
| concurrency: | |
| group: ${{ github.workflow }} | |
| cancel-in-progress: false | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| pull_request: | |
| branches: [ "master" ] | |
| schedule: | |
| - cron: "27 20 * * 0" | |
| jobs: | |
| # Summary: | |
| # | |
| # * Installs and configures the environment | |
| # * Builds the solution in Debug configuration | |
| # * Runs just the Selenium tests | |
| # * In Debug configuration (.NET tests) | |
| # * Using the BrowserStack browser configuration | |
| browser_tests: | |
| strategy: | |
| max-parallel: 1 | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - browserStackConfig: chromeLatest | |
| # - browserStackConfig: chromeOld | |
| # - browserStackConfig: edgeLatest | |
| # - browserStackConfig: firefoxLatest | |
| # - browserStackConfig: firefoxOld | |
| # - browserStackConfig: safari17 | |
| # - browserStackConfig: safari26 | |
| name: Run tests | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 30 | |
| env: | |
| RunNumber: ${{ github.run_number }}.${{ github.run_attempt }} | |
| VersionSuffix: crossbrowser.${{ github.run_number }} | |
| Configuration: Release | |
| Tfm: net8.0 | |
| DotnetVersion: 8.0.x | |
| BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} | |
| BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | |
| BROWSERSTACK_BUILD_IDENTIFIER: gh-actions-cbt.${{ github.run_number }}.${{ github.run_attempt }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # Install build dependencies | |
| - name: Install .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DotnetVersion }} | |
| - name: Install Node.js for building JSON-to-HTML report converter | |
| uses: actions/setup-node@v6.2.0 | |
| # Environment setup pre-build | |
| # Note that the BrowserStack SDK is presently incompatible with .NET 10 | |
| - name: Activate BrowserStack | |
| run: | | |
| cp Tests/CSF.Screenplay.Selenium.Tests/Tools/browserstack.${{ matrix.browserStackConfig }}.yml Tests/CSF.Screenplay.Selenium.Tests/browserstack.yml | |
| cp Tests/CSF.Screenplay.Selenium.Tests/Tools/BrowserStack.props Tests/CSF.Screenplay.Selenium.Tests/BrowserStack.props | |
| - name: Force .NET 8 with global.json | |
| run: | | |
| echo '{ "sdk": { "version": "8.0.418", "rollForward": "latestFeature" } }' > global.json | |
| - name: Restore Node modules | |
| run: | | |
| cd CSF.Screenplay.JsonToHtmlReport.Template/src | |
| npm ci | |
| cd ../.. | |
| - name: Restore NuGet packages | |
| run: dotnet restore | |
| # Build and test the solution | |
| - name: Build the solution | |
| run: dotnet build -c ${{ env.Configuration }} | |
| - name: Run .NET Selenium tests only | |
| id: dotnet_tests | |
| run: dotnet test -c ${{ env.Configuration }} --no-build --filter TestCategory=WebDriver Tests/CSF.Screenplay.Selenium.Tests | |
| continue-on-error: true | |
| # Post-test tasks (artifacts, overall status) | |
| - name: Upload Screenplay JSON report artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Screenplay JSON reports ${{ matrix.browserStackConfig }} | |
| path: Tests/CSF.Screenplay.Selenium.Tests/**/ScreenplayReport_*.json | |
| - name: Convert Screenplay reports to HTML | |
| continue-on-error: true | |
| run: | | |
| for report in $(find Tests/CSF.Screenplay.Selenium.Tests/ -type f -name "ScreenplayReport_*.json") | |
| do | |
| reportDir=$(dirname "$report") | |
| outputFile="$reportDir/ScreenplayReport.html" | |
| dotnet run --no-build --framework $Tfm -c ${{ env.Configuration }} --project CSF.Screenplay.JsonToHtmlReport --ReportPath "$report" --OutputPath "$outputFile" | |
| done | |
| - name: Upload Screenplay HTML report artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Screenplay HTML reports ${{ matrix.browserStackConfig }} | |
| path: Tests/**/ScreenplayReport.html | |
| - name: Fail the build if any test failures | |
| if: steps.dotnet_tests.outcome == 'failure' | |
| run: | | |
| echo "Failing the build due to test failures" | |
| exit 1 |