Skip to content

Commit e709586

Browse files
agarneha1331francisf
authored andcommitted
Added github action
1 parent 8ae61f6 commit e709586

File tree

2 files changed

+68
-14
lines changed

2 files changed

+68
-14
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
*.yml @browserstack/asi-devs
1+
.github/workflows/*.yml @browserstack/asi-devs
Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,88 @@
1-
#This job tests changes made in main branch via PRs.
1+
# This job is to test different npm profiles in main branch against Pull Requests raised
2+
# This workflow targets jest-js
3+
4+
name: Jest-js Test workflow for Node from workflow_dispatch
25

3-
name: Review changes from PRs
4-
run-name: ${{ github.actor }} has created/updated a PR
56
on:
6-
pull_request:
7-
branches: [ main ]
7+
workflow_dispatch:
8+
inputs:
9+
pull_request_number:
10+
description: 'The pull request number to build'
11+
required: true
812

913
jobs:
10-
build:
14+
comment-run:
15+
runs-on: ${{ matrix.os }}
1116
strategy:
17+
fail-fast: false
18+
max-parallel: 3
1219
matrix:
13-
version: [ 14, 16, 18 ]
20+
node: ['14', '16', '18']
1421
os: [ macos-latest, windows-latest, ubuntu-latest ]
15-
runs-on: ${{ matrix.os }}
16-
name: JestJS repo ${{ matrix.version }} - ${{ matrix.os }} Sample
22+
name: Jest-js Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
1723
env:
1824
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
1925
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
2026

2127
steps:
2228
- uses: actions/checkout@v3
23-
- uses: actions/setup-node@v3
2429
with:
25-
node-version: ${{ matrix.version }}
26-
27-
- name: Setup environment for testing
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: Jest-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
2860
run: npm install
2961

3062
- name: Run sample tests
3163
run: npm run sample-test
3264

3365
- name: Run local tests
3466
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: Jest-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)