|
| 1 | +name: Cross-browser testing |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "master" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "master" ] |
| 8 | + schedule: |
| 9 | + - cron: "27 20 * * 0" |
| 10 | + |
| 11 | +jobs: |
| 12 | + |
| 13 | + # Summary: |
| 14 | + # |
| 15 | + # * Installs and configures the environment |
| 16 | + # * Builds the solution in Debug configuration |
| 17 | + # * Runs just the Selenium tests |
| 18 | + # * In Debug configuration (.NET tests) |
| 19 | + # * Using the BrowserStack browser configuration |
| 20 | + |
| 21 | + browser_tests: |
| 22 | + |
| 23 | + strategy: |
| 24 | + max-parallel: 1 |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + - browserName: Chrome |
| 29 | + browserVersion: latest-50 |
| 30 | + os: Windows |
| 31 | + osVersion: 11 |
| 32 | + - browserName: Chrome |
| 33 | + browserVersion: latest |
| 34 | + os: Windows |
| 35 | + osVersion: 11 |
| 36 | + - browserName: Edge |
| 37 | + browserVersion: latest |
| 38 | + os: Windows |
| 39 | + osVersion: 11 |
| 40 | + - browserName: Firefox |
| 41 | + browserVersion: latest |
| 42 | + os: Windows |
| 43 | + osVersion: 11 |
| 44 | + - browserName: Firefox |
| 45 | + browserVersion: latest-40 |
| 46 | + os: Windows |
| 47 | + osVersion: 11 |
| 48 | + - browserName: Safari |
| 49 | + browserVersion: 17.3 |
| 50 | + os: OS X |
| 51 | + osVersion: Sonoma |
| 52 | + - browserName: Safari |
| 53 | + browserVersion: 26.2 |
| 54 | + os: OS X |
| 55 | + osVersion: Tahoe |
| 56 | + |
| 57 | + name: Run tests |
| 58 | + runs-on: ubuntu-24.04 |
| 59 | + timeout-minutes: 30 |
| 60 | + |
| 61 | + env: |
| 62 | + RunNumber: ${{ github.run_number }}.${{ github.run_attempt }} |
| 63 | + VersionSuffix: crossbrowser.${{ github.run_number }} |
| 64 | + Configuration: Release |
| 65 | + Tfm: net8.0 |
| 66 | + DotnetVersion: 8.0.x |
| 67 | + WebDriverFactory__SelectedConfiguration: BrowserStack |
| 68 | + BSbrowserName: ${{ matrix.browserName }} |
| 69 | + BSbrowserVersion: ${{ matrix.browserVersion }} |
| 70 | + BSos: ${{ matrix.os }} |
| 71 | + BSosVersion: ${{ matrix.osVersion }} |
| 72 | + BSuserName: ${{ secrets.BROWSERSTACK_USERNAME }} |
| 73 | + BSaccessKey: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} |
| 74 | + BSprojectName: CSF.Screenplay |
| 75 | + BSbuildName: ghActionsRun.${{ github.run_number }}.${{ github.run_attempt }}_${{ matrix.browserName }}:${{ matrix.browserVersion }}_${{ matrix.os }}:${{ matrix.osVersion }} |
| 76 | + BSparallelism: 5 |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Checkout |
| 80 | + uses: actions/checkout@v4 |
| 81 | + |
| 82 | + # Install build dependencies |
| 83 | + |
| 84 | + - name: Install .NET |
| 85 | + uses: actions/setup-dotnet@v4 |
| 86 | + with: |
| 87 | + dotnet-version: ${{ env.DotnetVersion }} |
| 88 | + - name: Install Node.js for building JSON-to-HTML report converter |
| 89 | + uses: actions/setup-node@v6.2.0 |
| 90 | + |
| 91 | + # Environment setup pre-build |
| 92 | + |
| 93 | + - name: Restore .NET packages |
| 94 | + run: dotnet restore |
| 95 | + - name: Restore Node modules |
| 96 | + run: | |
| 97 | + cd CSF.Screenplay.JsonToHtmlReport.Template/src |
| 98 | + npm ci |
| 99 | + cd ../.. |
| 100 | +
|
| 101 | + # Build and test the solution |
| 102 | + |
| 103 | + - name: Build the solution |
| 104 | + run: dotnet build -c ${{ env.Configuration }} |
| 105 | + - name: Run .NET Selenium tests only |
| 106 | + id: dotnet_tests |
| 107 | + run: dotnet test -c ${{ env.Configuration }} --no-build Tests/CSF.Screenplay.Selenium.Tests -- NumberOfTestWorkers=$BSparallelism |
| 108 | + continue-on-error: true |
| 109 | + |
| 110 | + # Post-test tasks (artifacts, overall status) |
| 111 | + - name: Upload Screenplay JSON report artifact |
| 112 | + uses: actions/upload-artifact@v4 |
| 113 | + with: |
| 114 | + name: Screenplay JSON reports ${{ matrix.browserName }}_${{ matrix.browserVersion }}_${{ matrix.os }}_${{ matrix.osVersion }} |
| 115 | + path: Tests/CSF.Screenplay.Selenium.Tests/**/ScreenplayReport_*.json |
| 116 | + - name: Convert Screenplay reports to HTML |
| 117 | + continue-on-error: true |
| 118 | + run: | |
| 119 | + for report in $(find Tests/CSF.Screenplay.Selenium.Tests/ -type f -name "ScreenplayReport_*.json") |
| 120 | + do |
| 121 | + reportDir=$(dirname "$report") |
| 122 | + outputFile="$reportDir/ScreenplayReport.html" |
| 123 | + dotnet run --no-build --framework $Tfm -c ${{ env.Configuration }} --project CSF.Screenplay.JsonToHtmlReport --ReportPath "$report" --OutputPath "$outputFile" |
| 124 | + done |
| 125 | + - name: Upload Screenplay HTML report artifact |
| 126 | + uses: actions/upload-artifact@v4 |
| 127 | + with: |
| 128 | + name: Screenplay HTML reports ${{ matrix.browserName }}_${{ matrix.browserVersion }}_${{ matrix.os }}_${{ matrix.osVersion }} |
| 129 | + path: Tests/**/ScreenplayReport.html |
| 130 | + - name: Fail the build if any test failures |
| 131 | + if: steps.dotnet_tests.outcome == 'failure' |
| 132 | + run: | |
| 133 | + echo "Failing the build due to test failures" |
| 134 | + exit 1 |
0 commit comments