The .github/workflows/copilot-setup-steps.yml had a critical step ordering issue:
Before (BROKEN):
- Create
.env.llm-testsfile - Checkout code ← This overwrites the directory, losing the .env file!
- Run tests
After (FIXED):
- Checkout code
- Create
.env.llm-testsfile ← Now persists correctly - Run tests
- Moved "Persist Secrets to Agent Environment" step AFTER "Checkout code"
- Added
exportprefix to environment variables for proper shell sourcing - Added
RUN_LLM_TESTS=trueto enable tests automatically - Added
chmod 600for security - Added verification logging to confirm file creation
The .env.llm-tests sourcing mechanism works correctly:
# Create .env file
echo 'export OPENAI_API_KEY=sk-your-key' > .env.llm-tests
echo 'export RUN_LLM_TESTS=true' >> .env.llm-tests
# Source and verify
source .env.llm-tests
echo $OPENAI_API_KEY # Shows the keyWhen the environment is properly sourced, tests correctly:
- Detect the API key presence
- Enable live test execution (not skipped)
- Show provider detection: "Running LLM integration tests with provider: openai"
Tests fail in the jsdom environment with network errors:
Error: Cross origin null forbidden
Error: LLM API call failed: Network Error
This is expected because:
- Tests run in a jsdom environment (not a real browser)
- axios HTTP requests fail due to CORS restrictions in jsdom
- Live API tests need a proper Node.js environment or network mocking
Run tests with a real API key in a Node environment:
source .env.llm-tests
cd app && yarn testThe workflow now correctly:
- Checks out the repository first
- Creates
.env.llm-testsin the workspace - Makes the API key available to subsequent steps
Consider:
- Running tests in a Node environment (not jsdom)
- Using nock or msw to mock HTTP requests in tests
- Running live tests only in scheduled jobs with proper network access
- ✅
.env.llm-testscreation via workflow (step order fixed) - ✅
.env.llm-testscreation viasetup-llm-env.sh - ✅ Environment variable sourcing
- ✅ Test detection of API keys
- ✅ Provider auto-detection (OpenAI/Gemini)
- ✅ Proper skip behavior when no API key
The infrastructure is now working correctly. The workflow step order has been fixed to ensure .env.llm-tests persists after checkout.