-
Notifications
You must be signed in to change notification settings - Fork 63
118 lines (106 loc) · 4.25 KB
/
Copy pathreviewing_changes.yml
File metadata and controls
118 lines (106 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# This job is to test different npm profiles in master branch against Pull Request raised
# This workflow targets nightwatch
name: NodeJS Test workflow on workflow_dispatch
on:
workflow_dispatch:
inputs:
commit_sha:
description: 'The full 40-character commit SHA on master to build'
required: true
permissions:
contents: read
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: Nightwatch Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
permissions:
contents: read
checks: write
steps:
- name: Validate commit_sha format
env:
COMMIT_SHA: ${{ github.event.inputs.commit_sha }}
shell: bash
run: |
if [[ ! "$COMMIT_SHA" =~ ^[0-9a-f]{40}$ ]]; then
echo "::error::commit_sha must be a 40-character lowercase hex SHA (got: $COMMIT_SHA)"
exit 1
fi
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ github.event.inputs.commit_sha }}
fetch-depth: 0
persist-credentials: false
- name: Verify commit_sha is reachable from master
env:
COMMIT_SHA: ${{ github.event.inputs.commit_sha }}
shell: bash
run: |
git fetch origin master:refs/remotes/origin/master
if ! git merge-base --is-ancestor "$COMMIT_SHA" origin/master; then
echo "::error::commit_sha $COMMIT_SHA is not an ancestor of origin/master; refusing to run with attacker-controlled refs"
exit 1
fi
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
id: status-check-in-progress
env:
job_name: Nightwatch 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@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm ci
- name: Run sample tests
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
run: npm run sample-test
- name: Run local tests
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
run: npm run sample-local-test
- if: always()
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
id: status-check-completed
env:
conclusion: ${{ job.status }}
job_name: Nightwatch 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')
}