diff --git a/.github/workflows/on_schedule_tests.yaml b/.github/workflows/on_schedule_tests.yaml index 96c4edb98d..0d9503b3d8 100644 --- a/.github/workflows/on_schedule_tests.yaml +++ b/.github/workflows/on_schedule_tests.yaml @@ -69,6 +69,7 @@ jobs: run: uv run poe e2e-templates-tests -m "${{ matrix.http-client }} and ${{ matrix.crawler-type }} and ${{ matrix.package-manager }}" env: APIFY_TEST_USER_API_TOKEN: ${{ secrets.APIFY_TEST_USER_API_TOKEN }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} # Send a Slack notification to #tooling-team-python when scheduled e2e tests fail. # Skipped on workflow_dispatch (manual runs) so that ad-hoc triggers don't spam the channel. diff --git a/tests/e2e/project_template/test_static_crawlers_templates.py b/tests/e2e/project_template/test_static_crawlers_templates.py index 358f05fe50..eb25425f1a 100644 --- a/tests/e2e/project_template/test_static_crawlers_templates.py +++ b/tests/e2e/project_template/test_static_crawlers_templates.py @@ -109,17 +109,16 @@ async def test_static_crawler_actor_at_apify( client = ApifyClientAsync(token=os.getenv('APIFY_TEST_USER_API_TOKEN')) actor = client.actor(actor_id) - # The template ships a placeholder API key, so only validate the build and skip the run. - if crawler_type == 'stagehand': - try: - assert build_process.returncode == 0 - finally: - await actor.delete() - return - # Run actor try: assert build_process.returncode == 0 + + # Stagehand needs the model API key in `os.environ` at run time; register it as a secret env var + # on the deployed actor version so the platform injects it into the run. + if crawler_type == 'stagehand': + env_vars = actor.version('0.0').env_vars() + await env_vars.create(name='OPENAI_API_KEY', value=os.environ['OPENAI_API_KEY'], is_secret=True) + started_run_data = await actor.start(memory_mbytes=8192) actor_run = client.run(started_run_data['id'])