|
| 1 | +name: Verify testing documentation for changes |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - ".github/workflows/verify-testing-docs-on-change.yml" |
| 7 | + - "docs/_quartodoc-testing.yml" |
| 8 | + - "shiny/playwright/controller/**" |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + pull-requests: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + verify-testing-docs: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + if: github.event_name == 'pull_request' |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + |
| 25 | + - name: Setup py-shiny |
| 26 | + id: install |
| 27 | + uses: ./.github/py-shiny/setup |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + make ci-install-docs |
| 32 | +
|
| 33 | + - name: Update testing docs and check for changes |
| 34 | + id: check-docs-changes |
| 35 | + run: | |
| 36 | + # Store the current state of the documentation file |
| 37 | + cp shiny/pytest/_generate/_data/testing-documentation.json testing-documentation-before.json |
| 38 | +
|
| 39 | + # Run the make command to update testing docs |
| 40 | + make update-testing-docs |
| 41 | +
|
| 42 | + if [[ ! -f testing-documentation-before.json || ! -f shiny/pytest/_generate/_data/testing-documentation.json ]]; then |
| 43 | + echo "One or both documentation files are missing." |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | +
|
| 47 | + # Check if the documentation file has changed |
| 48 | + if diff -q testing-documentation-before.json shiny/pytest/_generate/_data/testing-documentation.json > /dev/null 2>&1; then |
| 49 | + echo "docs_changed=true" >> $GITHUB_OUTPUT |
| 50 | + echo "The generated documentation is out of sync with the current controller changes." |
| 51 | + echo "\n\n" |
| 52 | + diff -q testing-documentation-before.json shiny/pytest/_generate/_data/testing-documentation.json || true |
| 53 | + echo "\n\n" |
| 54 | + else |
| 55 | + echo "docs_changed=false" >> $GITHUB_OUTPUT |
| 56 | + echo "Documentation file is up to date" |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Comment on PR about testing docs update |
| 60 | + if: steps.check-docs-changes.outputs.docs_changed == 'true' |
| 61 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 62 | + with: |
| 63 | + header: testing-docs-update |
| 64 | + message: | |
| 65 | + 🚨 **Testing Documentation Out of Sync** |
| 66 | +
|
| 67 | + We detected changes in the `shiny/playwright/controller` directory that affect the testing documentation used by the `shiny add test` command. |
| 68 | +
|
| 69 | + **The generated documentation is out of sync with your controller changes. Please run:** |
| 70 | +
|
| 71 | + ```bash |
| 72 | + make update-testing-docs |
| 73 | + ``` |
| 74 | +
|
| 75 | + **Then commit the updated `shiny/pytest/_generate/_data/testing-documentation.json` file.** |
| 76 | +
|
| 77 | + <details><summary>Additional details</summary> |
| 78 | +
|
| 79 | + The updated documentation file ensures that the AI test generator has access to the latest controller API documentation. |
| 80 | +
|
| 81 | + </details> |
| 82 | +
|
| 83 | + ❌ **This check will fail until the documentation is updated and committed.** |
| 84 | +
|
| 85 | + --- |
| 86 | + *This comment was automatically generated by the `verify-testing-docs-on-change.yml` workflow.* |
| 87 | +
|
| 88 | + - name: Remove comment when no controller changes or docs are up to date |
| 89 | + if: steps.check-docs-changes.outputs.docs_changed == 'false' |
| 90 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 91 | + with: |
| 92 | + header: testing-docs-update |
| 93 | + delete: true |
0 commit comments