Skip to content

Commit 6b1dcfb

Browse files
authored
test(CI): Add merge queue support for faster PR testing (#1265)
1 parent acd611d commit 6b1dcfb

File tree

6 files changed

+77
-30
lines changed

6 files changed

+77
-30
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'Custom merge queue browsers'
2+
description: 'Trim down pytest browsers for any github event other than merge_group.'
3+
inputs:
4+
all-browsers:
5+
description: 'Force all pytest browsers to used when testing'
6+
required: false
7+
default: 'false'
8+
outputs:
9+
browsers:
10+
description: 'pytest browsers to use'
11+
value: ${{ steps.browsers.outputs.browsers }}
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Determine browsers to use
16+
shell: bash
17+
id: browsers
18+
run: |
19+
if [ "${{ inputs.all-browsers }}" == "true" ]; then
20+
echo "Using all browsers!"
21+
exit 0
22+
fi
23+
24+
if [ "${{ github.event_name }}" == "pull_request" ]; then
25+
echo "Using chrome browser only!"
26+
echo 'browsers=PYTEST_BROWSERS="--browser chromium"' >> "$GITHUB_OUTPUT"
27+
fi
28+
29+
echo "No custom pytest browsers!"
30+
exit 0

.github/workflows/build-docs.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ on:
55
push:
66
branches: ["main"]
77
pull_request:
8+
merge_group:
89

910
jobs:
10-
build:
11+
build-docs:
1112
runs-on: ubuntu-latest
1213
strategy:
1314
matrix:
1415
python-version: ["3.12"]
1516
fail-fast: false
1617

1718
steps:
18-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
1920

2021
- name: Set up Python ${{ matrix.python-version }}
2122
uses: actions/setup-python@v4
@@ -42,6 +43,7 @@ jobs:
4243
make quartodoc
4344
4445
- name: Build site
46+
if: ${{ github.event_name != 'pull_request' || startsWith(github.head_ref, 'docs') }}
4547
run: |
4648
cd docs
4749
make site
@@ -52,15 +54,14 @@ jobs:
5254
with:
5355
path: "docs/_site"
5456

55-
5657
deploy:
5758
if: github.ref == 'refs/heads/main'
58-
needs: build
59+
needs: build-docs
5960

6061
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
6162
permissions:
62-
pages: write # to deploy to Pages
63-
id-token: write # to verify the deployment originates from an appropriate source
63+
pages: write # to deploy to Pages
64+
id-token: write # to verify the deployment originates from an appropriate source
6465

6566
# Deploy to the github-pages environment
6667
environment:

.github/workflows/pytest.yaml

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ on:
55
push:
66
branches: ["main", "rc-*"]
77
pull_request:
8+
merge_group:
89
release:
910
types: [published]
1011
schedule:
1112
- cron: "0 8 * * *"
1213

1314
jobs:
14-
build:
15+
check:
1516
runs-on: ubuntu-latest
1617
strategy:
1718
matrix:
@@ -21,7 +22,7 @@ jobs:
2122
fail-fast: false
2223

2324
steps:
24-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2526
- name: Setup py-shiny
2627
id: install
2728
uses: ./.github/py-shiny/setup
@@ -58,16 +59,24 @@ jobs:
5859
fail-fast: false
5960

6061
steps:
61-
- uses: actions/checkout@v3
62+
- uses: actions/checkout@v4
6263
- name: Setup py-shiny
6364
uses: ./.github/py-shiny/setup
6465
with:
6566
python-version: ${{ matrix.python-version }}
6667

68+
- name: Determine browsers for testing
69+
uses: ./.github/py-shiny/pytest-browsers
70+
id: browsers
71+
with:
72+
all-browsers: ${{ startsWith(github.head_ref, 'playwright') }}
73+
- name: Display browser
74+
shell: bash
75+
run: echo '${{ steps.browsers.outputs.browsers }}'
6776
- name: Run End-to-End tests
6877
timeout-minutes: 20
6978
run: |
70-
make playwright-shiny SUB_FILE=". -vv"
79+
make playwright-shiny SUB_FILE=". -vv" ${{ steps.browsers.outputs.browsers }}
7180
- uses: actions/upload-artifact@v4
7281
if: failure()
7382
with:
@@ -85,14 +94,14 @@ jobs:
8594
fail-fast: false
8695

8796
steps:
88-
- uses: actions/checkout@v3
97+
- uses: actions/checkout@v4
8998
- name: Setup py-shiny
9099
uses: ./.github/py-shiny/setup
91100
with:
92101
python-version: ${{ matrix.python-version }}
93102

94103
- name: Install node.js
95-
uses: actions/setup-node@v3
104+
uses: actions/setup-node@v4
96105
with:
97106
node-version: "18"
98107
cache: npm
@@ -102,10 +111,15 @@ jobs:
102111
run: |
103112
npm ci
104113
114+
- name: Determine browsers for testing
115+
uses: ./.github/py-shiny/pytest-browsers
116+
id: browsers
117+
with:
118+
all-browsers: ${{ startsWith(github.head_ref, 'playwright') }}
105119
- name: Run example app tests
106120
timeout-minutes: 20
107121
run: |
108-
make playwright-examples SUB_FILE=". -vv"
122+
make playwright-examples SUB_FILE=". -vv" ${{ steps.browsers.outputs.browsers }}
109123
- uses: actions/upload-artifact@v4
110124
if: failure()
111125
with:
@@ -124,7 +138,7 @@ jobs:
124138
fail-fast: false
125139

126140
steps:
127-
- uses: actions/checkout@v3
141+
- uses: actions/checkout@v4
128142
- name: Setup py-shiny
129143
uses: ./.github/py-shiny/setup
130144
with:
@@ -146,7 +160,7 @@ jobs:
146160

147161
playwright-deploys:
148162
needs: [playwright-deploys-precheck]
149-
if: github.event_name != 'release' && (github.event_name == 'push' || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'deploy')))
163+
if: github.event_name != 'release' && (github.event_name == 'push' || startsWith(github.head_ref, 'deploy'))
150164
# Only allow one `playwright-deploys` job to run at a time. (Independent of branch / PR)
151165
# Only one is allowed to run at a time because it is deploying to the same server location.
152166
concurrency: playwright-deploys
@@ -159,7 +173,7 @@ jobs:
159173
fail-fast: false
160174

161175
steps:
162-
- uses: actions/checkout@v3
176+
- uses: actions/checkout@v4
163177
- name: Setup py-shiny
164178
uses: ./.github/py-shiny/setup
165179
with:
@@ -172,7 +186,7 @@ jobs:
172186
run: |
173187
make playwright-deploys SUB_FILE=". -vv"
174188
175-
- name: Deploy apps and run tests (on `push` or on `pull_request` w/ `deploy**` branch)
189+
- name: Deploy apps and run tests (on `push` or `deploy**` branches)
176190
env:
177191
DEPLOY_APPS: "true"
178192
DEPLOY_CONNECT_SERVER_URL: "https://rsc.radixu.com/"
@@ -197,9 +211,9 @@ jobs:
197211
name: "Deploy to PyPI"
198212
runs-on: ubuntu-latest
199213
if: github.event_name == 'release'
200-
needs: [build]
214+
needs: [check]
201215
steps:
202-
- uses: actions/checkout@v3
216+
- uses: actions/checkout@v4
203217
- name: "Set up Python 3.10"
204218
uses: actions/setup-python@v4
205219
with:
@@ -233,7 +247,7 @@ jobs:
233247

234248
testrail-reporting-nightly:
235249
runs-on: ${{ matrix.os }}
236-
if: ${{ github.event_name == 'schedule' || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'testrail')) }}
250+
if: ${{ github.event_name == 'schedule' || startsWith(github.head_ref, 'testrail') }}
237251
strategy:
238252
matrix:
239253
python-version:
@@ -246,14 +260,14 @@ jobs:
246260
fail-fast: false
247261

248262
steps:
249-
- uses: actions/checkout@v3
263+
- uses: actions/checkout@v4
250264
- name: Setup py-shiny
251265
uses: ./.github/py-shiny/setup
252266
with:
253267
python-version: ${{ matrix.python-version }}
254268

255269
- name: Install node.js
256-
uses: actions/setup-node@v3
270+
uses: actions/setup-node@v4
257271
with:
258272
node-version: "18"
259273
cache: npm

.github/workflows/verify-js-built.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
name: Build
1+
name: Verify built assets
22

33
on:
44
push:
55
branches: ["main", "rc-*"]
66
pull_request:
7+
merge_group:
78

89
jobs:
910
verify_js_built:

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ clean-js: FORCE
144144

145145
# Default `SUB_FILE` to empty
146146
SUB_FILE:=
147-
147+
PYTEST_BROWSERS:= --browser webkit --browser firefox --browser chromium
148148
install-playwright: FORCE
149149
playwright install --with-deps
150150

@@ -157,15 +157,15 @@ install-rsconnect: FORCE
157157

158158
# end-to-end tests with playwright; (SUB_FILE="" within tests/playwright/shiny/)
159159
playwright-shiny: install-playwright
160-
pytest tests/playwright/shiny/$(SUB_FILE)
160+
pytest tests/playwright/shiny/$(SUB_FILE) $(PYTEST_BROWSERS)
161161

162162
# end-to-end tests on deployed apps with playwright; (SUB_FILE="" within tests/playwright/deploys/)
163163
playwright-deploys: install-playwright install-rsconnect
164-
pytest tests/playwright/deploys/$(SUB_FILE)
164+
pytest tests/playwright/deploys/$(SUB_FILE) $(PYTEST_BROWSERS)
165165

166166
# end-to-end tests on all py-shiny examples with playwright; (SUB_FILE="" within tests/playwright/examples/)
167167
playwright-examples: install-playwright
168-
pytest tests/playwright/examples/$(SUB_FILE)
168+
pytest tests/playwright/examples/$(SUB_FILE) $(PYTEST_BROWSERS)
169169

170170
playwright-debug: install-playwright ## All end-to-end tests, chrome only, headed; (SUB_FILE="" within tests/playwright/)
171171
pytest -c tests/playwright/playwright-pytest.ini tests/playwright/$(SUB_FILE)
@@ -175,10 +175,10 @@ playwright-show-trace: ## Show trace of failed tests
175175

176176
# end-to-end tests with playwright and generate junit report
177177
testrail-junit: install-playwright install-trcli
178-
pytest tests/playwright/shiny/$(SUB_FILE) --junitxml=report.xml
178+
pytest tests/playwright/shiny/$(SUB_FILE) --junitxml=report.xml $(PYTEST_BROWSERS)
179179

180180
coverage: FORCE ## check combined code coverage (must run e2e last)
181-
pytest --cov-report term-missing --cov=shiny tests/pytest/ tests/playwright/shiny/$(SUB_FILE)
181+
pytest --cov-report term-missing --cov=shiny tests/pytest/ tests/playwright/shiny/$(SUB_FILE) $(PYTEST_BROWSERS)
182182
coverage html
183183
$(BROWSER) htmlcov/index.html
184184

pytest.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[pytest]
22
asyncio_mode=strict
33
testpaths=tests/pytest/
4-
addopts = --strict-markers --durations=6 --durations-min=5.0 --browser webkit --browser firefox --browser chromium --numprocesses auto --tracing=retain-on-failure --video=retain-on-failure
4+
; Note: Browsers are set within `./Makefile`
5+
addopts = --strict-markers --durations=6 --durations-min=5.0 --numprocesses auto --tracing=retain-on-failure --video=retain-on-failure

0 commit comments

Comments
 (0)