forked from DevExpress/testcafe-hammerhead
-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (125 loc) · 4.81 KB
/
health-monitor.yml
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Health Monitor
on:
schedule:
- cron: '0 2 * * *'
issue_comment:
types: [ created ]
workflow_dispatch:
jobs:
main-branch:
if: |
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch'
runs-on: windows-latest
steps:
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Checkout the Health Monitor repository
uses: actions/checkout@v2
with:
repository: ${{ secrets.HEALTH_MONITOR_REPO }}
token: ${{ secrets.CLONE_PRIVATE_REPOS_TOKEN }}
path: ./HealthMonitor/health-monitor
- name: Checkout the testcafe-hammerhead repository
uses: actions/checkout@v2
with:
path: ./HealthMonitor/testcafe-hammerhead
- name: Write the current testcafe-hammerhead abbreviated commit hash to a file
run: git log -1 --pretty=format:"%h" > ..\health-monitor\last-commit-id.txt
working-directory: ./HealthMonitor/testcafe-hammerhead
- name: Install testcafe-hammerhead dependencies and run a build task
run: |
npm i
npx gulp build
working-directory: ./HealthMonitor/testcafe-hammerhead
- name: Install Health Monitor dependencies
run: |
npm i
npm i testcafe-hammerhead ../testcafe-hammerhead --save
working-directory: ./HealthMonitor/health-monitor
- name: Run Health Monitor
run: npx gulp health-monitor
working-directory: ./HealthMonitor/health-monitor
pr-branch:
if: |
github.event.issue.pull_request &&
(
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'COLLABORATOR' ||
github.event.comment.author_association == 'MEMBER'
) &&
github.event.comment.body == 'run monitor'
runs-on: windows-latest
steps:
- name: Create a PR comment with a job URL
uses: actions/github-script@v3
with:
script: |
const request = {
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId
}
const runJobs = await github.actions.listJobsForWorkflowRun(request)
.then(res => res.data.jobs)
.catch(err => {
core.setFailed(`Request failed with error ${err}`);
});
const currentJob = runJobs.find(job => job.name === context.job);
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Monitor started on this PR.\nDetails: ${currentJob.html_url}?check_suite_focus=true`
});
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Checkout the Health Monitor repository
uses: actions/checkout@v2
with:
repository: ${{ secrets.HEALTH_MONITOR_REPO }}
token: ${{ secrets.CLONE_PRIVATE_REPOS_TOKEN }}
path: ./HealthMonitor/health-monitor
- name: Get PR info to checkout testcafe-hammerhead branch
uses: actions/github-script@v3
id: get-pr-to-checkout
with:
script: |
const request = {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
};
try {
const result = await github.pulls.get(request);
return result.data;
}
catch (err) {
core.setFailed(`Request failed with the following error:\n${err}`);
}
- name: Checkout the testcafe-hammerhead PR branch
uses: actions/checkout@v2
with:
repository: ${{ fromJSON(steps.get-pr-to-checkout.outputs.result).head.repo.full_name }}
ref: ${{ fromJSON(steps.get-pr-to-checkout.outputs.result).head.ref }}
path: ./HealthMonitor/testcafe-hammerhead
- name: Write the current testcafe-hammerhead abbreviated commit hash to a file
run: git log -1 --pretty=format:"%h" > ..\health-monitor\last-commit-id.txt
working-directory: ./HealthMonitor/testcafe-hammerhead
- name: Install testcafe-hammerhead dependencies and run a build task
run: |
npm i
npx gulp build
working-directory: ./HealthMonitor/testcafe-hammerhead
- name: Install Health Monitor dependencies
run: |
npm i
npm i testcafe-hammerhead ../testcafe-hammerhead --save
working-directory: ./HealthMonitor/health-monitor
- name: Run Health Monitor
run: npx gulp health-monitor
working-directory: ./HealthMonitor/health-monitor