Skip to content

Commit f85cbf1

Browse files
committed
cad reporting browserstack-report action
1 parent dba20ea commit f85cbf1

File tree

12 files changed

+36556
-0
lines changed

12 files changed

+36556
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
es2020: true,
5+
mocha: true,
6+
},
7+
extends: 'airbnb-base',
8+
parserOptions: {
9+
ecmaVersion: 11,
10+
sourceType: 'script',
11+
},
12+
rules: {
13+
semi: ['error', 'always'],
14+
indent: ['error', 2, { SwitchCase: 1 }],
15+
quotes: 'off',
16+
'consistent-return': 'off',
17+
'no-underscore-dangle': 'off',
18+
'no-case-declarations': 'error',
19+
'prefer-destructuring': ['error', { object: true, array: false }],
20+
'no-restricted-syntax': 'off',
21+
'linebreak-style': 'off',
22+
},
23+
ignorePatterns: ['dist/index.js'],
24+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Node
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
package-lock.json
7+
8+
# Misc
9+
.DS_Store
10+
11+
# Coverage
12+
coverage/
13+
.nyc_output/
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
- `browserstack-username` (**required**): Your BrowserStack username.
9+
It's recommended to store this as a GitHub secret.
10+
- `browserstack-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+
- `user-timeout` (optional): User-defined timeout value (in seconds) to be sent to the report API.
15+
Default: `300`. (Currently for dummy API simulation)
16+
17+
## Outputs
18+
19+
- `build_uuid`: The UUID of the build from the API.
20+
- `report_status`: The final status of the report generation.
21+
- `build_integration`: The type of build integration (e.g., "sdk", "non-sdk").
22+
23+
## Example Usage
24+
25+
```yaml
26+
name: CI with BrowserStack Report
27+
28+
on: [push]
29+
30+
jobs:
31+
test_and_report:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v3
36+
37+
# ... your test steps that trigger a BrowserStack build ...
38+
39+
- name: Fetch BrowserStack Report
40+
# If using a published version:
41+
# uses: your-org/browserstack-report-action@v1
42+
# If using a local version from the same repository:
43+
uses: ./.github/actions/browserstack-report-action
44+
with:
45+
browserstack-username: ${{ secrets.BROWSERSTACK_USERNAME }}
46+
browserstack-access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
47+
build-name: 'My Awesome App E2E Tests'
48+
# user-timeout can be specified if needed, e.g.:
49+
# user-timeout: '600'
50+
# Polling interval and max retries are determined by the API's first response.
51+
```
52+
53+
## Development
54+
55+
1. Clone the repository (or create these files in your existing one).
56+
2. Navigate to the `browserstack-report-action` directory.
57+
3. Run `npm install` to install dependencies.
58+
4. Make changes to the source code in the `src` directory or constants in the `config` directory.
59+
5. Run `npm run build` to compile the action to the `dist` directory.
60+
6. Run `npm test` to run unit tests.
61+
7. Run `npm run all` to run linting, tests, and build.
62+
63+
## Project Structure
64+
65+
```
66+
browserstack-report-action/
67+
├── .gitignore - Gitignore file
68+
├── .eslintrc.js - ESLint configuration
69+
├── action.yml - GitHub Action metadata
70+
├── package.json - Node.js package file
71+
├── README.md - Documentation
72+
├── config/ - Configuration files
73+
│ └── constants.js - Constants used throughout the action
74+
├── dist/ - Compiled code (generated by ncc)
75+
├── src/ - JavaScript source code
76+
│ ├── main.js - Main action code
77+
│ └── actionInput/ - Input handling and validation
78+
│ ├── index.js - ActionInput class
79+
│ └── inputValidator.js - InputValidator class
80+
└── test/ - Test files
81+
└── main.test.js - Tests for main.js
82+
```
83+
84+
## Notes
85+
86+
- 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.
87+
- 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.
88+
- The `report_status` values handled are: `in_progress`, `complete`, `tests_available`, `not_available`, `build_not_found`, `more_than_one_build_found`.
89+
- The HTML report from `report.basic_html` is added to the GitHub Actions summary.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 'BrowserStack Report Action'
2+
description: 'Fetches a BrowserStack report and displays it in the GitHub Actions summary.'
3+
author: 'GitHub Copilot'
4+
5+
inputs:
6+
browserstack-username:
7+
description: 'Your BrowserStack username.'
8+
required: true
9+
browserstack-access-key:
10+
description: 'Your BrowserStack access key.'
11+
required: true
12+
build-name:
13+
description: 'The name of the build on BrowserStack. Defaults to GitHub workflow name and run ID.'
14+
required: false
15+
user-timeout:
16+
description: 'User-defined timeout value (in seconds) to be sent to the report API.'
17+
required: false
18+
default: '300'
19+
20+
runs:
21+
using: 'node16'
22+
main: 'dist/index.js'
23+
24+
branding:
25+
icon: 'bar-chart-2'
26+
color: 'blue'
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module.exports = {
2+
// Default values
3+
DEFAULT_POLLING_INTERVAL_SECONDS: 30,
4+
DEFAULT_MAX_RETRIES: 10,
5+
DEFAULT_USER_TIMEOUT_SECONDS: 300,
6+
7+
// API simulation constants
8+
MAX_POLLS_FOR_IN_PROGRESS: 3,
9+
10+
// Report formats
11+
REPORT_FORMAT: {
12+
BASIC_HTML: 'basic_html',
13+
},
14+
15+
INPUT: {
16+
USERNAME: 'username',
17+
ACCESS_KEY: 'access-key',
18+
BUILD_NAME: 'build-name',
19+
TIMEOUT: 'report-timeout'
20+
},
21+
22+
// Report statuses
23+
REPORT_STATUS: {
24+
IN_PROGRESS: 'in_progress',
25+
COMPLETE: 'complete',
26+
TESTS_AVAILABLE: 'tests_available',
27+
NOT_AVAILABLE: 'not_available',
28+
BUILD_NOT_FOUND: 'build_not_found',
29+
MORE_THAN_ONE_BUILD_FOUND: 'more_than_one_build_found',
30+
},
31+
32+
// Integration types
33+
INTEGRATION_TYPE: {
34+
SDK: 'sdk',
35+
NON_SDK: 'non-sdk',
36+
},
37+
38+
// CI system identifiers
39+
CI_SYSTEM: {
40+
GITHUB_ACTIONS: 'github-actions',
41+
},
42+
};

0 commit comments

Comments
 (0)