Browse Source

ci: verify chromedriver (#21993)

* initial pass

* better

* even better

* ci

* add chromedriver to build step

* add chromedriver to other build step

* persist chromedriver for tests

* appveyor test

* correct sys.platform names

* chromedriver-path -> build-dir
Erick Zhao 5 years ago
parent
commit
bdf65a75d0
3 changed files with 154 additions and 8 deletions
  1. 91 8
      .circleci/config.yml
  2. 2 0
      appveyor.yml
  3. 61 0
      script/verify-chromedriver.py

+ 91 - 8
.circleci/config.yml

@@ -477,6 +477,7 @@ step-persist-data-for-tests: &step-persist-data-for-tests
       # Build artifacts
       - src/out/Default/dist.zip
       - src/out/Default/mksnapshot.zip
+      - src/out/Default/chromedriver.zip
       - src/out/Default/shell_browser_ui_unittests
       - src/out/Default/gen/node_headers
       - src/out/ffmpeg/ffmpeg.zip
@@ -507,6 +508,13 @@ step-mksnapshot-unzip: &step-mksnapshot-unzip
       cd src/out/Default
       unzip -o mksnapshot.zip
 
+step-chromedriver-unzip: &step-chromedriver-unzip
+  run:
+    name: Unzip chromedriver.zip
+    command: |
+      cd src/out/Default
+      unzip -o chromedriver.zip
+
 step-ffmpeg-gn-gen: &step-ffmpeg-gn-gen
   run:
     name: ffmpeg GN gen
@@ -544,6 +552,13 @@ step-verify-mksnapshot: &step-verify-mksnapshot
       cd src
       python electron/script/verify-mksnapshot.py --source-root "$PWD" --build-dir out/Default
 
+step-verify-chromedriver: &step-verify-chromedriver
+  run:
+    name: Verify ChromeDriver
+    command: |
+      cd src
+      python electron/script/verify-chromedriver.py --source-root "$PWD" --build-dir out/Default
+
 step-setup-linux-for-headless-testing: &step-setup-linux-for-headless-testing
   run:
     name: Setup for headless testing
@@ -965,6 +980,10 @@ steps-electron-build: &steps-electron-build
     - *step-maybe-cross-arch-snapshot
     - *step-maybe-cross-arch-snapshot-store
 
+    # chromedriver
+    - *step-electron-chromedriver-build
+    - *step-electron-chromedriver-store
+
     # ffmpeg
     - *step-ffmpeg-gn-gen
     - *step-ffmpeg-build
@@ -1144,6 +1163,18 @@ steps-verify-mksnapshot: &steps-verify-mksnapshot
     - *step-verify-mksnapshot
     - *step-maybe-notify-slack-failure
 
+steps-verify-chromedriver: &steps-verify-chromedriver
+  steps:
+    - attach_workspace:
+        at: .
+    - *step-depot-tools-add-to-path
+    - *step-electron-dist-unzip
+    - *step-chromedriver-unzip
+    - *step-setup-linux-for-headless-testing
+
+    - *step-verify-chromedriver
+    - *step-maybe-notify-slack-failure
+
 steps-tests: &steps-tests
   steps:
     - attach_workspace:
@@ -1152,6 +1183,7 @@ steps-tests: &steps-tests
     - *step-depot-tools-add-to-path
     - *step-electron-dist-unzip
     - *step-mksnapshot-unzip
+    - *step-chromedriver-unzip
     - *step-setup-linux-for-headless-testing
     - *step-restore-brew-cache
     - *step-fix-known-hosts-linux
@@ -1185,6 +1217,7 @@ steps-tests: &steps-tests
         path: src/junit
 
     - *step-verify-mksnapshot
+    - *step-verify-chromedriver
 
     - *step-maybe-notify-slack-failure
 
@@ -1374,6 +1407,10 @@ commands:
             - *step-maybe-cross-arch-snapshot
             - *step-maybe-cross-arch-snapshot-store
 
+            # chromedriver
+            - *step-electron-chromedriver-build
+            - *step-electron-chromedriver-store
+
             # ffmpeg
             - *step-ffmpeg-gn-gen
             - *step-ffmpeg-build
@@ -1918,6 +1955,14 @@ jobs:
       <<: *env-send-slack-notifications
     <<: *steps-verify-mksnapshot
 
+  linux-x64-verify-chromedriver:
+    <<: *machine-linux-medium
+    environment:
+      <<: *env-linux-medium
+      <<: *env-headless-testing
+      <<: *env-send-slack-notifications
+    <<: *steps-verify-chromedriver
+
   linux-ia32-testing-tests:
     <<: *machine-linux-medium
     environment:
@@ -1973,6 +2018,14 @@ jobs:
       <<: *env-send-slack-notifications
     <<: *steps-verify-mksnapshot
 
+  linux-ia32-verify-chromedriver:
+    <<: *machine-linux-medium
+    environment:
+      <<: *env-linux-medium
+      <<: *env-headless-testing
+      <<: *env-send-slack-notifications
+    <<: *steps-verify-chromedriver
+
   osx-testing-tests:
     <<: *machine-mac-large
     environment:
@@ -2003,6 +2056,13 @@ jobs:
       <<: *env-send-slack-notifications
     <<: *steps-verify-mksnapshot
 
+  osx-verify-chromedriver:
+    <<: *machine-mac
+    environment:
+      <<: *env-machine-mac
+      <<: *env-send-slack-notifications
+    <<: *steps-verify-chromedriver
+
   mas-testing-tests:
     <<: *machine-mac-large
     environment:
@@ -2033,6 +2093,13 @@ jobs:
       <<: *env-send-slack-notifications
     <<: *steps-verify-mksnapshot
 
+  mas-verify-chromedriver:
+    <<: *machine-mac
+    environment:
+      <<: *env-machine-mac
+      <<: *env-send-slack-notifications
+    <<: *steps-verify-chromedriver
+
   # Layer 4: Summary.
   linux-x64-release-summary:
     <<: *machine-linux-medium
@@ -2220,15 +2287,19 @@ workflows:
       - linux-x64-release-tests:
           requires:
             - linux-x64-release
+      - linux-x64-chromedriver:
+          requires:
+            - linux-checkout-fast
       - linux-x64-verify-ffmpeg:
           requires:
             - linux-x64-release
       - linux-x64-verify-mksnapshot:
           requires:
             - linux-x64-release
-      - linux-x64-chromedriver:
+      - linux-x64-verify-chromedriver:
           requires:
-            - linux-checkout-fast
+            - linux-x64-release
+            - linux-x64-chromedriver
       - linux-x64-release-summary:
           requires:
             - linux-x64-release
@@ -2242,15 +2313,19 @@ workflows:
       - linux-ia32-release-tests:
           requires:
             - linux-ia32-release
+      - linux-ia32-chromedriver:
+          requires:
+            - linux-checkout-fast
       - linux-ia32-verify-ffmpeg:
           requires:
             - linux-ia32-release
       - linux-ia32-verify-mksnapshot:
           requires:
             - linux-ia32-release
-      - linux-ia32-chromedriver:
+      - linux-x64-verify-chromedriver:
           requires:
-            - linux-checkout-fast
+            - linux-ia32-release
+            - linux-ia32-chromedriver
       - linux-ia32-release-summary:
           requires:
             - linux-ia32-release
@@ -2299,15 +2374,19 @@ workflows:
       - osx-release-tests:
           requires:
             - osx-release
+      - osx-chromedriver:
+          requires:
+            - mac-checkout-fast
       - osx-verify-ffmpeg:
           requires:
             - osx-release
       - osx-verify-mksnapshot:
           requires:
             - osx-release
-      - osx-chromedriver:
+      - osx-verify-chromedriver:
           requires:
-            - mac-checkout-fast
+            - osx-release
+            - osx-chromedriver
       - osx-release-summary:
           requires:
           - osx-release
@@ -2321,15 +2400,19 @@ workflows:
       - mas-release-tests:
           requires:
             - mas-release
+      - mas-chromedriver:
+          requires:
+            - mac-checkout-fast
       - mas-verify-ffmpeg:
           requires:
             - mas-release
       - mas-verify-mksnapshot:
           requires:
             - mas-release
-      - mas-chromedriver:
+      - mas-verify-chromedriver:
           requires:
-            - mac-checkout-fast
+            - mas-release
+            - mas-chromedriver
       - mas-release-summary:
           requires:
           - mas-release

+ 2 - 0
appveyor.yml

@@ -190,6 +190,8 @@ test_script:
   - echo "About to verify mksnapshot"
   - if "%RUN_TESTS%"=="true" ( echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd% )
   - echo "Done verifying mksnapshot"
+  - if "%RUN_TESTS%"=="true" ( echo Verifying chromedriver & python electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd% )
+  - echo "Done verifying chromedriver"
 deploy_script:
   - cd electron
   - ps: >-

+ 61 - 0
script/verify-chromedriver.py

@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+
+import argparse
+import os
+import re
+import shlex
+import subprocess
+import sys
+import time
+
+SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
+
+
+def main():
+  args = parse_args()
+
+  chromedriver_name = {
+    'darwin': 'chromedriver',
+    'win32': 'chromedriver.exe',
+    'linux2': 'chromedriver'
+}
+
+  chromedriver_path = os.path.join(
+    args.source_root, args.build_dir, chromedriver_name[sys.platform])
+  proc = subprocess.Popen([chromedriver_path],
+                          stdout=subprocess.PIPE, universal_newlines=True)
+  try:
+    output = proc.stdout.readline()
+  except KeyboardInterrupt:
+    returncode = 0
+  finally:
+    proc.terminate()
+
+  returncode = 0
+  match = re.search(
+    '^Starting ChromeDriver [0-9]+.[0-9]+.[0-9]+.[0-9]+ .* on port [0-9]+$', output)
+
+  if match == None:
+    returncode = 1
+
+  if returncode == 0:
+    print('ok ChromeDriver is able to be initialized.')
+
+  return returncode
+
+
+def parse_args():
+    parser=argparse.ArgumentParser(description='Test ChromeDriver')
+    parser.add_argument('--source-root',
+                        default=SOURCE_ROOT,
+                        required=False)
+    parser.add_argument('--build-dir',
+                        default=None,
+                        required=True)
+    return parser.parse_args()
+
+
+if __name__ == '__main__':
+    sys.exit(main())