|
| 1 | +# BrowserStack Report GitHub Action |
| 2 | + |
| 3 | +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. |
| 4 | +The polling interval and maximum retries are determined by the initial API response. |
| 5 | + |
| 6 | +## Inputs |
| 7 | + |
| 8 | +- `username` (**required**): Your BrowserStack username. |
| 9 | + It's recommended to store this as a GitHub secret. |
| 10 | +- `access-key` (**required**): Your BrowserStack access key. |
| 11 | + It's recommended to store this as a GitHub secret. |
| 12 | +- `build-name` (optional): The name of the build on BrowserStack. |
| 13 | + Defaults to `<GitHub Workflow Name>_<GitHub Run ID>`. |
| 14 | +- `report-timeout` (optional): User-defined timeout value (in seconds) to be sent to the report API. |
| 15 | + Default: `10`. |
| 16 | + |
| 17 | +## Example Usage |
| 18 | + |
| 19 | +```yaml |
| 20 | +name: CI with BrowserStack Report |
| 21 | + |
| 22 | +on: [push] |
| 23 | + |
| 24 | +jobs: |
| 25 | + test_and_report: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Checkout code |
| 29 | + uses: actions/checkout@v3 |
| 30 | + |
| 31 | + # ... your test steps that trigger a BrowserStack build ... |
| 32 | + |
| 33 | + - name: Fetch BrowserStack Report |
| 34 | + # If using a published version: |
| 35 | + # uses: your-org/browserstack-report-action@v1 |
| 36 | + # If using a local version from the same repository: |
| 37 | + uses: ./.github/actions/browserstack-report-action |
| 38 | + with: |
| 39 | + username: ${{ secrets.BROWSERSTACK_USERNAME }} |
| 40 | + access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} |
| 41 | + build-name: 'My Awesome App E2E Tests' |
| 42 | + #user-timeout can be specified if needed, e.g.: |
| 43 | + report-timeout: '10' |
| 44 | +``` |
| 45 | +
|
| 46 | +## Development |
| 47 | +
|
| 48 | +1. Clone the repository (or create these files in your existing one). |
| 49 | +2. Navigate to the `browserstack-report-action` directory. |
| 50 | +3. Run `npm install` to install dependencies. |
| 51 | +4. Make changes to the source code in the `src` directory or constants in the `config` directory. |
| 52 | +5. Run `npm run build` to compile the action to the `dist` directory. |
| 53 | +6. Run `npm test` to run unit tests. |
| 54 | +7. Run `npm run all` to run linting, tests, and build. |
| 55 | + |
| 56 | +## Project Structure |
| 57 | + |
| 58 | +``` |
| 59 | +browserstack-report-action/ |
| 60 | +├── .gitignore - Gitignore file |
| 61 | +├── .eslintrc.js - ESLint configuration |
| 62 | +├── action.yml - GitHub Action metadata |
| 63 | +├── package.json - Node.js package file |
| 64 | +├── README.md - Documentation |
| 65 | +├── config/ - Configuration files |
| 66 | +│ └── constants.js - Constants used throughout the action |
| 67 | +├── dist/ - Compiled code (generated by ncc) |
| 68 | +├── src/ - JavaScript source code |
| 69 | +│ ├── main.js - Main action code |
| 70 | +│ └── actionInput/ - Input handling and validation |
| 71 | +│ ├── index.js - ActionInput class |
| 72 | +│ └── inputValidator.js - InputValidator class |
| 73 | +└── test/ - Test files |
| 74 | + └── main.test.js - Tests for main.js |
| 75 | +``` |
| 76 | +
|
| 77 | +## Notes |
| 78 | +
|
| 79 | +- 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. |
| 80 | +- 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. |
| 81 | +- The `report_status` values handled are: `in_progress`, `complete`, `tests_available`, `not_available`, `build_not_found`, `more_than_one_build_found`. |
| 82 | +- The HTML report from `report.basic_html` is added to the GitHub Actions summary. |
0 commit comments