From 30885e5f9f7564f05f9d01c69c73b9b7c28a36bb Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 13 Jun 2024 14:14:33 -0500 Subject: [PATCH] build: add Linux GHA test step (#42460) * build: add Linux GHA test step * Switch to medium AKS runners * Add missing BUILD_TYPE to restore-artifact * Fix untar to current dir * Remove known hosts logic * Add missing Node.js headers step * Fix for active SSH sessions * Fix storing artifacts * Build on x64 for test --- .github/workflows/linux-pipeline.yml | 83 +++++++++++++++++++++++++++- script/actions/move-artifacts.sh | 18 +++--- script/actions/restore-artifacts.sh | 26 +++++++-- 3 files changed, 110 insertions(+), 17 deletions(-) diff --git a/.github/workflows/linux-pipeline.yml b/.github/workflows/linux-pipeline.yml index 7f8a2f9bfbc0..fc0527cc2499 100644 --- a/.github/workflows/linux-pipeline.yml +++ b/.github/workflows/linux-pipeline.yml @@ -66,7 +66,7 @@ jobs: strategy: fail-fast: false matrix: - build-arch: [ arm64 ] # x64, arm + build-arch: [ x64 ] # arm64, arm env: TARGET_ARCH: ${{ matrix.build-arch }} runs-on: aks-linux-large @@ -163,8 +163,6 @@ jobs: echo "DEPSHASH=$(shasum src/electron/.depshash | cut -f1 -d' ')" >> $GITHUB_ENV - name: Add CHROMIUM_BUILDTOOLS_PATH to env run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV - - name: Fix Known Hosts on Linux - run: src/electron/.circleci/fix-known-hosts.sh - name: Install build-tools & Setup RBE run: | echo "NUMBER_OF_NINJA_PROCESSES=300" >> $GITHUB_ENV @@ -247,6 +245,10 @@ jobs: cd src e build electron:electron_chromedriver -j $NUMBER_OF_NINJA_PROCESSES e build electron:electron_chromedriver_zip + - name: Build Node.js headers + run: | + cd src + e build electron:node_headers - name: Generate & Zip Symbols run: | # Generate breakpad symbols on release builds @@ -299,3 +301,78 @@ jobs: with: name: generated_artifacts_linux_${{ matrix.build-arch }} path: ./generated_artifacts_linux_${{ matrix.build-arch }} + test: + if: ${{ inputs.is-release == false }} + runs-on: aks-linux-medium + container: + image: ghcr.io/electron/build:latest + options: --user root + needs: build + strategy: + fail-fast: false + matrix: + build-arch: [ arm64 ] # x64, arm + env: + TARGET_ARCH: ${{ matrix.build-arch }} + 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_${{ matrix.build-arch }} + path: ./generated_artifacts_linux_${{ matrix.build-arch }} + - name: Restore Generated Artifacts + run: ./src/electron/script/actions/restore-artifacts.sh + - name: Unzip Dist, Mksnapshot & Chromedriver + run: | + cd src/out/Default + unzip -:o dist.zip + unzip -:o chromedriver.zip + unzip -:o mksnapshot.zip + - name: Setup for headless testing + run: sh -e /etc/init.d/xvfb start + - name: Run Electron Tests + env: + MOCHA_REPORTER: mocha-multi-reporters + ELECTRON_TEST_RESULTS_DIR: junit + MOCHA_MULTI_REPORTERS: mocha-junit-reporter, tap + ELECTRON_DISABLE_SECURITY_WARNINGS: 1 + ELECTRON_SKIP_NATIVE_MODULE_TESTS: true + run: | + cd src/electron + node script/yarn test --runners=main --trace-uncaught --enable-logging + - name: Wait for active SSH sessions + if: always() && !cancelled() + run: | + while [ -f /var/.ssh-lock ] + do + sleep 60 + done \ No newline at end of file diff --git a/script/actions/move-artifacts.sh b/script/actions/move-artifacts.sh index f026b56ad211..28b8d869dff8 100755 --- a/script/actions/move-artifacts.sh +++ b/script/actions/move-artifacts.sh @@ -10,14 +10,16 @@ elif [ "`uname`" == "Linux" ]; then BUILD_TYPE="linux" fi -echo Creating generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}... -rm -rf generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH} -mkdir generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH} +GENERATED_ARTIFACTS="generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}" + +echo Creating $GENERATED_ARTIFACTS... +rm -rf $GENERATED_ARTIFACTS +mkdir $GENERATED_ARTIFACTS mv_if_exist() { if [ -f "$1" ] || [ -d "$1" ]; then echo Storing $1 - mv $1 generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH} + mv $1 $GENERATED_ARTIFACTS else echo Skipping $1 - It is not present on disk fi @@ -26,7 +28,7 @@ mv_if_exist() { cp_if_exist() { if [ -f "$1" ] || [ -d "$1" ]; then echo Storing $1 - cp $1 generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH} + cp $1 $GENERATED_ARTIFACTS else echo Skipping $1 - It is not present on disk fi @@ -55,12 +57,12 @@ tar_src_dirs_if_exist() { src/v8/tools/builtins-pgo do if [ -d "$dir" ]; then - mkdir -p build_artifacts/$dir - cp -r $dir build_artifacts/$dir + mkdir -p build_artifacts/$(dirname $dir) + cp -r $dir/ build_artifacts/$dir fi done - tar -cf build_artifacts.tarbuild_artifacts + tar -C build_artifacts -cf build_artifacts.tar ./ mv_if_exist build_artifacts.tar } diff --git a/script/actions/restore-artifacts.sh b/script/actions/restore-artifacts.sh index f174cf44b257..ac1baee19679 100755 --- a/script/actions/restore-artifacts.sh +++ b/script/actions/restore-artifacts.sh @@ -1,24 +1,38 @@ #!/bin/bash +if [ "`uname`" == "Darwin" ]; then + if [ -z "$MAS_BUILD" ]; then + BUILD_TYPE="darwin" + else + BUILD_TYPE="mas" + fi +elif [ "`uname`" == "Linux" ]; then + BUILD_TYPE="linux" +fi + +GENERATED_ARTIFACTS="generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}" + mv_if_exist() { - if [ -f "generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}/$1" ] || [ -d "generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}/$1" ]; then + if [ -f "${GENERATED_ARTIFACTS}/$1" ] || [ -d "${GENERATED_ARTIFACTS}/$1" ]; then echo Restoring $1 to $2 mkdir -p $2 - mv generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}/$1 $2 + mv $GENERATED_ARTIFACTS/$1 $2 else echo Skipping $1 - It is not present on disk fi } untar_if_exist() { - if [ -f "generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}/$1" ] || [ -d "generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}/$1" ]; then - echo Restoring $1 to $2 - tar -xf generated_artifacts_${BUILD_TYPE}_${TARGET_ARCH}/$1 $2 + if [ -f "${GENERATED_ARTIFACTS}/$1" ] || [ -d "${GENERATED_ARTIFACTS}/$1" ]; then + echo Restoring $1 to current directory + tar -xf ${GENERATED_ARTIFACTS}/$1 else echo Skipping $1 - It is not present on disk fi } +echo Restoring artifacts from $GENERATED_ARTIFACTS + # Restore generated artifacts mv_if_exist dist.zip src/out/Default mv_if_exist node_headers.tar.gz src/out/Default/gen @@ -30,4 +44,4 @@ mv_if_exist hunspell_dictionaries.zip src/out/Default mv_if_exist cross-arch-snapshots src # Restore build artifacts -untar_if_exist build_artifacts.tar ./ +untar_if_exist build_artifacts.tar