Skip to content

Commit 466f54d

Browse files
authored
Dump sdk to master (#15)
* adding source to yml as we are using chromeDriver now * create workflow for maven testing on testNG sample repo * add browserstack creds * add branch name * fix get env var from secrets * fix run multiple commands in one go * set env vars when building with maven * remove build step and add env var at root level * add CODEOWNERS for yml files * add codeowners and change profile name * add local WebDriver profile and webdriver manager * change profile names and run with bstack as per env var * update: added comments to describe chromedriver setup * run tests on PR and comment creation (#12) * run tests on PR and comment creation * fix pr comment * add conditions for tests trigger * add conditions for tests trigger * fix: conditional expression * fix: conditional expression format * fix: corrected conditions placement * add: java version 11 and ubuntu latest in matrices * add: print PR comment * fix: trigger issue comment event on sdk branch * update: add event action for issue comment event * remove: commenting condition * add conditional run for job (#13) * add conditional run for job * create another job for comment run * trigger tests on PR comment * create separate jobs for test run * run jobs consecutively * set max parallels in strategy * continue other tests when one fails
1 parent 2176434 commit 466f54d

File tree

8 files changed

+253
-117
lines changed

8 files changed

+253
-117
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github/workflows/*.yml @browserstack/asi-devs

.github/pull_request_template.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#### How to run tests?
2+
- Before running tests please take master merge in the PR
3+
- Comment RUN_TESTS to run maven tests
4+
5+
Note: Tests will also be triggered when PR is opened or reopened

.github/workflows/comment-run.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This job is to test different maven profiles in sdk branch again Pull Request raised
2+
# This workflow targets Java with Maven execution
3+
4+
name: TestNG SDK Test workflow for Maven on comment RUN_TESTS
5+
6+
on:
7+
issue_comment:
8+
types: [ created, edited ]
9+
10+
jobs:
11+
comment-run:
12+
if: contains(github.event.comment.body, 'RUN_TESTS')
13+
runs-on: ${{ matrix.os }}
14+
continue-on-error: true
15+
strategy:
16+
max-parallel: 3
17+
matrix:
18+
java: [ '8', '11', '17' ]
19+
os: [ 'macos-latest', 'windows-latest', 'ubuntu-latest' ]
20+
name: TestNG Repo ${{ matrix.Java }} - ${{ matrix.os }} Sample
21+
env:
22+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
23+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
24+
25+
steps:
26+
- uses: actions/checkout@v3
27+
- name: Set up Java
28+
uses: actions/setup-java@v3
29+
with:
30+
distribution: 'temurin'
31+
java-version: ${{ matrix.java }}
32+
- name: Run mvn test
33+
run: |
34+
mvn compile
35+
mvn test
36+
- name: Run mvn profile sample-local-test
37+
run: |
38+
mvn compile
39+
mvn test -P sample-local-test
40+
- name: Run mvn profile sample-test
41+
run: |
42+
mvn compile
43+
mvn test -P sample-test

.github/workflows/maven.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This job is to test different maven profiles in sdk branch again Pull Request raised
2+
# This workflow targets Java with Maven execution
3+
4+
name: TestNG SDK Test workflow for Maven
5+
6+
on:
7+
pull_request:
8+
branches: [ "master", "sdk" ]
9+
types: [ opened, reopened ]
10+
11+
jobs:
12+
maven-run:
13+
runs-on: ${{ matrix.os }}
14+
continue-on-error: true
15+
strategy:
16+
max-parallel: 3
17+
matrix:
18+
java: [ '8', '11', '17' ]
19+
os: [ 'macos-latest', 'windows-latest', 'ubuntu-latest' ]
20+
name: TestNG Repo ${{ matrix.Java }} - ${{ matrix.os }} Sample
21+
env:
22+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
23+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
24+
25+
steps:
26+
- uses: actions/checkout@v3
27+
- name: Set up Java
28+
uses: actions/setup-java@v3
29+
with:
30+
distribution: 'temurin'
31+
java-version: ${{ matrix.java }}
32+
- name: Run mvn test
33+
run: |
34+
mvn compile
35+
mvn test
36+
- name: Run mvn profile sample-local-test
37+
run: |
38+
mvn compile
39+
mvn test -P sample-local-test
40+
- name: Run mvn profile sample-test
41+
run: |
42+
mvn compile
43+
mvn test -P sample-test

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
- Clone the repository
1212
- Replace YOUR_USERNAME and YOUR_ACCESS_KEY with your BrowserStack access credentials in browserstack.yml.
1313
- Install dependencies `mvn compile`
14-
- To run the test suite having cross-platform with parallelization, run `mvn test -P sample-test`
15-
- To run local tests, run `mvn test -P sample-local-test`
14+
- To run the test suite with local webdriver, run `mvn test -P skip-browserstack-test`
15+
- To run the test suite having cross-platform with parallelization on browserstack, run `mvn test -P sample-test`
16+
- To run local (privately hosted websites) tests on browserstack, run `mvn test -P sample-local-test`
1617

1718
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
1819

@@ -68,8 +69,9 @@ This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow t
6869

6970
- Clone the repository
7071
- Install dependencies `gradle build`
71-
- To run the test suite having cross-platform with parallelization, run `gradle sampleTest`
72-
- To run local tests, run `gradle sampleLocalTest`
72+
- To run the test suite with local webdriver, run `gradle skipBrowserstackTest`
73+
- To run the test suite having cross-platform with parallelization on browserstack, run `gradle sampleTest`
74+
- To run local (privately hosted websites) tests on browserstack, run `gradle sampleLocalTest`
7375

7476
Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)
7577

build.gradle

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ repositories { mavenCentral() }
66

77
dependencies {
88
implementation 'org.testng:testng:7.4.0'
9-
implementation 'commons-io:commons-io:1.3.2'
9+
implementation 'commons-io:commons-io:2.11.0'
1010
implementation 'org.seleniumhq.selenium:selenium-java:4.1.4'
11-
implementation 'com.browserstack:browserstack-local-java:1.0.6'
1211
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
12+
implementation 'io.github.bonigarcia:webdrivermanager:5.3.0'
1313
compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'
1414
}
1515

@@ -24,6 +24,16 @@ tasks.withType(JavaCompile) {
2424
options.encoding = 'UTF-8'
2525
}
2626

27+
task skipBrowserstackTest(type: Test) {
28+
useTestNG() {
29+
environment = [ 'BROWSERSTACK_AUTOMATION': 'false' ]
30+
dependsOn cleanTest
31+
useDefaultListeners = true
32+
suites "config/sample-test.testng.xml"
33+
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
34+
}
35+
}
36+
2737
task sampleTest(type: Test) {
2838
useTestNG() {
2939
dependsOn cleanTest

0 commit comments

Comments
 (0)