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.
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.
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'- Clone the repository (or create these files in your existing one).
- Navigate to the
browserstack-report-actiondirectory. - Run
npm installto install dependencies. - Make changes to the source code in the
srcdirectory or constants in theconfigdirectory. - Run
npm run buildto compile the action to thedistdirectory. - Run
npm testto run unit tests. - Run
npm run allto run linting, tests, and build.
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
- The current API interaction is simulated within
src/main.js. You'll need to replacefetchDummyReportAPIwith 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) andretry_countwhich dictate the polling behavior. If not provided, defaults are used. - The
report_statusvalues handled are:in_progress,complete,tests_available,not_available,build_not_found,more_than_one_build_found. - The HTML report from
report.basic_htmlis added to the GitHub Actions summary.