Browse Source

Backport PR #11388: Set default ui font to `system-ui` (#11927)

* Python script to update Galata snapshot images.

* Add the Galata snapshots update script to MANIFEST.in to fix integrity problems.

* If Galata fails, generate updated snapshots and upload them.

* Bump github workflow timeouts

1. The linux tests workflow was running out of time at 30 minutes
2. We effectively now have double the work for galata if there is a
failure, so double the timeout.

* Remove unnecessary import

* Prefix galata uploads with jupyterlab-

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>

* Updated screenshots from master

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>

Co-authored-by: Jason Grout <jasongrout@users.noreply.github.com>
Frédéric Collonval 3 years ago
parent
commit
c12bea95c1
4 changed files with 57 additions and 2 deletions
  1. 14 1
      .github/workflows/galata.yml
  2. 1 1
      .github/workflows/linuxtests.yml
  3. 1 0
      MANIFEST.in
  4. 41 0
      galata/update_snapshots.py

+ 14 - 1
.github/workflows/galata.yml

@@ -11,7 +11,7 @@ on:
 jobs:
   build:
     name: Visual Regression Tests
-    timeout-minutes: 40
+    timeout-minutes: 80
     runs-on: ubuntu-20.04
     steps:
       - name: Checkout
@@ -68,6 +68,19 @@ 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: |

+ 1 - 1
.github/workflows/linuxtests.yml

@@ -61,7 +61,7 @@ jobs:
           - group: splice_source
             python-version: '3.7'
       fail-fast: false
-    timeout-minutes: 30
+    timeout-minutes: 45
     runs-on: ubuntu-20.04
     steps:
       - name: Checkout

+ 1 - 0
MANIFEST.in

@@ -35,6 +35,7 @@ recursive-exclude jupyterlab *.js.map
 # Galata
 include galata/README.md
 include galata/jupyter_server_test_config.py
+include galata/update_snapshots.py
 include galata/*.js
 recursive-include galata/media *.*
 graft galata/src

+ 41 - 0
galata/update_snapshots.py

@@ -0,0 +1,41 @@
+# Copyright (c) Jupyter Development Team.
+# Distributed under the terms of the Modified BSD License.
+
+import hashlib
+from pathlib import Path
+import json
+import shutil
+
+import argparse
+parser = argparse.ArgumentParser(description='Update Galata Snapshot images.')
+parser.add_argument('report', help='Path to the galata-report directory')
+args = parser.parse_args()
+
+# Calculate hashes of all png files in the test/directory
+def sha1(path):
+    with open(path, "rb") as f:
+        return hashlib.sha1(f.read()).hexdigest()
+
+
+filehashes = {sha1(p): p for p in Path('.').glob('**/*-snapshots/*-linux.png')}
+
+
+# For every json file in data directory except report.json
+data_dir = Path(args.report).expanduser().resolve() / 'data'
+for p in data_dir.glob('*.json'):
+    if p.name == 'report.json':
+        continue
+    with open(p, "rb") as f:
+        z = json.load(f)
+    for t in z['tests']:
+        if t['outcome'] != 'unexpected':
+            continue
+        for r in t['results']:
+            for attachment in r['attachments']:
+                if attachment['name'] == 'expected':
+                    expected = Path(attachment['path']).stem
+                elif attachment['name'] == 'actual':
+                    actual = data_dir / Path(attachment['path']).name
+            if expected and attachment and expected in filehashes:
+                shutil.copyfile(actual, filehashes[expected])
+                print(f'{actual} -> {filehashes[expected]}')