Skip to content

Commit

Permalink
Merge pull request #1 from BrowserStackCE/develop
Browse files Browse the repository at this point in the history
first commit
  • Loading branch information
Yatin2108 committed Nov 9, 2023
2 parents 5d704cd + e7f67a0 commit 800b411
Show file tree
Hide file tree
Showing 12 changed files with 9,981 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.github/* @browserstack/asi-devs

* @browserstack/automate-public-repos
48 changes: 48 additions & 0 deletions .github/workflows/Semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Name of this GitHub Actions workflow.
name: Semgrep

on:
# Scan changed files in PRs (diff-aware scanning):
# The branches below must be a subset of the branches above
pull_request:
branches: ["master", "main"]
push:
branches: ["master", "main"]
schedule:
- cron: '0 6 * * *'


permissions:
contents: read

jobs:
semgrep:
# User definable name of this GitHub Actions job.
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
name: semgrep/ci
# If you are self-hosting, change the following `runs-on` value:
runs-on: ubuntu-latest

container:
# A Docker image with Semgrep installed. Do not change this.
image: returntocorp/semgrep

# Skip any PR created by dependabot to avoid permission issues:
if: (github.actor != 'dependabot[bot]')

steps:
# Fetch project source with GitHub Actions Checkout.
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
# Run the "semgrep ci" command on the command line of the docker image.
- run: semgrep ci --sarif --output=semgrep.sarif
env:
# Add the rules that Semgrep uses by setting the SEMGREP_RULES environment variable.
SEMGREP_RULES: p/default # more at semgrep.dev/explore

- name: Upload SARIF file for GitHub Advanced Security Dashboard
uses: github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e # v2.20.0
with:
sarif_file: semgrep.sarif
if: always()
85 changes: 85 additions & 0 deletions .github/workflows/reviewing_changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This job is to test different npm profiles in master branch against Pull Request raised
# This workflow targets wdio

name: NodeJS Test workflow on workflow_dispatch

on:
workflow_dispatch:
inputs:
commit_sha:
description: 'The full commit id to build'
required: true

jobs:
comment-run:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 3
matrix:
node: ['14', '16', '18']
os: [ macos-latest, windows-latest, ubuntu-latest ]
name: WebDriverIO Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.commit_sha }}
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
id: status-check-in-progress
env:
job_name: WebDriverIO Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
commit_sha: ${{ github.event.inputs.commit_sha }}
with:
github-token: ${{ github.token }}
script: |
const result = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: process.env.job_name,
head_sha: process.env.commit_sha,
status: 'in_progress'
}).catch((err) => ({status: err.status, response: err.response}));
console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`)
if (result.status !== 201) {
console.log('Failed to create check run')
}
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
run: npm install

- name: Run sample tests
run: npm run test

- name: Run local tests
run: npm run local

- if: always()
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
id: status-check-completed
env:
conclusion: ${{ job.status }}
job_name: WebDriverIO Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
commit_sha: ${{ github.event.inputs.commit_sha }}
with:
github-token: ${{ github.token }}
script: |
const result = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: process.env.job_name,
head_sha: process.env.commit_sha,
status: 'completed',
conclusion: process.env.conclusion
}).catch((err) => ({status: err.status, response: err.response}));
console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`)
if (result.status !== 201) {
console.log('Failed to create check run')
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
local.log
errorShots
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# automate-percy-wdio
# automate-percy-wdio

[WebdriverIO](http://webdriver.io/) Integration with BrowserStack.

![BrowserStack Logo](https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-header.png?1469004780)

<img src = "https://webdriver.io/img/webdriverio.png" height = "100">

## Setup
* Clone the repo
* Install dependencies `npm install`
* You can setup environment variables for all sample repos (see Notes) or update `*.conf.js` files inside the `conf/` directory with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
* Create a [Percy Automate Project](https://www.browserstack.com/docs/percy/get-started/create-project)
* Setup the [PERCY_TOKEN](https://www.browserstack.com/docs/percy/get-started/set-env-var) as the environment variable.

## Running your tests
- To run parallel tests, run `npx percy exec -- npm run test`
- To run local test, run `npx percy exec -- npm run local`

## Additional Resources
* [Documentation for writing automate test scripts in Node](https://www.browserstack.com/automate/node)
* [Customizing your tests on BrowserStack](https://www.browserstack.com/automate/capabilities)
* [Browsers & mobile devices for selenium testing on BrowserStack](https://www.browserstack.com/list-of-browsers-and-platforms?product=automate)
* [Using REST API to access information about your tests via the command-line interface](https://www.browserstack.com/automate/rest-api)
29 changes: 29 additions & 0 deletions conf/base.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
exports.config = {
user: process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
key: process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',

updateJob: false,
specs: ['./tests/specs/test.js'],
exclude: [],

logLevel: 'warn',
coloredLogs: true,
screenshotPath: './errorShots/',
baseUrl: '',
waitforTimeout: 10000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
hostname: 'hub.browserstack.com',
services: [['browserstack']],

before: function () {
var chai = require('chai');
global.expect = chai.expect;
chai.Should();
},
framework: 'mocha',
mochaOpts: {
ui: 'bdd',
timeout: 60000,
},
};
31 changes: 31 additions & 0 deletions conf/local-test.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { config: baseConfig } = require('./base.conf.js');

const localConfig = {
// Adding browserstackLocal to browserstack-service to initiate local binary
services: [
[
'browserstack',
{
browserstackLocal: true,
buildIdentifier: '#${BUILD_NUMBER}',
opts: {
forcelocal: false,
localIdentifier: 'webdriverio-browserstack-repo'
}
},
],
],
capabilities: [
{
browserName: 'chrome',
browserVersion: 'latest',
'bstack:options': {
buildName: 'browserstack build',
source: 'webdriverio:sample-master:v1.2'
}
},
],
specs: ['./tests/specs/local_test.js'],
};

exports.config = { ...baseConfig, ...localConfig };
49 changes: 49 additions & 0 deletions conf/test.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const { config: baseConfig } = require('./base.conf.js');

const parallelConfig = {
maxInstances: 10,
commonCapabilities: {
'bstack:options': {
buildName: 'browserstack build',
source: 'webdriverio:sample-master:v1.2'
}
},
services: [
[
'browserstack',
{ buildIdentifier: '#${BUILD_NUMBER}' },
],
],
capabilities: [
{
browserName: 'chrome',
browserVersion: 'latest',
'bstack:options': {
os: 'Windows',
osVersion: '10',
},
},
{
browserName: 'safari',
browserVersion: 'latest',
'bstack:options': {
os: 'OS X',
osVersion: 'Big Sur',
},
},
{
browserName: 'chrome',
'bstack:options': {
deviceName: 'Samsung Galaxy S20',
},
},
],
};

exports.config = { ...baseConfig, ...parallelConfig };

// Code to support common capabilities
exports.config.capabilities.forEach(function (caps) {
for (var i in exports.config.commonCapabilities)
caps[i] = { ...caps[i], ...exports.config.commonCapabilities[i]};
});
Loading

0 comments on commit 800b411

Please sign in to comment.