Skip to content

Commit f7c512a

Browse files
committed
chore: add some changes to the workflow
1 parent 5f2a6a6 commit f7c512a

1 file changed

Lines changed: 81 additions & 15 deletions

File tree

.github/workflows/tests.yml

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
branches:
66
- main
77
pull_request:
8+
workflow_dispatch:
9+
schedule:
10+
- cron: '0 */2 * * *' # Every 2 hours; controlled by ENABLE_SCHEDULED_TESTS + SCHEDULED_TESTS_UNTIL vars
811

912
permissions:
1013
contents: read
@@ -115,15 +118,54 @@ jobs:
115118
!.tmp/testDiff/
116119
!.next/
117120
121+
schedule-gate:
122+
name: 🗓️ Schedule Gate
123+
runs-on: ubuntu-latest
124+
if: github.event_name == 'schedule'
125+
outputs:
126+
enabled: ${{ steps.check.outputs.enabled }}
127+
branch: ${{ steps.check.outputs.branch }}
128+
steps:
129+
- name: Check ENABLE_SCHEDULED_TESTS and SCHEDULED_TESTS_UNTIL
130+
id: check
131+
run: |
132+
if [[ "${{ vars.ENABLE_SCHEDULED_TESTS }}" != "true" ]]; then
133+
echo "Scheduled tests disabled (ENABLE_SCHEDULED_TESTS != true)"
134+
echo "enabled=false" >> "$GITHUB_OUTPUT"
135+
exit 0
136+
fi
137+
until_date="${{ vars.SCHEDULED_TESTS_UNTIL }}"
138+
if [[ -z "$until_date" ]]; then
139+
echo "No expiry date set (SCHEDULED_TESTS_UNTIL is empty)"
140+
echo "enabled=false" >> "$GITHUB_OUTPUT"
141+
exit 0
142+
fi
143+
now=$(date -u +%s)
144+
until=$(date -u -d "$until_date 23:59:59" +%s)
145+
if (( now <= until )); then
146+
echo "Schedule active until $until_date"
147+
echo "enabled=true" >> "$GITHUB_OUTPUT"
148+
echo "branch=${{ vars.SCHEDULED_TESTS_BRANCH || 'main' }}" >> "$GITHUB_OUTPUT"
149+
else
150+
echo "Schedule window expired on $until_date"
151+
echo "enabled=false" >> "$GITHUB_OUTPUT"
152+
fi
153+
118154
ci-pr-desktop-web:
119155
name: 🔄 💻 CI PR Run Desktop Web Tests on LambdaTest
120156
runs-on: ubuntu-latest
121-
if: |
122-
github.event_name == 'pull_request' &&
123-
github.actor != 'dependabot[bot]'
157+
needs: [schedule-gate]
158+
if: >-
159+
always() && (
160+
(github.event_name == 'pull_request' && github.actor != 'dependabot[bot]') ||
161+
github.event_name == 'workflow_dispatch' ||
162+
(github.event_name == 'schedule' && needs.schedule-gate.outputs.enabled == 'true')
163+
)
124164
steps:
125165
- name: ⬇️ Checkout Repository
126166
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
167+
with:
168+
ref: ${{ needs.schedule-gate.outputs.branch || github.ref }}
127169

128170
- name: 📦 Setup pnpm
129171
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
@@ -171,12 +213,18 @@ jobs:
171213
ci-pr-android-web:
172214
name: 🔄 🤖 🌐 CI PR Run Android Web Tests on LambdaTest
173215
runs-on: ubuntu-latest
174-
if: |
175-
github.event_name == 'pull_request' &&
176-
github.actor != 'dependabot[bot]'
216+
needs: [schedule-gate]
217+
if: >-
218+
always() && (
219+
(github.event_name == 'pull_request' && github.actor != 'dependabot[bot]') ||
220+
github.event_name == 'workflow_dispatch' ||
221+
(github.event_name == 'schedule' && needs.schedule-gate.outputs.enabled == 'true')
222+
)
177223
steps:
178224
- name: ⬇️ Checkout Repository
179225
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
226+
with:
227+
ref: ${{ needs.schedule-gate.outputs.branch || github.ref }}
180228

181229
- name: 📦 Setup pnpm
182230
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
@@ -224,12 +272,18 @@ jobs:
224272
ci-pr-ios-web:
225273
name: 🔄 🍏 🌐 CI PR Run iOS Web Tests on LambdaTest
226274
runs-on: ubuntu-latest
227-
if: |
228-
github.event_name == 'pull_request' &&
229-
github.actor != 'dependabot[bot]'
275+
needs: [schedule-gate]
276+
if: >-
277+
always() && (
278+
(github.event_name == 'pull_request' && github.actor != 'dependabot[bot]') ||
279+
github.event_name == 'workflow_dispatch' ||
280+
(github.event_name == 'schedule' && needs.schedule-gate.outputs.enabled == 'true')
281+
)
230282
steps:
231283
- name: ⬇️ Checkout Repository
232284
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
285+
with:
286+
ref: ${{ needs.schedule-gate.outputs.branch || github.ref }}
233287

234288
- name: 📦 Setup pnpm
235289
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
@@ -277,12 +331,18 @@ jobs:
277331
ci-pr-app:
278332
name: 🔄 📱 CI PR Run Mobile App Tests on Sauce
279333
runs-on: ubuntu-latest
280-
if: |
281-
github.event_name == 'pull_request' &&
282-
github.actor != 'dependabot[bot]'
334+
needs: [schedule-gate]
335+
if: >-
336+
always() && (
337+
(github.event_name == 'pull_request' && github.actor != 'dependabot[bot]') ||
338+
github.event_name == 'workflow_dispatch' ||
339+
(github.event_name == 'schedule' && needs.schedule-gate.outputs.enabled == 'true')
340+
)
283341
steps:
284342
- name: ⬇️ Checkout Repository
285343
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
344+
with:
345+
ref: ${{ needs.schedule-gate.outputs.branch || github.ref }}
286346

287347
- name: 📦 Setup pnpm
288348
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
@@ -330,12 +390,18 @@ jobs:
330390
ci-pr-ocr:
331391
name: 🔄 📱 CI PR Run OCR Tests on LambdaTest
332392
runs-on: ubuntu-latest
333-
if: |
334-
github.event_name == 'pull_request' &&
335-
github.actor != 'dependabot[bot]'
393+
needs: [schedule-gate]
394+
if: >-
395+
always() && (
396+
(github.event_name == 'pull_request' && github.actor != 'dependabot[bot]') ||
397+
github.event_name == 'workflow_dispatch' ||
398+
(github.event_name == 'schedule' && needs.schedule-gate.outputs.enabled == 'true')
399+
)
336400
steps:
337401
- name: ⬇️ Checkout Repository
338402
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
403+
with:
404+
ref: ${{ needs.schedule-gate.outputs.branch || github.ref }}
339405

340406
- name: 📦 Setup pnpm
341407
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0

0 commit comments

Comments
 (0)