Browse Source

build: initial Linux pipeline checkout (#42429)

* build: create config for GHA build linux

* build: restructure linux pipeline files

* build (do not merge): don't run CircleCI or Appveyor

* build: run on push

* build: add checkout step

* build: fix .yml syntax

* Remove Azure CLI install

* Revert "build (do not merge): don't run CircleCI or Appveyor"

This reverts commit eb55e317bc74f2e5fa596ac90814d753d4fb6124.

* build: change pipeline SHA to main

* chore: update patches

---------

Co-authored-by: Keeley Hammond <[email protected]>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Shelley Vohr 10 months ago
parent
commit
92de23bb3c

+ 17 - 0
.github/workflows/linux-build.yml

@@ -0,0 +1,17 @@
+name: Build Linux
+
+on:
+  workflow_dispatch:
+  # push:
+  # pull_request:
+
+jobs:
+  build:
+    uses: electron/electron/.github/workflows/linux-pipeline.yml@main
+    with:
+      is-release: false
+      gn-config: //electron/build/args/testing.gn
+      gn-build-type: testing
+      generate-symbols: false
+      upload-to-storage: '0'
+    secrets: inherit

+ 190 - 0
.github/workflows/linux-pipeline.yml

@@ -0,0 +1,190 @@
+name: Pipeline Linux
+
+on:
+  workflow_call:
+    inputs:
+      is-release:
+        description: 'Whether this build job is a release job'
+        required: true
+        type: boolean
+        default: false
+      gn-config:
+        description: 'The gn arg configuration to use'
+        required: true
+        type: string
+        default: //electron/build/args/testing.gn
+      gn-build-type:
+        description: 'The gn build type - testing or release'
+        required: true
+        type: string
+        default: testing
+      generate-symbols: 
+        description: 'Whether or not to generate symbols'
+        required: true
+        type: boolean
+        default: false
+      upload-to-storage: 
+        description: 'Whether or not to upload build artifacts to external storage'
+        required: true
+        type: string
+        default: '0'
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
+env:
+  AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }}
+  AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }}
+  AZURE_STORAGE_CONTAINER_NAME: ${{ secrets.AZURE_STORAGE_CONTAINER_NAME }}
+  ELECTRON_ARTIFACTS_BLOB_STORAGE: ${{ secrets.ELECTRON_ARTIFACTS_BLOB_STORAGE }}
+  ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
+  ELECTRON_GITHUB_TOKEN: ${{ secrets.ELECTRON_GITHUB_TOKEN }}
+  GN_CONFIG: ${{ inputs.gn-config }}
+  # Disable pre-compiled headers to reduce out size - only useful for rebuilds
+  GN_BUILDFLAG_ARGS: 'enable_precompiled_headers = false'
+  GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
+  CHECK_DIST_MANIFEST: '1'
+  IS_GHA_RELEASE: true
+  ELECTRON_OUT_DIR: Default
+
+jobs:
+  checkout:
+    runs-on: LargeLinuxRunner
+    steps:
+    - name: Checkout Electron
+      uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
+      with:
+        path: src/electron
+    - name: Set GIT_CACHE_PATH to make gclient to use the cache
+      run: |
+        echo "GIT_CACHE_PATH=$(pwd)/git-cache" >> $GITHUB_ENV
+    - name: Setup Node.js/npm
+      uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
+      with:
+        node-version: 20.11.x
+        cache: yarn
+        cache-dependency-path: src/electron/yarn.lock
+    - 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
+        if [ "`uname`" == "Darwin" ]; then
+          # remove ninjalog_uploader_wrapper.py from autoninja since we don't use it and it causes problems
+          sed -i '' '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja
+        else
+          sed -i '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja
+          # Remove swift-format dep from cipd on macOS until we send a patch upstream.
+          cd depot_tools
+          git apply --3way ../src/electron/.github/workflows/config/gclient.diff
+        fi
+        # 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: Generate DEPS Hash
+      run: |
+        node src/electron/script/generate-deps-hash.js && cat src/electron/.depshash-target
+        echo "DEPSHASH=v1-src-cache-$(shasum src/electron/.depshash | cut -f1 -d' ')" >> $GITHUB_ENV
+    - name: Check If Cache Exists
+      id: check-cache
+      run: |
+        exists_json=$(az storage blob exists \
+          --account-name $AZURE_STORAGE_ACCOUNT \
+          --account-key $AZURE_STORAGE_KEY \
+          --container-name $AZURE_STORAGE_CONTAINER_NAME \
+          --name $DEPSHASH)
+
+        cache_exists=$(echo $exists_json | jq -r '.exists')
+        echo "cache_exists=$cache_exists" >> $GITHUB_OUTPUT
+
+        if (test "$cache_exists" = "true"); then
+          echo "Cache Exists for $DEPSHASH"
+        else
+          echo "Cache Does Not Exist for $DEPSHASH"
+        fi
+    - name: Gclient Sync
+      if: steps.check-cache.outputs.cache_exists == 'false'
+      run: |
+        gclient config \
+          --name "src/electron" \
+          --unmanaged \
+          ${GCLIENT_EXTRA_ARGS} \
+          "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
+
+        ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 gclient sync --with_branch_heads --with_tags -vvvvv
+        if [ ${{ inputs.is-release != true }} ]; then
+          # Re-export all the patches to check if there were changes.
+          python3 src/electron/script/export_all_patches.py src/electron/patches/config.json
+          cd src/electron
+          git update-index --refresh || true
+          if ! git diff-index --quiet HEAD --; then
+            # There are changes to the patches. Make a git commit with the updated patches
+            git add patches
+            GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
+            # Export it
+            mkdir -p ../../patches
+            git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
+            if (node ./script/push-patch.js 2> /dev/null > /dev/null); then
+              echo
+              echo "======================================================================"
+              echo "Changes to the patches when applying, we have auto-pushed the diff to the current branch"
+              echo "A new CI job will kick off shortly"
+              echo "======================================================================"
+              exit 1
+            else
+              echo
+              echo "======================================================================"
+              echo "There were changes to the patches when applying."
+              echo "Check the CI artifacts for a patch you can apply to fix it."
+              echo "======================================================================"
+              exit 1
+            fi
+          fi
+        fi
+
+    # delete all .git directories under src/ except for
+    # third_party/angle/ and third_party/dawn/ because of build time generation of files
+    # gen/angle/commit.h depends on third_party/angle/.git/HEAD
+    # https://chromium-review.googlesource.com/c/angle/angle/+/2074924
+    # and dawn/common/Version_autogen.h depends on  third_party/dawn/.git/HEAD
+    # https://dawn-review.googlesource.com/c/dawn/+/83901
+    # TODO: maybe better to always leave out */.git/HEAD file for all targets ?
+    - name: Delete .git directories under src to free space
+      if: steps.check-cache.outputs.cache_exists == 'false'
+      run: |
+        cd src
+        ( find . -type d -name ".git" -not -path "./third_party/angle/*" -not -path "./third_party/dawn/*" -not -path "./electron/*" ) | xargs rm -rf
+    - name: Minimize Cache Size for Upload
+      if: steps.check-cache.outputs.cache_exists == 'false'
+      run: |
+        rm -rf src/android_webview
+        rm -rf src/ios/chrome
+        rm -rf src/third_party/blink/web_tests
+        rm -rf src/third_party/blink/perf_tests
+        rm -rf src/chrome/test/data/xr/webvr_info
+        rm -rf src/third_party/angle/third_party/VK-GL-CTS/src
+        rm -rf src/third_party/swift-toolchain
+        rm -rf src/third_party/swiftshader/tests/regres/testlists
+        rm -rf src/electron
+    - name: Compress Src Directory
+      if: steps.check-cache.outputs.cache_exists == 'false'
+      run: |
+        echo "Uncompressed src size: $(du -sh src | cut -f1 -d' ')"
+        tar -cvf $DEPSHASH.tar src
+        echo "Compressed src to $(du -sh $DEPSHASH.tar | cut -f1 -d' ')"
+    - name: Upload Compressed Src Cache to Azure
+      if: steps.check-cache.outputs.cache_exists == 'false'
+      run: |
+        az storage blob upload \
+          --account-name $AZURE_STORAGE_ACCOUNT \
+          --account-key $AZURE_STORAGE_KEY \
+          --container-name $AZURE_STORAGE_CONTAINER_NAME \
+          --file $DEPSHASH.tar \
+          --name $DEPSHASH \
+          --debug

+ 25 - 0
.github/workflows/linux-publish.yml

@@ -0,0 +1,25 @@
+name: Publish Linux
+
+on:
+  workflow_dispatch:
+    inputs:
+      upload-to-storage:
+        description: 'Uploads to Azure storage'
+        required: false
+        default: '1'
+        type: string
+      run-macos-publish:
+        description: 'Run the publish jobs vs just the build jobs'
+        type: boolean
+        default: false
+
+jobs:
+  publish:
+    uses: electron/electron/.github/workflows/linux-pipeline.yml@main
+    with:
+      is-release: true
+      gn-config: //electron/build/args/release.gn
+      gn-build-type: release
+      generate-symbols: true
+      upload-to-storage: ${{ inputs.upload-to-storage }}
+    secrets: inherit

+ 0 - 1
.github/workflows/macos-build.yml

@@ -7,7 +7,6 @@ on:
 
 jobs:
   build:
-  # TODO(vertedinde): Change this to main before merge
     uses: electron/electron/.github/workflows/macos-pipeline.yml@main
     with:
       is-release: false

+ 0 - 2
.github/workflows/macos-pipeline.yml

@@ -110,8 +110,6 @@ jobs:
           echo "Cache Does Not Exist for $DEPSHASH"
         fi
     - name: Gclient Sync
-      # If there is no existing src cache, we need to do a full gclient sync.
-      # TODO(codebytere): Add stale patch handling for non-release builds.
       if: steps.check-cache.outputs.cache_exists == 'false'
       run: |
         gclient config \

+ 0 - 1
.github/workflows/macos-publish.yml

@@ -15,7 +15,6 @@ on:
 
 jobs:
   publish:
-  # TODO(vertedinde): Change this to main before merge
     uses: electron/electron/.github/workflows/macos-pipeline.yml@main
     with:
       is-release: true

+ 2 - 2
patches/chromium/feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch

@@ -246,7 +246,7 @@ index 20ad001988831afca73315c577f90c824a36e282..57a8d35ace583eaafb526f70935d21c0
    // NewSelectFileDialogImplKDE will actually work.
    static bool CheckKDEDialogWorksOnUIThread(std::string& kdialog_version);
 diff --git a/ui/shell_dialogs/select_file_dialog_linux_kde.cc b/ui/shell_dialogs/select_file_dialog_linux_kde.cc
-index 302147116649575649e44c0fc87e2b0a915db5db..49a4ee5d2a3552b1352c28344e4091308a93daa9 100644
+index c79fb47bfba9233da7d2c1438d1e26600684fc78..d7cc7cd70653aaa5b628ef456dcb48a2eef5ec5e 100644
 --- a/ui/shell_dialogs/select_file_dialog_linux_kde.cc
 +++ b/ui/shell_dialogs/select_file_dialog_linux_kde.cc
 @@ -480,6 +480,9 @@ void SelectFileDialogLinuxKde::CreateSelectFolderDialog(
@@ -269,7 +269,7 @@ index 302147116649575649e44c0fc87e2b0a915db5db..49a4ee5d2a3552b1352c28344e409130
            &SelectFileDialogLinuxKde::OnSelectSingleFolderDialogResponse, this,
            parent, params));
 diff --git a/ui/shell_dialogs/select_file_dialog_linux_portal.cc b/ui/shell_dialogs/select_file_dialog_linux_portal.cc
-index 9e4cc2a3fa2db0397655550a2c6209543f32cbd7..caad1879a46fcb285ba4d4384ff46a7223046b15 100644
+index 65727489ddecb755eeabbd194ce843ca9eaa59c9..b15bace56639d2f914f8f76edfa1b28e33165b48 100644
 --- a/ui/shell_dialogs/select_file_dialog_linux_portal.cc
 +++ b/ui/shell_dialogs/select_file_dialog_linux_portal.cc
 @@ -219,6 +219,10 @@ void SelectFileDialogLinuxPortal::SelectFileImpl(