forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (91 loc) · 3.23 KB
/
Copy pathtest-chunk.yml
File metadata and controls
103 lines (91 loc) · 3.23 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
name: Test chunk
on:
workflow_call:
inputs:
serialize:
required: false
type: boolean
cmd:
required: true
type: string
chunk-no:
required: true
type: number
wdir:
required: true
type: string
outputs:
wdir:
description: "Cache key for the working directory after running tests"
value: test-${{ inputs.cmd }}-${{ inputs.chunk-no }}-${{ github.run_id }}
secrets:
BROWSERSTACK_USER_NAME:
description: "Browserstack user name"
BROWSERSTACK_ACCESS_KEY:
description: "Browserstack access key"
concurrency:
# The following generates 'browserstack-<run_id>' when inputs.serialize is true, and a hopefully unique ID otherwise
# Ideally we'd like to serialize browserstack access across all workflows, but github's max queue length is only 1
# (cfr. https://github.com/orgs/community/discussions/12835)
# so we add the run_id to serialize only within one push / pull request (which has the effect of queueing e2e and unit tests)
group: ${{ inputs.serialize && 'browser' || github.run_id }}${{ inputs.serialize && 'stack' || inputs.cmd }}-${{ github.run_id }}
cancel-in-progress: false
jobs:
test:
name: "Test chunk ${{ inputs.chunk-no }}"
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USER_NAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
TEST_CHUNKS: 4
TEST_CHUNK: ${{ inputs.chunk-no }}
runs-on: ubuntu-latest
steps:
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Restore working directory
id: restore-dir
uses: actions/cache/restore@v4
with:
path: .
key: ${{ inputs.wdir }}
fail-on-cache-miss: true
- name: 'BrowserStack Env Setup'
uses: 'browserstack/github-actions/setup-env@master'
with:
username: ${{ secrets.BROWSERSTACK_USER_NAME}}
access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
- name: 'BrowserStackLocal Setup'
uses: 'browserstack/github-actions/setup-local@master'
with:
local-testing: start
local-identifier: random
- name: 'Wait for browserstack'
if: ${{ inputs.serialize }}
uses: ./.github/actions/wait-for-browserstack
with:
BROWSERSTACK_USER_NAME: ${{ secrets.BROWSERSTACK_USER_NAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
- name: Run tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 8
max_attempts: 3
command: ${{ inputs.cmd }}
- name: 'BrowserStackLocal Stop'
uses: 'browserstack/github-actions/setup-local@master'
with:
local-testing: stop
- name: Save working directory
uses: actions/cache/save@v4
with:
path: .
key: test-${{ inputs.cmd }}-${{ inputs.chunk-no }}-${{ github.run_id }}
- name: Verify cache
uses: actions/cache/restore@v4
with:
path: .
key: test-${{ inputs.cmd }}-${{ inputs.chunk-no }}-${{ github.run_id }}
lookup-only: true
fail-on-cache-miss: true