Skip to content

Commit 0caed70

Browse files
authored
Merge pull request #3757 from plotly/fix/percy-forks
skip percy on forks
2 parents adad025 + d17c0f2 commit 0caed70

2 files changed

Lines changed: 71 additions & 21 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'Percy Exec'
2+
description: 'Run a command with Percy, or skip Percy for fork PRs (no token access)'
3+
4+
inputs:
5+
command:
6+
description: 'The command to run (e.g., "pytest --headless tests/")'
7+
required: true
8+
percy-token:
9+
description: 'Percy token (pass secrets.PERCY_TOKEN)'
10+
required: false
11+
default: ''
12+
13+
runs:
14+
using: 'composite'
15+
steps:
16+
- name: Run with Percy
17+
if: inputs.percy-token != ''
18+
shell: bash
19+
env:
20+
PERCY_TOKEN: ${{ inputs.percy-token }}
21+
run: npx percy exec -- ${{ inputs.command }}
22+
23+
- name: Run without Percy (fork PR)
24+
if: inputs.percy-token == ''
25+
shell: bash
26+
run: |
27+
echo "::notice::Skipping Percy (no token available - likely a fork PR)"
28+
${{ inputs.command }}

.github/workflows/testing.yml

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,15 @@ jobs:
515515
run: npm run setup-tests.py
516516

517517
- name: Run main integration tests
518-
run: |
519-
if [ "${{ matrix.python-version }}" == "3.12" ]; then
520-
npx percy exec -- pytest --headless --nopercyfinalize --junitxml=test-reports/junit_intg.xml tests/integration --splits 3 --group ${{ matrix.test-group }}
521-
else
522-
pytest --headless --nopercyfinalize --junitxml=test-reports/junit_intg.xml tests/integration --splits 3 --group ${{ matrix.test-group }}
523-
fi
518+
if: matrix.python-version != '3.12'
519+
run: pytest --headless --nopercyfinalize --junitxml=test-reports/junit_intg.xml tests/integration --splits 3 --group ${{ matrix.test-group }}
520+
521+
- name: Run main integration tests with Percy
522+
if: matrix.python-version == '3.12'
523+
uses: ./.github/actions/percy-exec
524+
with:
525+
command: pytest --headless --nopercyfinalize --junitxml=test-reports/junit_intg.xml tests/integration --splits 3 --group ${{ matrix.test-group }}
526+
percy-token: ${{ secrets.PERCY_TOKEN }}
524527

525528
- name: Upload test results
526529
if: always()
@@ -601,15 +604,21 @@ jobs:
601604
sudo Xvfb :99 -ac -screen 0 1280x1024x24 &
602605
echo "DISPLAY=:99" >> $GITHUB_ENV
603606
607+
- name: Install HTML components dependencies
608+
working-directory: components/dash-html-components
609+
run: npm ci
610+
604611
- name: Run HTML components tests
612+
if: matrix.python-version != '3.12'
605613
working-directory: components/dash-html-components
606-
run: |
607-
npm ci
608-
if [ "${{ matrix.python-version }}" == "3.12" ]; then
609-
npx percy exec -- pytest --headless --nopercyfinalize --junitxml=test-reports/junit_html.xml
610-
else
611-
pytest --headless --nopercyfinalize --junitxml=test-reports/junit_html.xml
612-
fi
614+
run: pytest --headless --nopercyfinalize --junitxml=test-reports/junit_html.xml
615+
616+
- name: Run HTML components tests with Percy
617+
if: matrix.python-version == '3.12'
618+
uses: ./.github/actions/percy-exec
619+
with:
620+
command: cd components/dash-html-components && pytest --headless --nopercyfinalize --junitxml=test-reports/junit_html.xml
621+
percy-token: ${{ secrets.PERCY_TOKEN }}
613622

614623
- name: Upload test results
615624
if: always()
@@ -863,11 +872,18 @@ jobs:
863872
sudo Xvfb :99 -ac -screen 0 1280x1024x24 &
864873
echo "DISPLAY=:99" >> $GITHUB_ENV
865874
875+
- name: Install Table test dependencies
876+
working-directory: components/dash-table
877+
run: npm ci
878+
866879
- name: Run Table visual tests
880+
if: env.PERCY_TOKEN != ''
867881
working-directory: components/dash-table
868-
run: |
869-
npm ci
870-
npm run test.visual
882+
run: npm run test.visual
883+
884+
- name: Skip Table visual tests (fork PR)
885+
if: env.PERCY_TOKEN == ''
886+
run: echo "::notice::Skipping Percy table visual tests (no token available - likely a fork PR)"
871887

872888
- name: Upload dash artifacts
873889
if: always()
@@ -883,17 +899,23 @@ jobs:
883899
needs: [test-main, dcc-test, html-test]
884900
runs-on: ubuntu-latest
885901
if: always()
902+
env:
903+
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
886904
steps:
887905
- name: Finalize Main Percy Build
888906
if: |
889-
needs.test-main.result != 'skipped' ||
890-
needs.dcc-test.result != 'skipped' ||
891-
needs.html-test.result != 'skipped'
907+
env.PERCY_TOKEN != '' && (
908+
needs.test-main.result != 'skipped' ||
909+
needs.dcc-test.result != 'skipped' ||
910+
needs.html-test.result != 'skipped'
911+
)
892912
run: |
893913
npm install -g @percy/cli
894914
npx percy build:finalize
895-
env:
896-
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
915+
916+
- name: Skip Percy finalize (fork PR)
917+
if: env.PERCY_TOKEN == ''
918+
run: echo "::notice::Skipping Percy finalize (no token available - likely a fork PR)"
897919

898920
report-table-percy-skipped:
899921
name: Report Percy Table Skipped

0 commit comments

Comments
 (0)