Skip to content

Commit 366bde9

Browse files
authored
Merge pull request #53 from agarneha1331/create_github_action
Create GitHub action
2 parents ca5ea05 + 930e49b commit 366bde9

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github/* @browserstack/asi-devs
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# This job is to test different npm profiles in master branch against Pull Request raised
2+
# This workflow targets cucumber-js
3+
4+
name: NodeJS SDK Test workflow on workflow_dispatch
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
pull_request_number:
10+
description: 'The pull request number to build'
11+
required: true
12+
13+
jobs:
14+
comment-run:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
max-parallel: 3
19+
matrix:
20+
node: ['14', '16', '18']
21+
os: [ macos-latest, windows-latest, ubuntu-latest ]
22+
name: Cucumber-js Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
23+
env:
24+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
25+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
26+
27+
steps:
28+
- uses: actions/checkout@v3
29+
with:
30+
ref: refs/pull/${{ github.event.inputs.pull_request_number }}/head
31+
- name: Fetch Commit SHA
32+
run: |
33+
git log -1 --format='%H'
34+
echo "commit_sha=$(git log -1 --format='%H')" >> $GITHUB_ENV
35+
echo "commit_sha=$(git log -1 --format='%H')" >> $env:GITHUB_ENV
36+
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
37+
id: status-check-in-progress
38+
env:
39+
job_name: Cucumber-js Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
40+
with:
41+
github-token: ${{ github.token }}
42+
script: |
43+
const result = await github.rest.checks.create({
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
name: process.env.job_name,
47+
head_sha: process.env.commit_sha,
48+
status: 'in_progress'
49+
}).catch((err) => ({status: err.status, response: err.response}));
50+
console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`)
51+
if (result.status !== 201) {
52+
console.log('Failed to create check run')
53+
}
54+
- name: Setup node
55+
uses: actions/setup-node@v3
56+
with:
57+
node-version: ${{ matrix.node }}
58+
59+
- name: Install dependencies
60+
run: npm install
61+
62+
- name: Run sample tests
63+
run: npm run sample-test
64+
65+
- name: Run local tests
66+
run: npm run sample-local-test
67+
68+
- if: always()
69+
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
70+
id: status-check-completed
71+
env:
72+
conclusion: ${{ job.status }}
73+
job_name: Cucumber-js Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
74+
with:
75+
github-token: ${{ github.token }}
76+
script: |
77+
const result = await github.rest.checks.create({
78+
owner: context.repo.owner,
79+
repo: context.repo.repo,
80+
name: process.env.job_name,
81+
head_sha: process.env.commit_sha,
82+
status: 'completed',
83+
conclusion: process.env.conclusion
84+
}).catch((err) => ({status: err.status, response: err.response}));
85+
console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`)
86+
if (result.status !== 201) {
87+
console.log('Failed to create check run')
88+
}

0 commit comments

Comments
 (0)