Skip to content

Commit 5a72ddd

Browse files
authored
CI: attempt to serialize test runs (prebid#14049)
* Try to gauge running session from browserstack * automate, not app automate; separate to its own workflow * reintroduce retries * check on every chunk * jobs not steps * do not wait when not using browserstack * composite actions * remove stale yml * fix path
1 parent 5fdc56d commit 5a72ddd

3 files changed

Lines changed: 48 additions & 2 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Wait for browserstack sessions
2+
description: Wait until enough browserstack sessions have become available
3+
inputs:
4+
BROWSERSTACK_USER_NAME:
5+
description: "Browserstack user name"
6+
BROWSERSTACK_ACCESS_KEY:
7+
description: "Browserstack access key"
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- env:
13+
BROWSERSTACK_USERNAME: ${{ inputs.BROWSERSTACK_USER_NAME }}
14+
BROWSERSTACK_ACCESS_KEY: ${{ inputs.BROWSERSTACK_ACCESS_KEY }}
15+
shell: bash
16+
run: |
17+
while
18+
status=$(curl -u "${BROWSERSTACK_USERNAME}:${BROWSERSTACK_ACCESS_KEY}" \
19+
-X GET "https://api-cloud.browserstack.com/automate/plan.json" 2> /dev/null);
20+
running=$(jq '.parallel_sessions_running' <<< $status)
21+
max_running=$(jq '.parallel_sessions_max_allowed' <<< $status)
22+
queued=$(jq '.queued_sessions' <<< $status)
23+
max_queued=$(jq '.queued_sessions_max_allowed' <<< $status)
24+
spare=$(( ${max_running} + ${max_queued} - ${running} - ${queued} ))
25+
required=6
26+
echo "Browserstack status: ${running} sessions running, ${queued} queued, ${spare} free"
27+
(( ${required} > ${spare} ))
28+
do
29+
delay=$(( 60 + $(shuf -i 1-60 -n 1) ))
30+
echo "Waiting for ${required} sessions to free up, checking again in ${delay}s"
31+
sleep $delay
32+
done

.github/workflows/test-chunk.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,18 @@ jobs:
6767
local-testing: start
6868
local-identifier: random
6969

70+
- name: 'Wait for browserstack'
71+
if: ${{ inputs.serialize }}
72+
uses: ./.github/actions/wait-for-browserstack
73+
with:
74+
BROWSERSTACK_USER_NAME: ${{ secrets.BROWSERSTACK_USER_NAME }}
75+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
76+
7077
- name: Run tests
7178
uses: nick-fields/retry@v3
7279
with:
7380
timeout_minutes: 8
74-
max_attempts: 1
81+
max_attempts: 3
7582
command: ${{ inputs.cmd }}
7683

7784
- name: 'BrowserStackLocal Stop'

.github/workflows/test.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ jobs:
110110
secrets:
111111
BROWSERSTACK_USER_NAME: ${{ secrets.BROWSERSTACK_USER_NAME }}
112112
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
113+
113114
test-e2e:
114115
name: "End-to-end tests"
115116
needs: checkout
@@ -145,11 +146,17 @@ jobs:
145146
local-testing: start
146147
local-identifier: random
147148

149+
- name: 'Wait for browserstack'
150+
uses: ./.github/actions/wait-for-browserstack
151+
with:
152+
BROWSERSTACK_USER_NAME: ${{ secrets.BROWSERSTACK_USER_NAME }}
153+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
154+
148155
- name: Run tests
149156
uses: nick-fields/retry@v3
150157
with:
151158
timeout_minutes: 20
152-
max_attempts: 1
159+
max_attempts: 3
153160
command: npx gulp e2e-test
154161

155162
- name: 'BrowserStackLocal Stop'

0 commit comments

Comments
 (0)