Image and video frame details refactor #1999
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: End2End Test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| NODE_OPTIONS: --max-old-space-size=4096 | |
| DATASET_PATH: $(pwd)/datasets | |
| E2E_BASE_URL: http://localhost:8001 | |
| LIGHTLY_STUDIO_LICENSE_KEY: ${{ secrets.MUNDIG_LICENSE_KEY }} | |
| jobs: | |
| prepare-caches: | |
| name: Build Cache | |
| runs-on: ubuntu-latest | |
| outputs: | |
| cache-hit: ${{ steps.cache-build.outputs.cache-hit }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| # Authenticate to download lightly-edge-sdk. | |
| - name: Authenticate with GCP | |
| uses: 'google-github-actions/auth@v2' | |
| with: | |
| project_id: boris-250909 | |
| credentials_json: ${{ secrets.GCP_LIGHTLY_STUDIO_CI_READONLY }} | |
| - name: Cache build | |
| id: cache-build | |
| uses: actions/cache@v4 | |
| with: | |
| lookup-only: true | |
| path: &cache-build-path | | |
| lightly_studio_view/build | |
| lightly_studio/src/lightly_studio/dist_lightly_studio_view_app | |
| key: &cache-build-key >- | |
| python-build-${{ | |
| hashFiles( | |
| '.github/workflows/end2end_test.yml', | |
| 'lightly_studio/e2e-tests/**/*', | |
| 'lightly_studio/src/**/*', | |
| 'lightly_studio/pyproject.toml', | |
| 'lightly_studio_view/e2e/**/*', | |
| 'lightly_studio_view/src/**/*', | |
| 'lightly_studio_view/public/**/*', | |
| 'lightly_studio_view/package.json', | |
| 'lightly_studio_view/package-lock.json' | |
| ) | |
| }} | |
| - name: Cache Playwright browsers | |
| id: cache-playwright-browsers | |
| uses: actions/cache@v4 | |
| with: | |
| path: &cache-playwright-browsers-path ~/.cache/ms-playwright | |
| key: &cache-playwright-browsers-key >- | |
| playwright-${{ runner.os }}-${{ hashFiles( | |
| 'lightly_studio_view/package-lock.json' | |
| ) | |
| }} | |
| - name: Cache example dataset | |
| id: cache-example-dataset | |
| uses: actions/cache@v4 | |
| with: | |
| # No need to download a cached version in cache preparation step | |
| lookup-only: true | |
| path: &cache-example-dataset-path lightly_studio/datasets | |
| key: &cache-example-dataset-key example-dataset | |
| ### Setup steps for the workflow ### | |
| - name: Set Up Python | |
| if: steps.cache-build.outputs.cache-hit != 'true' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.8" | |
| - name: Set Up Uv | |
| if: steps.cache-build.outputs.cache-hit != 'true' | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: "0.8.17" | |
| enable-cache: true | |
| - name: Set Up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.11.0' | |
| cache: 'npm' | |
| cache-dependency-path: lightly_studio_view/package-lock.json | |
| - name: Install lightly_studio_view dependencies | |
| if: steps.cache-build.outputs.cache-hit != 'true' | |
| working-directory: lightly_studio_view | |
| run: npm ci | |
| ### Build caches ### | |
| # Always ensure system packages for browsers are present on Ubuntu | |
| - name: Install Playwright system dependencies | |
| if: steps.cache-build.outputs.cache-hit != 'true' | |
| working-directory: lightly_studio_view | |
| run: npx playwright install-deps chromium | |
| # Only download browser binaries when cache misses; otherwise reuse cache | |
| - name: Install Playwright browsers | |
| if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' | |
| working-directory: lightly_studio_view | |
| run: npx playwright install chromium | |
| - name: Download example dataset | |
| if: steps.cache-example-dataset.outputs.cache-hit != 'true' | |
| run: make download-example-dataset | |
| - name: Export schema and generate version file from backend | |
| if: steps.cache-build.outputs.cache-hit != 'true' | |
| working-directory: lightly_studio | |
| run: | | |
| make export-schema | |
| make export-version | |
| ### Building steps for the workflow ### | |
| - name: Build the ui application | |
| if: steps.cache-build.outputs.cache-hit != 'true' | |
| working-directory: lightly_studio_view | |
| run: | | |
| rm -rf build | |
| npm run build | |
| - name: Copy the built ui app to lightly_studio source folder | |
| if: steps.cache-build.outputs.cache-hit != 'true' | |
| run: | | |
| rm -rf lightly_studio/src/lightly_studio/dist_lightly_studio_view_app | |
| cp -r lightly_studio_view/build/ lightly_studio/src/lightly_studio/dist_lightly_studio_view_app | |
| end-to-end-general: | |
| name: General End2End Test | |
| runs-on: ubuntu-latest | |
| needs: prepare-caches | |
| # Skip the job if there's no change that affects end-to-end tests. | |
| if: needs.prepare-caches.outputs.cache-hit != 'true' | |
| steps: | |
| - &setup-checkout-code | |
| name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| # Authenticate to download lightly-edge-sdk. | |
| - &setup-authenticate-gcp | |
| name: Authenticate with GCP | |
| uses: 'google-github-actions/auth@v2' | |
| with: | |
| project_id: boris-250909 | |
| credentials_json: ${{ secrets.GCP_LIGHTLY_STUDIO_CI_READONLY }} | |
| ### Restore caches ### | |
| - &setup-cache-build | |
| name: Cache build | |
| id: cache-build | |
| uses: actions/cache@v4 | |
| with: | |
| fail-on-cache-miss: true | |
| path: *cache-build-path | |
| key: *cache-build-key | |
| - &setup-cache-playwright-browsers | |
| name: Cache Playwright browsers | |
| id: cache-playwright-browsers | |
| uses: actions/cache@v4 | |
| with: | |
| fail-on-cache-miss: true | |
| path: *cache-playwright-browsers-path | |
| key: *cache-playwright-browsers-key | |
| - &setup-cache-example-dataset | |
| name: Cache example dataset | |
| id: cache-example-dataset | |
| uses: actions/cache@v4 | |
| with: | |
| fail-on-cache-miss: true | |
| path: *cache-example-dataset-path | |
| key: *cache-example-dataset-key | |
| ### Setup ### | |
| - &setup-python | |
| name: Set Up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.8" | |
| - &setup-uv | |
| name: Set Up Uv | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: "0.8.17" | |
| enable-cache: true | |
| - &setup-nodejs | |
| name: Set Up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.11.0' | |
| cache: 'npm' | |
| cache-dependency-path: lightly_studio_view/package-lock.json | |
| - &setup-install-lightly-studio-view-deps | |
| name: Install lightly_studio_view dependencies | |
| working-directory: lightly_studio_view | |
| run: npm ci | |
| - &setup-install-lightly-studio-deps | |
| name: Install lightly_studio dependencies | |
| working-directory: lightly_studio | |
| run: make install-optional-deps | |
| ### Run e2e tests ### | |
| - name: Index dataset with using lightly_studio pypi package | |
| working-directory: lightly_studio | |
| # TODO(Michal, 10/2025): Starting up the server redownloads the embedding model. Consider caching it. | |
| run: | | |
| uv run e2e-tests/index_general.py > server.log 2>&1 & | |
| echo "SERVER_PID=$!" >> $GITHUB_ENV | |
| id: server | |
| - &wait-for-server | |
| name: Wait for the server to start | |
| timeout-minutes: 5 | |
| working-directory: lightly_studio | |
| run: | | |
| echo "Waiting for the server to become available..." | |
| timeout=360 | |
| elapsed=0 | |
| interval=5 | |
| while [ $elapsed -lt $timeout ]; do | |
| if curl -s -f ${E2E_BASE_URL}/healthz > /dev/null 2>&1; then | |
| echo "✅ Server is up and running after ${elapsed} seconds!" | |
| break | |
| fi | |
| if ! ps -p ${{ env.SERVER_PID }} > /dev/null; then | |
| echo "❌ Server process has exited unexpectedly." | |
| exit 1 | |
| fi | |
| echo "⏳ Server not ready yet, waiting... (${elapsed}/${timeout} seconds)" | |
| tail -n 1 server.log | |
| echo | |
| sleep $interval | |
| elapsed=$((elapsed + interval)) | |
| done | |
| if [ $elapsed -ge $timeout ]; then | |
| echo "❌ Timed out waiting for server to become available" | |
| exit 1 | |
| fi | |
| ### Running end-to-end tests ### | |
| - name: Run end-to-end tests for indexed dataset | |
| working-directory: lightly_studio_view | |
| run: npx playwright test --reporter=html --trace=on --project=general | |
| timeout-minutes: 10 | |
| ### Cleanup steps ### | |
| - &cleanup-show-server-logs | |
| name: Show server logs after failure | |
| if: failure() | |
| working-directory: lightly_studio | |
| run: | | |
| echo "Server logs:" | |
| cat server.log | |
| - &cleanup-upload-playwright-report | |
| name: Upload Playwright report after failure | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: Upload Playwright Report | |
| path: lightly_studio_view/playwright-report-${{ github.job }} | |
| retention-days: 5 | |
| - &cleanup-stop-server | |
| name: Stop lightly_studio application running in background | |
| if: always() | |
| run: | | |
| kill ${{ env.SERVER_PID }} || true | |
| end-to-end-captions: | |
| name: Captions End2End Test | |
| runs-on: ubuntu-latest | |
| needs: prepare-caches | |
| # Skip the job if there's no change that affects end-to-end tests. | |
| if: needs.prepare-caches.outputs.cache-hit != 'true' | |
| steps: | |
| - *setup-checkout-code | |
| - *setup-authenticate-gcp | |
| - *setup-cache-build | |
| - *setup-cache-playwright-browsers | |
| - *setup-cache-example-dataset | |
| - *setup-python | |
| - *setup-uv | |
| - *setup-nodejs | |
| - *setup-install-lightly-studio-view-deps | |
| - *setup-install-lightly-studio-deps | |
| ### Run e2e tests ### | |
| - name: Index dataset with using lightly_studio pypi package | |
| working-directory: lightly_studio | |
| # TODO(Michal, 10/2025): Starting up the server redownloads the embedding model. Consider caching it. | |
| run: | | |
| uv run e2e-tests/index_captions.py > server.log 2>&1 & | |
| echo "SERVER_PID=$!" >> $GITHUB_ENV | |
| id: server | |
| - *wait-for-server | |
| ### Running end-to-end tests ### | |
| - name: Run end-to-end tests for indexed dataset | |
| working-directory: lightly_studio_view | |
| run: npx playwright test --reporter=html --trace=on --project=captions | |
| timeout-minutes: 10 | |
| ### Cleanup steps ### | |
| - *cleanup-show-server-logs | |
| - *cleanup-upload-playwright-report | |
| - *cleanup-stop-server | |
| success-check: | |
| name: End2End Success Check | |
| runs-on: ubuntu-latest | |
| needs: | |
| - prepare-caches | |
| - end-to-end-general | |
| - end-to-end-captions | |
| if: always() | |
| steps: | |
| - name: Check failure | |
| if: | | |
| needs.prepare-caches.outputs.cache-hit != 'true' && | |
| ( | |
| needs.end-to-end-general.result != 'success' || | |
| needs.end-to-end-captions.result != 'success' | |
| ) | |
| run: | | |
| echo "❌ End-to-End tests did not complete successfully." | |
| exit 1 |