-
Notifications
You must be signed in to change notification settings - Fork 39
cad reporting browserstack-report action #61
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
Merged
Merged
Changes from 50 commits
Commits
Show all changes
103 commits
Select commit
Hold shift + click to select a range
f85cbf1
cad reporting browserstack-report action
shandli123 1191a0a
fix report timeout input name
shandli123 24ad8b8
input params change
shandli123 c9c01d8
testing with mock
shandli123 e3ed5d0
fixes
shandli123 9c3a9d4
update html
shandli123 7a34ff7
remove title
shandli123 8c8824a
artifact addition
shandli123 ecb45cd
artifact addition package name
shandli123 8f1c36e
artifact addition package name
shandli123 9e72c6c
artifact addition package name
shandli123 15d297d
artifact addition package name
shandli123 2ece26b
artifact addition package name
shandli123 12cf39a
artifact addition package name
shandli123 e0687b5
add fix for artifact
shandli123 6291e29
add fix for artifact
shandli123 c492cc5
add fix for artifact
shandli123 f19c9ec
add fix for artifact
shandli123 efc800e
add fix for artifact
shandli123 47c3991
add fix for artifact
shandli123 a58af3c
add fix for artifact
shandli123 408dbd0
add fix for artifact
shandli123 f823dbb
add fix for artifact
shandli123 b5ef1d0
add fix for artifact debug
shandli123 daa6a94
add fix for artifact debug
shandli123 aa49dfd
add fix for artifact debug
shandli123 b2e7673
add fix for artifact debug
shandli123 472c5f1
add fix for artifact debug
shandli123 96b6c96
add fix for artifact debug
shandli123 7c0b532
add fix for artifact debug
shandli123 7410733
add fix for artifact debug
shandli123 daa63f3
add fix for artifact debug
shandli123 f2653b1
add fix for artifact debug
shandli123 e375ae4
add fix for artifact debug
shandli123 afdff2b
add fix for artifact debug
shandli123 f8d1609
add fix for artifact debug
shandli123 6a72559
add fix for artifact debug
shandli123 f1b38b6
add fix for artifact debug
shandli123 ea45eae
add fix for artifact debug package.json change
shandli123 b072b0e
add fix for artifact debug package.json change
shandli123 bcbc474
add fix for artifact debug package.json change
shandli123 c6c1a35
add fix for artifact debug package.json change
shandli123 b98259e
artifact name update
shandli123 332a73c
linting fixes
shandli123 e748ba4
adding default numbers
shandli123 a88ad67
adding default numbers and sanitizing
shandli123 110767d
camel case params
shandli123 721b7c4
linting fixes
shandli123 ef251f9
readme update
shandli123 5b916a5
Update browserstack-report-action/src/utils/UploadFileForArtifact.js
shandli123 412efc7
commemnt resolution
shandli123 7a08922
commemnt resolution
shandli123 00f0327
updating buildCreatedAt type to timestamp
shandli123 4880a2c
status variable fix
shandli123 31f135e
adding check for intial report fetching
shandli123 2f790e5
remove additional error scenarios
shandli123 0b6cc9c
adding default time out
shandli123 a21daaf
refactoring code
shandli123 d9b6328
removing static function
shandli123 cdffece
removing static function
shandli123 064ba03
adding pollingInterval setter
shandli123 b777462
removing static function
shandli123 d5ff664
adding new variable for code clarity
shandli123 fed47c9
test
shandli123 33edbc7
testing \n revert
shandli123 df497c5
removing mock service
shandli123 6dda639
contract changes
shandli123 988c968
errorResponse update
shandli123 7bc8f93
errorResponse update static invoke
shandli123 a7e620d
verbose messaging
shandli123 3a032bd
test-commit
shandli123 04b2a62
debugging
shandli123 b641fd5
debugging
shandli123 6ddd855
test
shandli123 b92b9a0
test user timeout
shandli123 82a071e
logging response
shandli123 8c68c32
adding params back again
shandli123 7b56dec
check fix
shandli123 ab527d0
removing time stamp
shandli123 490bf8d
adding html separately
shandli123 f53efd8
adding html separately
shandli123 46d0432
additional brackets remove
shandli123 077f49e
rendering raw html
shandli123 0234f94
rendering raw html
shandli123 09f4bce
stringifying
shandli123 54dd0b4
stringifying remove
shandli123 5349b48
stringifying remove
shandli123 a9f8825
stringifying remove
shandli123 578f88d
adding html tag again
shandli123 28bc084
adding sanitisation
shandli123 f44ed7f
adding sanitisation
shandli123 085bed4
adding sanitisation
shandli123 e7a962d
adding sanitisation
shandli123 276dff3
formatting code
shandli123 8f65279
remove custom heading
shandli123 6db244b
changing o11y url to prod
shandli123 63688e3
increasing user default timeout
shandli123 19670e5
updating Github actions to push package-lock
shandli123 169960b
adding limits in timeout
shandli123 44e7034
adding limits in timeout
shandli123 74fc743
adding limits in timeout
shandli123 e524430
adding limits in timeout
shandli123 064d4fb
json changes
shandli123 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,24 @@ | ||
module.exports = { | ||
env: { | ||
node: true, | ||
es2020: true, | ||
mocha: true, | ||
}, | ||
extends: 'airbnb-base', | ||
parserOptions: { | ||
ecmaVersion: 11, | ||
sourceType: 'script', | ||
}, | ||
rules: { | ||
semi: ['error', 'always'], | ||
indent: ['error', 2, { SwitchCase: 1 }], | ||
quotes: 'off', | ||
'consistent-return': 'off', | ||
'no-underscore-dangle': 'off', | ||
'no-case-declarations': 'error', | ||
'prefer-destructuring': ['error', { object: true, array: false }], | ||
'no-restricted-syntax': 'off', | ||
'linebreak-style': 'off', | ||
}, | ||
ignorePatterns: ['dist/index.js'], | ||
}; |
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,13 @@ | ||
# Node | ||
node_modules/ | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
package-lock.json | ||
|
||
# Misc | ||
.DS_Store | ||
|
||
# Coverage | ||
coverage/ | ||
.nyc_output/ |
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,82 @@ | ||
# 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 | ||
|
||
```yaml | ||
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.: | ||
user-timeout: '600' | ||
``` | ||
|
||
## 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. |
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,26 @@ | ||
name: 'BrowserStack Report Action' | ||
description: 'Fetches a BrowserStack report and displays it in the GitHub Actions summary.' | ||
author: 'BrowserStack' | ||
|
||
inputs: | ||
username: | ||
description: 'Your BrowserStack username.' | ||
required: true | ||
access-key: | ||
description: 'Your BrowserStack access key.' | ||
required: true | ||
build-name: | ||
description: 'The name of the build on BrowserStack. Defaults to GitHub workflow name and run ID.' | ||
required: false | ||
report-timeout: | ||
description: 'User-defined timeout value (in seconds) to be sent to the report API.' | ||
required: false | ||
default: '300' | ||
|
||
runs: | ||
using: 'node16' | ||
main: 'dist/index.js' | ||
|
||
branding: | ||
icon: 'bar-chart-2' | ||
color: 'blue' |
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,50 @@ | ||
module.exports = { | ||
// Default values | ||
DEFAULT_POLLING_INTERVAL_SECONDS: 3, | ||
DEFAULT_MAX_RETRIES: 3, | ||
DEFAULT_USER_TIMEOUT_SECONDS: 10, | ||
|
||
// API simulation constants | ||
MAX_POLLS_FOR_IN_PROGRESS: 3, | ||
|
||
// Report formats | ||
REPORT_FORMAT: { | ||
BASIC_HTML: 'basicHtml', | ||
RICH_HTML: 'richHtml', | ||
}, | ||
|
||
INPUT: { | ||
USERNAME: 'username', | ||
ACCESS_KEY: 'access-key', | ||
BUILD_NAME: 'build-name', | ||
TIMEOUT: 'report-timeout', | ||
}, | ||
|
||
// Report statuses | ||
REPORT_STATUS: { | ||
IN_PROGRESS: 'IN_PROGRESS', | ||
COMPLETED: 'COMPLETED', | ||
TESTS_AVAILABLE: 'TEST_AVAILABLE', | ||
shandli123 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
NOT_AVAILABLE: 'NOT_AVAILABLE', | ||
BUILD_NOT_FOUND: 'BUILD_NOT_FOUND', | ||
MULTIPLE_BUILD_FOUND: 'MULTIPLE_BUILD_FOUND', | ||
}, | ||
|
||
// Integration types | ||
INTEGRATION_TYPE: { | ||
SDK: 'sdk', | ||
NON_SDK: 'non-sdk', | ||
}, | ||
|
||
// CI system identifiers | ||
CI_SYSTEM: { | ||
GITHUB_ACTIONS: 'github-actions', | ||
}, | ||
|
||
// REPORT_REQUEST_STATE | ||
REPORT_REQUEST_STATE: { | ||
FIRST: 'FIRST', | ||
POLL: 'POLL', | ||
LAST: 'LAST', | ||
}, | ||
}; |
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.
Uh oh!
There was an error while loading. Please reload this page.