From 30a0aa41e2637e2c79b2ae17f64b7b84c532c212 Mon Sep 17 00:00:00 2001 From: YaroslavVlasenko Date: Fri, 5 Jun 2026 18:23:30 +0300 Subject: [PATCH 1/3] TEST: Add GitHub Actions workflow for Selenium API tests --- .github/workflows/selenium-api-tests.yml | 79 ++++++++++++++++++++++++ 1 file changed, 79 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..8af48d7ac --- /dev/null +++ b/.github/workflows/selenium-api-tests.yml @@ -0,0 +1,79 @@ +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-java + uses: actions/checkout@v4 + with: + submodules: true + token: ${{ secrets.ACCESS_TOKEN }} + + - name: Check out device-detection-java-examples + uses: actions/checkout@v4 + with: + repository: 51Degrees/device-detection-java-examples + path: device-detection-java-examples + 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-java@v4 + with: + distribution: temurin + java-version: '17' + + - 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: Install the dev device-detection-java library + run: mvn install -B --no-transfer-progress -DskipTests -DskipNativeBuild=true + + - name: Launch the example and run the contract + env: + PORT: "8099" + EXAMPLE_URL: http://localhost:8099 + EXAMPLE_LANG: java + SUPER_RESOURCE_KEY: ${{ secrets.SUPER_RESOURCE_KEY }} + run: | + # Build the cloud example against the just-installed dev library. + dev_ver=$(mvn -q help:evaluate -Dexpression=project.version -DforceStdout) + pushd device-detection-java-examples + mvn -B --no-transfer-progress -pl web/getting-started.cloud -am package -DskipTests \ + -Ddevice-detection.version="$dev_ver" + jar=$(ls web/getting-started.cloud/target/*-jar-with-dependencies.jar | head -1) + PORT="$PORT" \ + TestCloudEndpoint=https://cloud.51degrees.com/api/v4 \ + TestResourceKey="$SUPER_RESOURCE_KEY" \ + java -jar "$jar" & + 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 c8b47f1c7872987378a6bbac253e004d5b6511ec Mon Sep 17 00:00:00 2001 From: YaroslavVlasenko Date: Mon, 8 Jun 2026 12:47:08 +0300 Subject: [PATCH 2/3] TEST: Update Selenium API tests workflow to streamline test config handling --- .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 8af48d7ac..7d1b65450 100644 --- a/.github/workflows/selenium-api-tests.yml +++ b/.github/workflows/selenium-api-tests.yml @@ -69,11 +69,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 7aa0a7c964c9f5a1fdf79607a7d0de6b4ecc32fe Mon Sep 17 00:00:00 2001 From: YaroslavVlasenko Date: Mon, 8 Jun 2026 16:30:43 +0300 Subject: [PATCH 3/3] TEST: Remove Selenium API tests workflow from GitHub Actions and migrate to PowerShell script --- .github/workflows/selenium-api-tests.yml | 78 ------------------------ ci/run-integration-tests.ps1 | 34 ++++++++++- 2 files changed, 33 insertions(+), 79 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 7d1b65450..000000000 --- a/.github/workflows/selenium-api-tests.yml +++ /dev/null @@ -1,78 +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-java - uses: actions/checkout@v4 - with: - submodules: true - token: ${{ secrets.ACCESS_TOKEN }} - - - name: Check out device-detection-java-examples - uses: actions/checkout@v4 - with: - repository: 51Degrees/device-detection-java-examples - path: device-detection-java-examples - 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-java@v4 - with: - distribution: temurin - java-version: '17' - - - 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: Install the dev device-detection-java library - run: mvn install -B --no-transfer-progress -DskipTests -DskipNativeBuild=true - - - name: Launch the example and run the contract - env: - PORT: "8099" - EXAMPLE_URL: http://localhost:8099 - EXAMPLE_LANG: java - SUPER_RESOURCE_KEY: ${{ secrets.SUPER_RESOURCE_KEY }} - run: | - # Build the cloud example against the just-installed dev library. - dev_ver=$(mvn -q help:evaluate -Dexpression=project.version -DforceStdout) - pushd device-detection-java-examples - mvn -B --no-transfer-progress -pl web/getting-started.cloud -am package -DskipTests \ - -Ddevice-detection.version="$dev_ver" - jar=$(ls web/getting-started.cloud/target/*-jar-with-dependencies.jar | head -1) - PORT="$PORT" \ - TestCloudEndpoint=https://cloud.51degrees.com/api/v4 \ - TestResourceKey="$SUPER_RESOURCE_KEY" \ - java -jar "$jar" & - 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 9e0772bea..3c269def7 100644 --- a/ci/run-integration-tests.ps1 +++ b/ci/run-integration-tests.ps1 @@ -73,4 +73,36 @@ finally { } -exit $LASTEXITCODE +$status = $LASTEXITCODE + +Write-Host 'Running Selenium tests...' +try { + # Build and start the cloud example (already pinned to the dev version above). + Push-Location "device-detection-java-examples" + try { + mvn -B --no-transfer-progress -pl web/getting-started.cloud -am package -DskipTests + $jar = (Get-ChildItem web/getting-started.cloud/target/*-jar-with-dependencies.jar | Select-Object -First 1).FullName + $env:PORT = 8099 + $env:TestCloudEndpoint = "https://cloud.51degrees.com/api/v4" + $env:TestResourceKey = $Keys.TestResourceKey + $example = java -jar $jar 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 = 'java' + 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 } +}