Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 71 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,8 @@ jobs:
with:
version: 2026.4.27
cache_key_prefix: mise-ci-${{ github.job }}
- name: Install dependencies
run: mise run playground:install
- name: Test
run: pnpm --dir playground exec vitest run --passWithNoTests
run: mise run test:playground

playground-check:
name: Check playground
Expand Down Expand Up @@ -635,6 +633,65 @@ jobs:
- name: Test coglet-python bindings
run: uvx nox -s coglet -p ${{ matrix.python-version }}

test-playground-e2e:
name: Playground Playwright integration tests (Chromium)
needs:
- playground-changes
- fmt-playground
- lint-playground
- test-playground
- playground-check
- build-cog
- build-sdk
- build-rust
if: needs.playground-changes.outputs.changed == 'true'
runs-on: ubuntu-latest-16-cores
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Login to Docker Hub
uses: docker/login-action@v4
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
with:
registry: index.docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Install cog binary
run: |
cp dist/cog ./cog
chmod +x ./cog
- uses: jdx/mise-action@v4
with:
version: 2026.4.27
cache_key_prefix: mise-ci-${{ github.job }}
- name: Install playground dependencies and Chromium
run: |
mise run playground:install
pnpm --dir playground exec playwright install --with-deps chromium
- name: Run browser integration tests
env:
BUILDKIT_PROGRESS: quiet
COG_BINARY: ${{ github.workspace }}/cog
COG_REGISTRY_HOST: ghcr.io/replicate/cog
COG_SDK_WHEEL: ${{ github.workspace }}/dist
COGLET_WHEEL: ${{ github.workspace }}/dist
run: pnpm --dir playground run test:e2e
- name: Upload browser test report
if: failure()
uses: actions/upload-artifact@v6
with:
name: PlaygroundPlaywrightReport
path: |
playground/playwright-report
playground/test-results

# Compute integration test shards dynamically.
# Slow tests (tagged with [short] skip) are distributed round-robin first,
# then remaining tests fill in. This ensures slow tests don't pile up on one runner.
Expand Down Expand Up @@ -824,6 +881,7 @@ jobs:
- test-rust
- test-python
- test-coglet-python
- test-playground-e2e
- integration-shards
- test-integration
if: always()
Expand Down Expand Up @@ -858,6 +916,7 @@ jobs:
echo " test-rust: ${{ needs.test-rust.result }}"
echo " test-python: ${{ needs.test-python.result }}"
echo " test-coglet-python: ${{ needs.test-coglet-python.result }}"
echo " test-playground-e2e: ${{ needs.test-playground-e2e.result }}"
echo " integration-shards: ${{ needs.integration-shards.result }}"
echo " test-integration: ${{ needs.test-integration.result }}"

Expand Down Expand Up @@ -898,6 +957,15 @@ jobs:
check_success integration-shards "${{ needs.integration-shards.result }}"
check_success test-integration "${{ needs.test-integration.result }}"

if [ "${{ needs.playground-changes.outputs.changed }}" = "true" ]; then
check_success test-playground-e2e "${{ needs.test-playground-e2e.result }}"
else
if [ "${{ needs.test-playground-e2e.result }}" != "skipped" ]; then
echo "::error::Playground integration tests should be skipped when playground sources are unchanged"
FAILED=true
fi
fi

if [ "$FAILED" = "true" ]; then
echo "::error::Some jobs failed or were cancelled"
exit 1
Expand Down
2 changes: 0 additions & 2 deletions pkg/cli/playground_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"github.com/replicate/cog/pkg/global"
)

var _ = newPlaygroundCommand

func newTestPlayground(t *testing.T) *httptest.Server {
t.Helper()
uiFS, err := fs.Sub(playgroundUI, "playground")
Expand Down
3 changes: 3 additions & 0 deletions playground/e2e/fixture/cog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build:
python_version: "3.12"
run: "run.py:Runner"
20 changes: 20 additions & 0 deletions playground/e2e/fixture/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import time

from cog import BaseRunner, ConcatenateIterator, Input, streaming


class Runner(BaseRunner):
@streaming
def run(
self,
text: str = Input(
description="Text to prefix with 'hello '",
min_length=2,
max_length=20,
regex=r"^[a-z ]+$",
),
) -> ConcatenateIterator[str]:
yield "hello "
if text == "slow":
time.sleep(2)
yield text
Loading
Loading