From 04c8f93d933f60189b7c153ca2b28cd2c3d8171c Mon Sep 17 00:00:00 2001 From: YaroslavVlasenko Date: Fri, 5 Jun 2026 16:55:46 +0300 Subject: [PATCH 1/4] TEST: Add Selenium API tests GitHub Actions workflow --- .github/workflows/selenium-api-tests.yml | 64 ++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/selenium-api-tests.yml diff --git a/.github/workflows/selenium-api-tests.yml b/.github/workflows/selenium-api-tests.yml new file mode 100644 index 000000000..c9f8ee1ad --- /dev/null +++ b/.github/workflows/selenium-api-tests.yml @@ -0,0 +1,64 @@ +name: Selenium API tests + +# Runs the shared Selenium contract for this repo's example against the live cloud. +on: + pull_request: + branches: [main] + workflow_dispatch: + +jobs: + selenium-api-tests: + runs-on: ubuntu-latest + steps: + - name: Check out device-detection-python + uses: actions/checkout@v4 + with: + submodules: true + token: ${{ secrets.ACCESS_TOKEN }} + + - name: Check out selenium-api-tests + uses: actions/checkout@v4 + with: + repository: 51Degrees/selenium-api-tests + path: selenium-api-tests + token: ${{ secrets.ACCESS_TOKEN }} + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + + - name: Build the shared contract tests + run: dotnet build selenium-api-tests/SeleniumApiTests.csproj -c Release + + - name: Launch the example and run the contract + env: + PORT: "8097" + cloud_endpoint: https://cloud.51degrees.com/api/v4/ + resource_key: ${{ secrets.SUPER_RESOURCE_KEY }} + EXAMPLE_URL: http://localhost:8097 + EXAMPLE_LANG: python + SUPER_RESOURCE_KEY: ${{ secrets.SUPER_RESOURCE_KEY }} + run: | + # Start this repo's cloud example, pointed at the live cloud. + pushd fiftyone_devicedetection_examples + python3 -m venv .venv + .venv/bin/pip install -e . + .venv/bin/python -m fiftyone_devicedetection_examples.cloud.gettingstarted_web & + example_pid=$! + popd + for i in $(seq 1 30); do + curl -sf -o /dev/null "http://localhost:${PORT}/" && break || sleep 2 + done + # Run the shared contract against the live cloud. + printf '{ "cloud_root_url": "https://cloud.51degrees.com/", "paid_resource_key": "%s" }\n' \ + "$SUPER_RESOURCE_KEY" > "$RUNNER_TEMP/testConfig.json" + TEST_CONFIG_FILE="$RUNNER_TEMP/testConfig.json" \ + dotnet test selenium-api-tests/SeleniumApiTests.csproj -c Release --no-build \ + --filter 'FullyQualifiedName~ExampleClientSideOverride|FullyQualifiedName~ExampleRenderTests' + status=$? + kill "$example_pid" 2>/dev/null || true + exit $status From 5aa95993025dfd37d77ecd1114d7fb09fc01e783 Mon Sep 17 00:00:00 2001 From: YaroslavVlasenko Date: Fri, 5 Jun 2026 17:28:57 +0300 Subject: [PATCH 2/4] TEMP: Trigger Selenium API tests on any branch push for debugging purposes --- .github/workflows/selenium-api-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/selenium-api-tests.yml b/.github/workflows/selenium-api-tests.yml index c9f8ee1ad..c5f0d68c6 100644 --- a/.github/workflows/selenium-api-tests.yml +++ b/.github/workflows/selenium-api-tests.yml @@ -2,6 +2,7 @@ name: Selenium API tests # Runs the shared Selenium contract for this repo's example against the live cloud. on: + push: # TEMPORARY: run on any branch push (no PR needed) — remove before merge pull_request: branches: [main] workflow_dispatch: From 75a8cb65176127099941bdbfd4dbe6481b47a703 Mon Sep 17 00:00:00 2001 From: YaroslavVlasenko Date: Mon, 8 Jun 2026 12:51:14 +0300 Subject: [PATCH 3/4] TEST: Update Selenium API tests to use environment variables and refined test filter --- .github/workflows/selenium-api-tests.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/selenium-api-tests.yml b/.github/workflows/selenium-api-tests.yml index c5f0d68c6..78eb2f981 100644 --- a/.github/workflows/selenium-api-tests.yml +++ b/.github/workflows/selenium-api-tests.yml @@ -55,11 +55,10 @@ jobs: curl -sf -o /dev/null "http://localhost:${PORT}/" && break || sleep 2 done # Run the shared contract against the live cloud. - printf '{ "cloud_root_url": "https://cloud.51degrees.com/", "paid_resource_key": "%s" }\n' \ - "$SUPER_RESOURCE_KEY" > "$RUNNER_TEMP/testConfig.json" - TEST_CONFIG_FILE="$RUNNER_TEMP/testConfig.json" \ + CLOUD_ROOT_URL="https://cloud.51degrees.com/" \ + PAID_RESOURCE_KEY="$SUPER_RESOURCE_KEY" \ dotnet test selenium-api-tests/SeleniumApiTests.csproj -c Release --no-build \ - --filter 'FullyQualifiedName~ExampleClientSideOverride|FullyQualifiedName~ExampleRenderTests' + --filter TestCategory=Contract status=$? kill "$example_pid" 2>/dev/null || true exit $status From 85577e3e5f3fb06932e597ac986e72f393ff9727 Mon Sep 17 00:00:00 2001 From: YaroslavVlasenko Date: Mon, 8 Jun 2026 16:28:24 +0300 Subject: [PATCH 4/4] REFACT: Delete Selenium API tests workflow and migrate logic to PowerShell integration script --- .github/workflows/selenium-api-tests.yml | 64 ------------------------ ci/run-integration-tests.ps1 | 34 ++++++++++++- 2 files changed, 33 insertions(+), 65 deletions(-) delete mode 100644 .github/workflows/selenium-api-tests.yml diff --git a/.github/workflows/selenium-api-tests.yml b/.github/workflows/selenium-api-tests.yml deleted file mode 100644 index 78eb2f981..000000000 --- a/.github/workflows/selenium-api-tests.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Selenium API tests - -# Runs the shared Selenium contract for this repo's example against the live cloud. -on: - push: # TEMPORARY: run on any branch push (no PR needed) — remove before merge - pull_request: - branches: [main] - workflow_dispatch: - -jobs: - selenium-api-tests: - runs-on: ubuntu-latest - steps: - - name: Check out device-detection-python - uses: actions/checkout@v4 - with: - submodules: true - token: ${{ secrets.ACCESS_TOKEN }} - - - name: Check out selenium-api-tests - uses: actions/checkout@v4 - with: - repository: 51Degrees/selenium-api-tests - path: selenium-api-tests - token: ${{ secrets.ACCESS_TOKEN }} - - - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 10.0.x - - - name: Build the shared contract tests - run: dotnet build selenium-api-tests/SeleniumApiTests.csproj -c Release - - - name: Launch the example and run the contract - env: - PORT: "8097" - cloud_endpoint: https://cloud.51degrees.com/api/v4/ - resource_key: ${{ secrets.SUPER_RESOURCE_KEY }} - EXAMPLE_URL: http://localhost:8097 - EXAMPLE_LANG: python - SUPER_RESOURCE_KEY: ${{ secrets.SUPER_RESOURCE_KEY }} - run: | - # Start this repo's cloud example, pointed at the live cloud. - pushd fiftyone_devicedetection_examples - python3 -m venv .venv - .venv/bin/pip install -e . - .venv/bin/python -m fiftyone_devicedetection_examples.cloud.gettingstarted_web & - example_pid=$! - popd - for i in $(seq 1 30); do - curl -sf -o /dev/null "http://localhost:${PORT}/" && break || sleep 2 - done - # Run the shared contract against the live cloud. - CLOUD_ROOT_URL="https://cloud.51degrees.com/" \ - PAID_RESOURCE_KEY="$SUPER_RESOURCE_KEY" \ - dotnet test selenium-api-tests/SeleniumApiTests.csproj -c Release --no-build \ - --filter TestCategory=Contract - status=$? - kill "$example_pid" 2>/dev/null || true - exit $status diff --git a/ci/run-integration-tests.ps1 b/ci/run-integration-tests.ps1 index a16bf161f..45e618633 100644 --- a/ci/run-integration-tests.ps1 +++ b/ci/run-integration-tests.ps1 @@ -30,5 +30,37 @@ if ($env:GITHUB_JOB -eq "Test") { } ./python/run-integration-tests.ps1 -RepoName $RepoName -Packages $packages -Keys $Keys +$status = $LASTEXITCODE -exit $LASTEXITCODE +Write-Host 'Running Selenium tests...' +try { + # Start this repo's cloud example, pointed at the live cloud. + Push-Location "$PSScriptRoot/../fiftyone_devicedetection_examples" + try { + python3 -m venv .venv + $py = $IsWindows ? ".venv/Scripts/python.exe" : ".venv/bin/python" + & $py -m pip install -e . + $env:PORT = 8097 + $env:resource_key = $Keys.TestResourceKey + $env:cloud_endpoint = "https://cloud.51degrees.com/api/v4/" + $example = & $py -m fiftyone_devicedetection_examples.cloud.gettingstarted_web 2>&1 & + } finally { Pop-Location } + + # Get the shared contract tests. + if (-not (Test-Path selenium-api-tests)) { + git clone --depth 1 https://github.com/51Degrees/selenium-api-tests.git + } + # Wait for the example to come up. + curl -sS -o /dev/null --retry 5 --retry-connrefused "http://localhost:$env:PORT" + + $env:CLOUD_ROOT_URL = "https://cloud.51degrees.com/" + $env:PAID_RESOURCE_KEY = $Keys.TestResourceKey + $env:EXAMPLE_URL = "http://localhost:$env:PORT" + $env:EXAMPLE_LANG = 'python' + dotnet test selenium-api-tests -c Release --filter TestCategory=Contract +} catch { + if ($example) { Write-Host '>>> example app output >>>'; Receive-Job $example | Out-Host; Write-Host '<<< app output <<<' } + throw +} finally { + if ($example) { Remove-Job -Force $example } +}