Skip to content

Commit

Permalink
Fix/docs visual cache logic (#11014)
Browse files Browse the repository at this point in the history
* make sure we evaluate the cache restore properly

* build and serve for visual tests

* increase timeout
  • Loading branch information
magierg authored and evanSe committed Jun 11, 2024
1 parent d65a525 commit 9830081
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 34 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/docs-visual-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defaults:
jobs:
run-tests:
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 60
env: # Or as an environment variable
PASS_COOKIE: ${{ secrets.PassCookie }}
steps:
Expand Down Expand Up @@ -55,6 +55,11 @@ jobs:
if: ${{inputs.test_env == 'http://localhost:8080/docs'}}
run: |
npm run docs:api
- name: Build documentation
if: ${{inputs.test_env == 'http://localhost:8080/docs'}}
run: |
npm run docs:build
- name: Set up cache
id: cache
Expand All @@ -63,13 +68,22 @@ jobs:
key: plawyright-cache/${{github.repository}}/${{github.ref}}
restore-keys: plawyright-cache/${{github.repository}}/refs/heads/develop
path: '**/test-artifacts/**'


- name: Check if cache was restored
id: check-cache
run: |
if [[ -n "$(find . -name 'test-artifacts' -type d -not -path '*/node_modules/*' -print0 | xargs -0 -I {} find {} -type f -print -quit)" ]]; then
echo "cache-restored=true" >> $GITHUB_ENV
else
echo "cache-restored=false" >> $GITHUB_ENV
fi
- name: Initialize snapshots
if: ${{steps.cache.outputs.cache-hit != 'true' || inputs.update-snapshots == 'true'}}
if: ${{env.cache-restored != 'true' || github.event.inputs.update-snapshots == 'true'}}
run: BASE_URL=${{ inputs.test_env }} npx playwright test --update-snapshots

- name: Test
if: ${{steps.cache.outputs.cache-hit == 'true' || inputs.update-snapshots != 'true'}}
if: ${{env.cache-restored == 'true' || github.event.inputs.update-snapshots != 'true'}}
run: BASE_URL=${{ inputs.test_env }} npx playwright test

- name: Upload test report
Expand Down
56 changes: 28 additions & 28 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"docs:scripts:generate-js-examples": "bash .vuepress/tools/generate-js-examples.sh",
"docs:start": "npm run docs:scripts:link-assets && cross-env NODE_OPTIONS=--openssl-legacy-provider node ./node_modules/.bin/vuepress dev ./",
"docs:start:no-cache": "npm run docs:scripts:link-assets && cross-env NODE_OPTIONS=--openssl-legacy-provider node ./node_modules/.bin/vuepress dev --no-cache ./",
"docs:serve": "http-server -c-1 .vuepress/dist/",
"docs:build": "npm run docs:scripts:generate-js-examples && cross-env NODE_OPTIONS=--openssl-legacy-provider node .vuepress/tools/build.mjs -- --no-cache",
"docs:docker:build": "npm run docs:docker:build:testing",
"docs:docker:build:testing": "npm run docs:scripts:link-assets && cross-env BUILD_MODE=testing npm run docs:build && docker build -f docker/Dockerfile -t docs-md ./",
Expand All @@ -41,7 +42,7 @@
"@babel/preset-react": "^7.13.13",
"@babel/preset-typescript": "^7.13.0",
"@octokit/rest": "^18.6.7",
"@playwright/test": "^1.42.1",
"@playwright/test": "^1.44.1",
"@types/node": "^20.11.27",
"@vuepress/plugin-active-header-links": "^1.9.10",
"@vuepress/shared-utils": "^1.9.10",
Expand Down Expand Up @@ -81,6 +82,7 @@
],
"dependencies": {
"@docsearch/js": "^3.6.0",
"@types/overlayscrollbars": "^1.12.5",
"codesandbox": "^2.2.3",
"dayjs": "^1.11.10",
"dotenv": "^16.4.5",
Expand Down
2 changes: 1 addition & 1 deletion docs/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default defineConfig({

/* Run your local dev server before starting the tests */
webServer: !process.env.BASE_URL || process.env.BASE_URL.includes('localhost') ? {
command: 'npm run docs:start',
command: 'npm run docs:serve',
url: process.env.BASE_URL ?? 'http://localhost:8080/docs',
reuseExistingServer: !process.env.CI,
timeout: 300 * 1000,
Expand Down

0 comments on commit 9830081

Please sign in to comment.