diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 5e879ff4dc..bc4595496f 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -1,27 +1,32 @@ name: Code Style Checks on: + workflow_dispatch: push: branches: - main + - release-* pull_request: - branches: - - main + paths: + - '**.cs' + - '**.csproj' + - '**.sln' -jobs: - build: - - runs-on: windows-latest +env: + DOTNET_VERSION: '10.0.x' +jobs: + code-style: + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: We shouldn't mention puppeteer + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Check formatting + run: dotnet format ./src/PlaywrightSharp.sln --verify-no-changes + - name: Check for puppeteer references run: | chmod +x ./.github/workflows/no-puppeteer.sh ./.github/workflows/no-puppeteer.sh - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.100 - - name: Check formatting - run: dotnet tool update dotnet-format --tool-path ./dotnet-format/ && ./dotnet-format/dotnet-format -f ./src/ --check -v:diag diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000000..cb5db9612f --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,106 @@ +name: build + +on: + workflow_dispatch: + push: + branches: + - main + - release-* + merge_group: + pull_request: + paths: + - '**.yml' + - '**.cs' + - '**.json' + - '**.csproj' + - '**.runsettings' + +env: + DOTNET_VERSION: '10.0.x' + +jobs: + build: + name: ${{ matrix.browser }}-${{ matrix.mode }}-${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + browser: chromium + mode: headless + - os: ubuntu-latest + browser: chromium + mode: headful + - os: windows-latest + browser: chromium + mode: headless + - os: windows-latest + browser: chromium + mode: headful + - os: ubuntu-latest + browser: firefox + mode: headless + - os: ubuntu-latest + browser: firefox + mode: headful + - os: windows-latest + browser: firefox + mode: headless + - os: windows-latest + browser: firefox + mode: headful + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Install system dependencies (Linux) + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y libgbm-dev xvfb + - name: Generate HTTPS dev certificate (Linux) + if: matrix.os == 'ubuntu-latest' + run: | + dotnet dev-certs https --clean + dotnet dev-certs https -ep src/PlaywrightSharp.TestServer/testCert.cer + sudo openssl x509 -inform der -in src/PlaywrightSharp.TestServer/testCert.cer -out /usr/local/share/ca-certificates/testCert.crt -outform pem + sudo update-ca-certificates + - name: Generate HTTPS dev certificate (Windows) + if: matrix.os == 'windows-latest' + run: | + New-SelfSignedCertificate -Subject "localhost" -FriendlyName "PlaywrightSharp" -CertStoreLocation "cert:\CurrentUser\My" + Get-ChildItem -Path cert:\CurrentUser\my | where { $_.friendlyname -eq "PlaywrightSharp" } | Export-Certificate -FilePath $env:GITHUB_WORKSPACE\src\PlaywrightSharp.TestServer\testCert.cer + - name: Check formatting + if: ${{ matrix.os == 'ubuntu-latest' && matrix.browser == 'chromium' && matrix.mode == 'headless' }} + run: dotnet format ./src/PlaywrightSharp.sln --verify-no-changes + - name: Check for puppeteer references + if: ${{ matrix.os == 'ubuntu-latest' && matrix.browser == 'chromium' && matrix.mode == 'headless' }} + run: | + chmod +x ./.github/workflows/no-puppeteer.sh + ./.github/workflows/no-puppeteer.sh + - name: Build + run: dotnet build ./src/PlaywrightSharp.sln + - name: Test (Linux headless) + if: ${{ matrix.os == 'ubuntu-latest' && matrix.mode == 'headless' }} + env: + PRODUCT: ${{ matrix.browser == 'chromium' && 'CHROMIUM' || 'FIREFOX' }} + HEADLESS: true + run: | + dotnet test ./src/PlaywrightSharp.Tests/PlaywrightSharp.Tests.csproj --filter Category=${{ matrix.browser }} -c Debug -f net10.0 -s src/PlaywrightSharp.Tests/test.runsettings + - name: Test (Linux headful) + if: ${{ matrix.os == 'ubuntu-latest' && matrix.mode == 'headful' }} + env: + PRODUCT: ${{ matrix.browser == 'chromium' && 'CHROMIUM' || 'FIREFOX' }} + HEADLESS: false + run: | + xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- dotnet test ./src/PlaywrightSharp.Tests/PlaywrightSharp.Tests.csproj --filter Category=${{ matrix.browser }} -c Debug -f net10.0 -s src/PlaywrightSharp.Tests/test.runsettings + - name: Test (Windows) + if: matrix.os == 'windows-latest' + env: + PRODUCT: ${{ matrix.browser == 'chromium' && 'CHROMIUM' || 'FIREFOX' }} + HEADLESS: ${{ matrix.mode == 'headless' && 'true' || 'false' }} + run: | + dotnet test ./src/PlaywrightSharp.Tests/PlaywrightSharp.Tests.csproj --filter Category=${{ matrix.browser }} -c Debug -f net10.0 -s src/PlaywrightSharp.Tests/test.runsettings diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml new file mode 100644 index 0000000000..7d129d6e51 --- /dev/null +++ b/.github/workflows/publish-nuget.yml @@ -0,0 +1,33 @@ +name: PushToNugetOrg + +on: + workflow_dispatch: + push: + tags: + - v* + +env: + DOTNET_VERSION: '10.0.x' + +jobs: + PushToNugetOrg: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Install dependencies + run: | + dotnet restore ./src/PlaywrightSharp.sln + dotnet dev-certs https -ep src/PlaywrightSharp.TestServer/testCert.cer + - name: Build + run: | + dotnet build ./src/PlaywrightSharp.sln --configuration Release --no-restore + - name: NugetPush to nuget.org + env: + NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_API_KEY }} + if: env.NUGET_TOKEN_EXISTS != '' + run: | + dotnet nuget push ./src/PlaywrightSharp/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json diff --git a/src/PlaywrightSharp.Tests/test.runsettings b/src/PlaywrightSharp.Tests/test.runsettings new file mode 100644 index 0000000000..2dca5a1aa5 --- /dev/null +++ b/src/PlaywrightSharp.Tests/test.runsettings @@ -0,0 +1,7 @@ + + + + + 3600000 + +