- 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
Add BrowserStack pipeline and session artifact capture #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            rsrohit
  wants to merge
  5
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
codex/add-browserstack-integration-to-pipeline
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      850f9a9
              
                Add BrowserStack pipeline and session artifact capture
              
              
                rsrohit d9cdb06
              
                Update gemini and deepseek env variables
              
              
                rsrohit e9bc7bb
              
                Update sample_login.json
              
              
                rsrohit 7dd82dc
              
                Merge branch 'main' into codex/add-browserstack-integration-to-pipeline
              
              
                rsrohit 2bbc926
              
                Update config.js
              
              
                rsrohit File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: BrowserStack Tests | ||
| 
     | 
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| workflow_dispatch: | ||
| 
     | 
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - platform: android | ||
| device: 'Samsung Galaxy S23' | ||
| os_version: '13.0' | ||
| app: ./path/to/android-app.apk | ||
| - platform: ios | ||
| device: 'iPhone 15' | ||
| os_version: '17' | ||
| app: ./path/to/ios-app.ipa | ||
| env: | ||
| BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} | ||
| BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | ||
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | ||
| DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }} | ||
| TEST_PATH: tests/sample_login.json | ||
| AI_SERVICE: gemini | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 18 | ||
| cache: 'npm' | ||
| cache-dependency-path: backend/package-lock.json | ||
| - name: Install backend dependencies | ||
| working-directory: backend | ||
| run: npm ci | ||
| - name: Run BrowserStack tests | ||
| id: run-tests | ||
| working-directory: backend | ||
| env: | ||
| APP_PATH: ${{ matrix.app }} | ||
| PLATFORM: ${{ matrix.platform }} | ||
| DEVICE_NAME: ${{ matrix.device }} | ||
| OS_VERSION: ${{ matrix.os_version }} | ||
| run: npm run test:browserstack | ||
| - name: Collect BrowserStack artifacts | ||
| if: ${{ steps.run-tests.outputs.session_id }} | ||
| working-directory: backend | ||
| env: | ||
| SESSION_ID: ${{ steps.run-tests.outputs.session_id }} | ||
| BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} | ||
| BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | ||
| run: | | ||
| mkdir -p artifacts | ||
| curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \ | ||
| "https://api.browserstack.com/app-automate/sessions/$SESSION_ID.json" -o session.json | ||
| VIDEO_URL=$(jq -r '.automation_session.video_url' session.json) | ||
| LOG_URL=$(jq -r '.automation_session.appium_logs_url' session.json) | ||
| curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" "$VIDEO_URL" -o artifacts/${SESSION_ID}-video.mp4 | ||
| curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" "$LOG_URL" -o artifacts/${SESSION_ID}-appium.log | ||
| echo "### BrowserStack Session $SESSION_ID" >> $GITHUB_STEP_SUMMARY | ||
| echo "- [Video]($VIDEO_URL)" >> $GITHUB_STEP_SUMMARY | ||
| echo "- [Appium Log]($LOG_URL)" >> $GITHUB_STEP_SUMMARY | ||
| - uses: actions/upload-artifact@v4 | ||
| if: ${{ steps.run-tests.outputs.session_id }} | ||
| with: | ||
| name: browserstack-${{ matrix.platform }}-${{ matrix.os_version }} | ||
| path: backend/artifacts | 
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/usr/bin/env node | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { executeTest } = require('../src/test-runner/test_executor'); | ||
| 
     | 
||
| async function main() { | ||
| const appPath = process.env.APP_PATH; | ||
| const testsPath = process.env.TEST_PATH; | ||
| const platform = process.env.PLATFORM || 'android'; | ||
| const deviceName = process.env.DEVICE_NAME || ''; | ||
| const osVersion = process.env.OS_VERSION || ''; | ||
| const aiService = process.env.AI_SERVICE || 'gemini'; | ||
| 
     | 
||
| if (!appPath || !testsPath) { | ||
| console.error('APP_PATH and TEST_PATH environment variables are required'); | ||
| process.exit(1); | ||
| } | ||
| 
     | 
||
| const rawStepsText = fs.readFileSync(path.resolve(testsPath), 'utf8'); | ||
| 
     | 
||
| const sessionId = await executeTest( | ||
| path.resolve(appPath), | ||
| rawStepsText, | ||
| { to: () => ({ emit: () => {} }) }, | ||
| 'cli', | ||
| aiService, | ||
| 'browserstack', | ||
| platform, | ||
| deviceName, | ||
| osVersion, | ||
| ); | ||
| 
     | 
||
| console.log(`BrowserStack session ID: ${sessionId}`); | ||
| 
     | 
||
| if (process.env.GITHUB_OUTPUT) { | ||
| fs.appendFileSync(process.env.GITHUB_OUTPUT, `session_id=${sessionId}\n`); | ||
| } | ||
| } | ||
| 
     | 
||
| main().catch((err) => { | ||
| console.error(err); | ||
| process.exit(1); | ||
| }); | ||
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Fail the CLI when test execution fails
The new BrowserStack runner awaits
executeTestand then exits successfully regardless of whether the test actually passes.executeTestcatches all exceptions and resolves (lines 581‑585 intest_executor.js), so when a test fails the function returnsnullor an unfinished session ID but never rejects. As a result, theRun BrowserStack testsjob will report success and still emit a session ID even when the underlying test suite failed, letting CI pipelines go green erroneously. The script should treat a missing/failed run as an error—either by propagating the exception fromexecuteTestor by checking its result and exiting with a non‑zero code—so that workflow failures surface in CI.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codex fix comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
Testing
node --check backend/scripts/run-browserstack-tests.jsnode --check backend/src/test-runner/test_executor.jsView task →