Skip to content

Latest commit

 

History

History
 
 

README.md

BrowserStack Report GitHub Action

This action fetches a report from a (currently dummy) BrowserStack-like API, polls for its completion, and displays the HTML report in the GitHub Actions summary tab. The polling interval and maximum retries are determined by the initial API response.

Inputs

  • username (required): Your BrowserStack username. It's recommended to store this as a GitHub secret.
  • access-key (required): Your BrowserStack access key. It's recommended to store this as a GitHub secret.
  • build-name (optional): The name of the build on BrowserStack. Defaults to <GitHub Workflow Name>_<GitHub Run ID>.
  • report-timeout (optional): User-defined timeout value (in seconds) to be sent to the report API. Default: 10.

Example Usage

name: CI with BrowserStack Report

on: [push]

jobs:
  test_and_report:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      # ... your test steps that trigger a BrowserStack build ...

      - name: Fetch BrowserStack Report
        # If using a published version:
        # uses: your-org/browserstack-report-action@v1 
        # If using a local version from the same repository:
        uses: ./.github/actions/browserstack-report-action
        with:
          username: ${{ secrets.BROWSERSTACK_USERNAME }}
          access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
          build-name: 'My Awesome App E2E Tests'
        #user-timeout can be specified if needed, e.g.:
          report-timeout: '10'

Development

  1. Clone the repository (or create these files in your existing one).
  2. Navigate to the browserstack-report-action directory.
  3. Run npm install to install dependencies.
  4. Make changes to the source code in the src directory or constants in the config directory.
  5. Run npm run build to compile the action to the dist directory.
  6. Run npm test to run unit tests.
  7. Run npm run all to run linting, tests, and build.

Project Structure

browserstack-report-action/
├── .gitignore             - Gitignore file
├── .eslintrc.js           - ESLint configuration
├── action.yml             - GitHub Action metadata
├── package.json           - Node.js package file
├── README.md              - Documentation
├── config/                - Configuration files
│   └── constants.js       - Constants used throughout the action
├── dist/                  - Compiled code (generated by ncc)
├── src/                   - JavaScript source code
│   ├── main.js            - Main action code
│   └── actionInput/       - Input handling and validation
│       ├── index.js       - ActionInput class
│       └── inputValidator.js - InputValidator class
└── test/                  - Test files
    └── main.test.js       - Tests for main.js

Notes

  • The current API interaction is simulated within src/main.js. You'll need to replace fetchDummyReportAPI with actual API calls to BrowserStack, including proper authentication using the provided username and access key.
  • The initial API response is expected to provide polling_interval (seconds) and retry_count which dictate the polling behavior. If not provided, defaults are used.
  • The report_status values handled are: in_progress, complete, tests_available, not_available, build_not_found, more_than_one_build_found.
  • The HTML report from report.basic_html is added to the GitHub Actions summary.