Browse Source

build: add several missing test steps for GHA (#42479)

Shelley Vohr 10 months ago
parent
commit
0affad3be6

+ 134 - 7
.github/workflows/linux-pipeline.yml

@@ -1,4 +1,4 @@
-name: Pipeline Linux
+name: Linux Pipeline
 
 on:
   workflow_call:
@@ -218,17 +218,17 @@ jobs:
           electron/script/strip-binaries.py --file $PWD/out/Default/mksnapshot
           electron/script/strip-binaries.py --file $PWD/out/Default/v8_context_snapshot_generator
         fi
-      
+
         e build electron:electron_mksnapshot_zip -j $NUMBER_OF_NINJA_PROCESSES
         (cd out/Default; zip mksnapshot.zip mksnapshot_args gen/v8/embedded.S)
     - name: Generate Cross-Arch Snapshot (arm/arm64)
-      if: ${{ matrix.build-arch == 'arm' }} || ${{ matrix.build-arch == 'arm64' }}
+      if: ${{ matrix.build-arch == 'arm' || matrix.build-arch == 'arm64' }}
       run: |
         cd src
         if [ "${{ matrix.build-arch }}" = "arm" ]; then
-          export MKSNAPSHOT_PATH="clang_x86_v8_arm"
+          MKSNAPSHOT_PATH="clang_x86_v8_arm"
         elif [ "${{ matrix.build-arch }}" = "arm64" ]; then
-          export MKSNAPSHOT_PATH="clang_x64_v8_arm64"
+          MKSNAPSHOT_PATH="clang_x64_v8_arm64"
         fi
 
         cp "out/Default/$MKSNAPSHOT_PATH/mksnapshot" out/Default
@@ -275,7 +275,7 @@ jobs:
       run: |
         cd src
         autoninja -C out/Default electron:hunspell_dictionaries_zip -j $NUMBER_OF_NINJA_PROCESSES
-    - name: Maybe Generate Libcxx
+    - name: Generate Libcxx
       if: ${{ inputs.is-release }}
       run: |
         cd src
@@ -375,4 +375,131 @@ jobs:
         while [ -f /var/.ssh-lock ]
         do
           sleep 60
-        done
+        done
+  node-tests:
+    name: Run Node.js Tests
+    if: ${{ inputs.is-release == false }}
+    runs-on: aks-linux-medium
+    needs: build
+    timeout-minutes: 20
+    env: 
+      TARGET_ARCH: x64
+    container:
+      image: ghcr.io/electron/build:latest
+      options: --user root
+    steps:
+    - name: Load Build Tools
+      run: |
+        export BUILD_TOOLS_SHA=ef894bc3cfa99d84a3b731252da0f83f500e4032
+        npm i -g @electron/build-tools
+        e auto-update disable
+        e init --root=$(pwd) --out=Default ${{ inputs.gn-build-type }}
+    - name: Checkout Electron
+      uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
+      with:
+        path: src/electron
+        fetch-depth: 0
+    - name: Install Dependencies
+      run: |
+        cd src/electron
+        node script/yarn install
+    - name: Get Depot Tools
+      timeout-minutes: 5
+      run: |
+        git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
+        sed -i '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja
+        cd depot_tools
+        git apply --3way ../src/electron/.github/workflows/config/gclient.diff
+        # Ensure depot_tools does not update.
+        test -d depot_tools && cd depot_tools
+        touch .disable_auto_update
+    - name: Add Depot Tools to PATH
+      run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
+    - name: Download Generated Artifacts
+      uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
+      with:
+        name: generated_artifacts_linux_${{ env.TARGET_ARCH }}
+        path: ./generated_artifacts_linux_${{ env.TARGET_ARCH }}
+    - name: Restore Generated Artifacts
+      run: ./src/electron/script/actions/restore-artifacts.sh
+    - name: Unzip Dist
+      run: |
+        cd src/out/Default
+        unzip -:o dist.zip
+    - name: Setup Linux for Headless Testing
+      run: sh -e /etc/init.d/xvfb start
+    - name: Run Node.js Tests
+      run: |
+        cd src
+        node electron/script/node-spec-runner.js --default --jUnitDir=junit
+    - name: Wait for active SSH sessions
+      if: always() && !cancelled()
+      run: |
+        while [ -f /var/.ssh-lock ]
+        do
+          sleep 60
+        done
+  nan-tests:
+    name: Run Nan Tests
+    if: ${{ inputs.is-release == false }}
+    runs-on: aks-linux-medium
+    needs: build
+    timeout-minutes: 20
+    env: 
+      TARGET_ARCH: x64
+    container:
+      image: ghcr.io/electron/build:latest
+      options: --user root
+    steps:
+    - name: Load Build Tools
+      run: |
+        export BUILD_TOOLS_SHA=ef894bc3cfa99d84a3b731252da0f83f500e4032
+        npm i -g @electron/build-tools
+        e auto-update disable
+        e init --root=$(pwd) --out=Default ${{ inputs.gn-build-type }}
+    - name: Checkout Electron
+      uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
+      with:
+        path: src/electron
+        fetch-depth: 0
+    - name: Install Dependencies
+      run: |
+        cd src/electron
+        node script/yarn install
+    - name: Get Depot Tools
+      timeout-minutes: 5
+      run: |
+        git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
+        sed -i '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja
+        cd depot_tools
+        git apply --3way ../src/electron/.github/workflows/config/gclient.diff
+        # Ensure depot_tools does not update.
+        test -d depot_tools && cd depot_tools
+        touch .disable_auto_update
+    - name: Add Depot Tools to PATH
+      run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
+    - name: Download Generated Artifacts
+      uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
+      with:
+        name: generated_artifacts_linux_${{ env.TARGET_ARCH }}
+        path: ./generated_artifacts_linux_${{ env.TARGET_ARCH }}
+    - name: Restore Generated Artifacts
+      run: ./src/electron/script/actions/restore-artifacts.sh
+    - name: Unzip Dist
+      run: |
+        cd src/out/Default
+        unzip -:o dist.zip
+    - name: Setup Linux for Headless Testing
+      run: sh -e /etc/init.d/xvfb start
+    - name: Run Node.js Tests
+      run: |
+        cd src
+        node electron/script/nan-spec-runner.js
+    - name: Wait for active SSH sessions
+      if: always() && !cancelled()
+      run: |
+        while [ -f /var/.ssh-lock ]
+        do
+          sleep 60
+        done
+

+ 15 - 6
.github/workflows/macos-pipeline.yml

@@ -1,4 +1,4 @@
-name: Build MacOS
+name: MacOS Pipeline
 
 on:
   workflow_call:
@@ -510,6 +510,7 @@ jobs:
         name: generated_artifacts_mas_${{ env.TARGET_ARCH }}
         path: ./generated_artifacts_mas_${{ env.TARGET_ARCH }}
   test:
+    name: Run Electron Tests
     if: ${{ inputs.is-release == false }}
     runs-on: macos-14-xlarge
     needs: build
@@ -568,11 +569,11 @@ jobs:
         unzip -:o dist.zip
         unzip -:o chromedriver.zip
         unzip -:o mksnapshot.zip
-    - name: Import & Trust Self-Signed Codesigning Cert on MacOS
-      run: |
-        sudo security authorizationdb write com.apple.trust-settings.admin allow
-        cd src/electron
-        ./script/codesign/generate-identity.sh
+    # - name: Import & Trust Self-Signed Codesigning Cert on MacOS
+    #   run: |
+    #     sudo security authorizationdb write com.apple.trust-settings.admin allow
+    #     cd src/electron
+    #     ./script/codesign/generate-identity.sh
     - name: Run Electron Tests
       env:
         MOCHA_REPORTER: mocha-multi-reporters
@@ -583,3 +584,11 @@ jobs:
       run: |
         cd src/electron
         node script/yarn test --runners=main --trace-uncaught --enable-logging
+    - name: Verify mksnapshot
+      run: |
+        cd src
+        python3 electron/script/verify-mksnapshot.py --source-root "$PWD" --build-dir out/Default
+    - name: Verify ChromeDriver
+      run: |
+        cd src
+        python3 electron/script/verify-chromedriver.py --source-root "$PWD" --build-dir out/Default

+ 3 - 0
script/actions/move-artifacts.sh

@@ -8,6 +8,9 @@ if [ "`uname`" == "Darwin" ]; then
   fi
 elif [ "`uname`" == "Linux" ]; then
   BUILD_TYPE="linux"
+else
+  echo "Unsupported platform"
+  exit 1
 fi
 
 GENERATED_ARTIFACTS="generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}"

+ 3 - 0
script/actions/restore-artifacts.sh

@@ -8,6 +8,9 @@ if [ "`uname`" == "Darwin" ]; then
   fi
 elif [ "`uname`" == "Linux" ]; then
   BUILD_TYPE="linux"
+else
+  echo "Unsupported platform"
+  exit 1
 fi
 
 GENERATED_ARTIFACTS="generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}"

+ 6 - 5
script/nan-spec-runner.js

@@ -90,16 +90,16 @@ async function main () {
     env.LDFLAGS = ldflags;
   }
 
-  const { status: buildStatus } = cp.spawnSync(NPX_CMD, ['node-gyp', 'rebuild', '--verbose', '--directory', 'test', '-j', 'max'], {
+  const { status: buildStatus, signal } = cp.spawnSync(NPX_CMD, ['node-gyp', 'rebuild', '--verbose', '--directory', 'test', '-j', 'max'], {
     env,
     cwd: NAN_DIR,
     stdio: 'inherit',
     shell: process.platform === 'win32'
   });
 
-  if (buildStatus !== 0) {
+  if (buildStatus !== 0 || signal != null) {
     console.error('Failed to build nan test modules');
-    return process.exit(buildStatus);
+    return process.exit(buildStatus !== 0 ? buildStatus : signal);
   }
 
   const { status: installStatus } = cp.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install'], {
@@ -108,9 +108,10 @@ async function main () {
     stdio: 'inherit',
     shell: process.platform === 'win32'
   });
-  if (installStatus !== 0) {
+
+  if (installStatus !== 0 || signal != null) {
     console.error('Failed to install nan node_modules');
-    return process.exit(installStatus);
+    return process.exit(installStatus !== 0 ? installStatus : signal);
   }
 
   const onlyTests = args.only && args.only.split(',');

+ 1 - 0
script/node-disabled-tests.json

@@ -4,6 +4,7 @@
   "parallel/test-bootstrap-modules",
   "parallel/test-child-process-fork-exec-path",
   "parallel/test-code-cache",
+  "parallel/test-cluster-primary-error",
   "parallel/test-crypto-aes-wrap",
   "parallel/test-crypto-authenticated-stream",
   "parallel/test-crypto-des3-wrap",