Skip to content

Update ExecutingTestsOnDockerGithubActions.ps1 #186

Update ExecutingTestsOnDockerGithubActions.ps1

Update ExecutingTestsOnDockerGithubActions.ps1 #186

on:
workflow_dispatch:
pull_request:
push:
branches:
- '*'
paths-ignore:
- README.md
tags:
- '*'
schedule:
- cron: '0 18 * * 0'
env:
solution: ${{ github.workspace }}/Ocaramba.sln
buildPlatform: Any CPU
buildConfiguration: Release
frameworkVersion: 4.2.0
TestResultsDirWindows: D:\a\Ocaramba\Ocaramba\TestResults
CHROMEWEBDRIVER: C:\SeleniumWebDrivers\ChromeDriver
BuildVersion: 4.2.0${{ github.run_number }}
ChromeDriverVersion: 122.0.6261.9400
seleniumGridVersion: selenium-server-4.8.0.jar
seleniumGridUrl: https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.8.0/selenium-server-4.8.0.jar
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
jobs:
build_Stage_BuildTestsOnWindows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- shell: powershell
run: |
$tags = git tag --sort=-creatordate
$tag = $tags[0]
Write-Host "##vso[task.setvariable variable=frameworkVersion]$tag"
if: startsWith(github.ref, 'refs/tags/')
- shell: powershell
run: '(Get-Content ''Ocaramba.sln'' -raw) -replace [regex](''.*?'' + ''Documentation'' + (''.*?\r\n'' * (5 + 1))) | set-content ''Ocaramba.sln'''
- name: Update ChromeDriver in csproj
run: |
Get-ChildItem ./ *.csproj -recurse |
Foreach-Object {
$c = ($_ | Get-Content)
$c = $c -replace '109.0.5414.7400','${{ env.ChromeDriverVersion }}'
[IO.File]::WriteAllText($_.FullName, ($c -join "`r`n"))
}
- name: Setup nuget
uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- name: Cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}\.nuget\packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} #hash of project files
restore-keys: |
${{ runner.os }}-nuget-
- name: NuGet restore
run: nuget restore ${{ env.solution }}
- name: Set project versions
id: update
uses: vers-one/[email protected]
with:
file: |
"**/Ocaramba.csproj", "**/OcarambaLite.csproj"
version: ${{ env.frameworkVersion }}
- run: msbuild '${{ env.solution }}' /p:configuration='${{ env.buildConfiguration }}' /p:platform='${{ env.buildPlatform }}' /v:minimal
- uses: actions/upload-artifact@v4
with:
path: ./Ocaramba/bin/Release/Ocaramba.${{ env.frameworkVersion }}.nupkg
name: Ocaramba${{ env.frameworkVersion }}
- uses: actions/upload-artifact@v4
with:
path: ./Ocaramba/bin/Release/Ocaramba.${{ env.frameworkVersion }}.snupkg
name: OcarambaS${{ env.frameworkVersion }}
- uses: actions/upload-artifact@v4
with:
path: ./OcarambaLite/bin/Release/OcarambaLite.${{ env.frameworkVersion }}.nupkg
name: OcarambaLite${{ env.frameworkVersion }}
- uses: actions/upload-artifact@v4
with:
path: ./OcarambaLite/bin/Release/OcarambaLite.${{ env.frameworkVersion }}.snupkg
name: OcarambaLiteS${{ env.frameworkVersion }}
- name: Zip artifact for deployment
run: Compress-Archive -Path ./ -Destination OcarambaBuild.zip
- uses: actions/upload-artifact@v4
with:
path: OcarambaBuild.zip
name: OcarambaBuild
compression-level: 0
if: (${{ job.status }} != 'cancelled')
test_Stage_RunTestsOnDocker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: startsWith(github.ref, 'refs/tags/')
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: startsWith(github.ref, 'refs/tags/')
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/')
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ocaramba/selenium:latest
if: startsWith(github.ref, 'refs/tags/')
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install docker-compose -y
- run: docker-compose -f docker-compose.yml up -d
- shell: pwsh
run: ./ExecutingTestsOnDockerGithubActions.ps1
if: true
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: true
with:
files: |
/home/runner/work/Ocaramba/Ocaramba/TestResults/Ocaramba.Tests.Docker.xml
test_Stage_RunTestsOnLinux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: find . -name '*.csproj' -exec sed -i -e 's/109.0.5414.7400/${{ env.ChromeDriverVersion }}/g' {} \;
- uses: browser-actions/setup-chrome@v1
if: true
- run: chrome --version
- uses: nanasess/setup-chromedriver@v2
- run: |
ls
export ASPNETCORE_ENVIRONMENT=Linux
echo $ASPNETCORE_ENVIRONMENT
sudo apt-get install google-chrome-stable
sed -i '/Documentation/,+5 d' ./Ocaramba.sln
- run: dotnet build ./Ocaramba.sln --configuration ${{ env.buildConfiguration }}
- shell: pwsh
run: ./ExecutingTestsOnLinuxAzure.ps1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: true
with:
files: |
/home/runner/work/Ocaramba/Ocaramba/TestResults/Ocaramba.Tests.netcoreapp.xml
check_name: ExecutingTestsOnLinuxAzure
test_Stage_RunTestsOnLinuxBrowserStack:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- run: |
ls
export ASPNETCORE_ENVIRONMENT=Linux
echo $ASPNETCORE_ENVIRONMENT
sed -i '/Documentation/,+5 d' ./Ocaramba.sln
- run: dotnet build ./Ocaramba.sln --configuration ${{ env.buildConfiguration }}
- uses: browser-actions/setup-chrome@v1
if: true
- run: chrome --version
- uses: nanasess/setup-chromedriver@v2
- shell: pwsh
if: true
env:
MAPPED_ENV_BROWSERSTACKKEY: ${{ secrets.BROWSERSTACKKEY }}
MAPPED_ENV_BROWSERSTACKUSER: ${{ secrets.BROWSERSTACKUSER }}
MAPPED_ENV_TESTINGBOTKEY: ${{ env.testingbotkey }}
MAPPED_ENV_TESTINGBOTSECRET: ${{ env.testingbotsecret }}
MAPPED_ENV_SAUCELABSACCESSKEY: ${{ env.saucelabsaccessKey }}
MAPPED_ENV_SAUCELABSUSERNAME: ${{ env.saucelabsusername }}
run: ./ExecutingTestsOnLinuxBrowserStackGithubActions.ps1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: false
with:
files: |
/home/runner/work/Ocaramba/Ocaramba/TestResults/BrowserStacknetcoreapp.xml
check_name: test_Stage_RunTestsOnLinuxBrowserStack
test_Stage_RunTestsOnWindowsCore1:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions1.ps1
- run: Get-ChildItem .\ -Recurse
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.netcoreapp.trx
check_name: ExecutingTestsOnWindowsGithubActions1
- name: Zip artifact
run: Compress-Archive -Path D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.NUnitExtentReports\bin\Release\net8.0\TestOutput -Destination ExtentReports_${{ github.run_id }}.zip
- uses: actions/upload-artifact@v4
with:
path: ExtentReports_${{ github.run_id }}.zip
name: ExtentTestReport
if: always()
test_Stage_RunTestsOnWindowsCore2:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions2.ps1
- run: Get-ChildItem .\ -Recurse
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: |
${{ env.TestResultsDirWindows }}\Ocaramba.Tests.netcoreapp.xml
${{ env.TestResultsDirWindows }}\Ocaramba.Tests.EdgeChrominum.xml
check_name: ExecutingTestsOnWindowsGithubActions2
test_Stage_RunTestsOnWindowsFramework:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions3.ps1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.net4.xml
check_name: ExecutingTestsOnWindowsGithubActions3
test_Stage_RunTestsOnWindowsBrowserStack:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions4.ps1
env:
MAPPED_ENV_BROWSERSTACKKEY: ${{ env.browserstackkey }}
MAPPED_ENV_BROWSERSTACKUSER: ${{ env.browserstackuser }}
MAPPED_ENV_TESTINGBOTKEY: ${{ env.testingbotkey }}
MAPPED_ENV_TESTINGBOTSECRET: ${{ env.testingbotsecret }}
MAPPED_ENV_SAUCELABSACCESSKEY: ${{ env.saucelabsaccessKey }}
MAPPED_ENV_SAUCELABSUSERNAME: ${{ env.saucelabsusername }}
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.BrowserStack.xml
check_name: ExecutingTestsOnWindowsGithubActions4
test_Stage_RunTestsSeleniumGrid:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions5.ps1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: |
${{ env.TestResultsDirWindows }}\Ocaramba.Tests.NUnitGrid.xml
${{ env.TestResultsDirWindows }}\Ocaramba.Tests.CloudProviderCrossBrowserGrid.xml
check_name: ExecutingTestsOnWindowsGithubActions5
test_Stage_RunTestsOnWindowsSaucelabs:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v2
with:
nuget-version: latest
- uses: actions/download-artifact@v4
with:
name: OcarambaBuild
- run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./
- run: ./ExecutingTestsOnWindowsGithubActions6.ps1
env:
MAPPED_ENV_BROWSERSTACKKEY: ${{ env.browserstackkey }}
MAPPED_ENV_BROWSERSTACKUSER: ${{ env.browserstackuser }}
MAPPED_ENV_TESTINGBOTKEY: ${{ env.testingbotkey }}
MAPPED_ENV_TESTINGBOTSECRET: ${{ env.testingbotsecret }}
MAPPED_ENV_SAUCELABSACCESSKEY: ${{ env.saucelabsaccessKey }}
MAPPED_ENV_SAUCELABSUSERNAME: ${{ env.saucelabsusername }}
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: |
${{ env.TestResultsDirWindows }}\Ocaramba.Tests.saucelabsnet472.xml
check_name: ExecutingTestsOnWindowsGithubActions6
release_Stage_PublishNuget:
runs-on: windows-latest
needs:
- build_Stage_BuildTestsOnWindows
- test_Stage_RunTestsOnDocker
- test_Stage_RunTestsOnLinux
- test_Stage_RunTestsOnLinuxBrowserStack
- test_Stage_RunTestsOnWindowsCore1
- test_Stage_RunTestsOnWindowsCore2
- test_Stage_RunTestsOnWindowsFramework
- test_Stage_RunTestsOnWindowsBrowserStack
- test_Stage_RunTestsSeleniumGrid
- test_Stage_RunTestsOnWindowsSaucelabs
steps:
- uses: actions/checkout@v4
- shell: powershell
run: |
$tags = git tag --sort=-creatordate
$tag = $tags[0]
Write-Host "##vso[task.setvariable variable=frameworkVersion]$tag"
if: startsWith(github.ref, 'refs/tags/')
- uses: actions/download-artifact@v4
with:
name: Ocaramba${{ env.frameworkVersion }}
- uses: actions/download-artifact@v4
with:
name: OcarambaS${{ env.frameworkVersion }}
- uses: actions/download-artifact@v4
with:
name: OcarambaLite${{ env.frameworkVersion }}
- uses: actions/download-artifact@v4
with:
name: OcarambaLiteS${{ env.frameworkVersion }}
- run: Get-ChildItem ./ -Recurse
- name: Push Nuget Package
run: dotnet push .\Ocaramba\Ocaramba\Ocaramba.${{ env.frameworkVersion }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
if: (success() && startsWith(github.ref, 'refs/tags/'))
- name: Push Nuget Package
run: dotnet push .\Ocaramba\Ocaramba\OcarambaLite.${{ env.frameworkVersion }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
if: (success() && startsWith(github.ref, 'refs/tags/'))