Browse Source

Backport PR #12040: Update Playwright snapshots from PR comments (#12403)

Frédéric Collonval 3 years ago
parent
commit
fc78ad37f2

+ 45 - 0
.github/workflows/galata-update.yml

@@ -0,0 +1,45 @@
+name: Update Playwright Snapshots
+
+on:
+  issue_comment:
+    types: [created, edited]
+
+permissions:
+  contents: write
+  pull-requests: write
+
+jobs:
+  update-galata-snapshots:
+    name: Update Galata References
+    if: ${{ github.event.issue.pull_request && (contains(github.event.comment.body, 'please update galata snapshots') || contains(github.event.comment.body, 'please update snapshots')) }}
+    timeout-minutes: 80
+    runs-on: ubuntu-20.04
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+        with:
+          token: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Configure git to use https
+        run: git config --global hub.protocol https
+
+      - name: Checkout the branch from the PR that triggered the job
+        run: hub pr checkout ${{ github.event.issue.number }}
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Base Setup
+        uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
+
+      - name: Install dependencies
+        run: |
+          bash ./scripts/ci_install.sh
+          # Build dev-mode
+          jlpm run build
+
+      - uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1
+        with:
+          github_token: ${{ secrets.GITHUB_TOKEN }}
+          server_url: http-get://localhost:8888/lab
+          test_folder: galata

+ 0 - 13
.github/workflows/galata.yml

@@ -68,19 +68,6 @@ jobs:
           path: |
             galata/playwright-report
 
-      - name: Update snapshots
-        if: failure()
-        run: |
-          cd galata
-          jlpm run test:update
-
-      - name: Upload updated snapshots
-        if: failure()
-        uses: actions/upload-artifact@v2
-        with:
-          name: jupyterlab-galata-updated-snapshots
-          path: galata/test/**/*-snapshots/*.*
-
       - name: Print JupyterLab logs
         if: always()
         run: |

+ 7 - 1
docs/source/developer/contributing.rst

@@ -649,7 +649,13 @@ Main reasons for UI test failures are:
 
 2. **An intended update to user interface**:
 
-   If your code change is introducing an update to UI which causes existing UI Tests to fail, then you will need to update reference image(s) for the failing tests. In order to do that, simply go to GitHub Actions page for the failed test and download test artifacts. It will contain test captures in directory ``test/screenshots``. You can copy the capture for the failed test and paste into reference screenshots directory in JupyterLab source code, replacing the failing test's reference capture. Reference captures are located in ``ui-tests/reference-output/screenshots`` in JupyterLab source code.
+   If your code change is introducing an update to UI which causes existing UI Tests to
+   fail, then you will need to update reference image(s) for the failing tests. In order
+   to do that, you can post a comment on your PR with the following content:
+
+   - ``please update galata snapshots``: A bot will push a new commit to your PR updating galata
+     test snaphsots.
+   - ``please update snapshots``: Combine the two previous comments effects.
 
 For more information on UI Testing, please read the `UI Testing developer documentation <https://github.com/jupyterlab/jupyterlab/blob/3.3.x/galata/README.md>`__ and `Galata documentation <https://github.com/jupyterlab/galata/blob/main/README.md>`__.