forked from DevExpress/testcafe-hammerhead
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (99 loc) · 3.89 KB
/
test-client-cloud.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
name: Test Client (Cloud)
on:
workflow_dispatch:
inputs:
sha:
desciption: 'The test commit SHA or ref'
required: true
default: 'master'
merged_sha:
description: 'The merge commit SHA'
deploy_run_id:
description: 'The ID of a deployment workspace run with artifacts'
jobs:
test:
runs-on: ubuntu-latest
environment: test-client
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
# NOTE: Test server on Android Emulator 7.1 and later can be accessed only via hostname.
# We are forced to add this variable to say the 'qunit-harness' module uses the hostname for the test server URL.
# https://github.com/AlexanderMoskovkin/qunit-harness/blob/master/src/index.js#L119
TRAVIS: true
steps:
- uses: actions/github-script@v3
with:
script: |
await github.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.inputs.sha,
context: context.workflow,
state: 'pending',
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
- uses: actions/checkout@v2
with:
ref: ${{github.event.inputs.merged_sha || github.event.inputs.sha}}
- uses: actions/setup-node@v2
with:
node-version: 14
- uses: actions/github-script@v3
with:
script: |
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
let artifacts = {};
for(let i = 0;i<36&&!artifacts.total_count;i++,await delay(5000)) {
try {
({ data: artifacts } = await github.actions.listWorkflowRunArtifacts({
repo: context.repo.repo,
owner: context.repo.owner,
run_id: context.payload.inputs.deploy_run_id
}));
}
catch (e) {
console.log(e);
}
}
const { data: artifact } = await github.request(artifacts.artifacts.find(artifact=> artifact.name === 'npm').archive_download_url);
require('fs').writeFileSync(require('path').join(process.env.GITHUB_WORKSPACE, 'package.zip'), Buffer.from(artifact))
- run: |
unzip package.zip
tar --strip-components=1 -xzf testcafe-hammerhead-*.tgz
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npx gulp test-client-cloud --no-build
timeout-minutes: 60
- uses: actions/github-script@v3
with:
script: |
await github.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.inputs.sha,
context: context.workflow,
state: 'success',
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
- uses: actions/github-script@v3
if: failure() || cancelled()
with:
script: |
await github.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.payload.inputs.sha,
context: context.workflow,
state: 'failure',
target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});