Browse Source

build: remove sync, try disk space prune

Keeley Hammond 1 year ago
parent
commit
1411101adc
1 changed files with 130 additions and 43 deletions
  1. 130 43
      .github/workflows/mac-build.yml

+ 130 - 43
.github/workflows/mac-build.yml

@@ -57,49 +57,48 @@ jobs:
         touch .disable_auto_update
     - run: echo "$PWD/depot_tools" >> $GITHUB_PATH
     # step-gclient-sync, L287
-    # TODO(vertedinde): Re-enable sync after SSH debug integration is working
-    - name: Gclient Sync
-      run: |
-        # If we did not restore a complete sync then we need to sync for realz
-        if [ ! -s "src/electron/.circle-sync-done" ]; then
-          gclient config \
-            --name "src/electron" \
-            --unmanaged \
-            $GCLIENT_EXTRA_ARGS \
-            "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
+    # - name: Gclient Sync
+    #   run: |
+    #     # If we did not restore a complete sync then we need to sync for realz
+    #     if [ ! -s "src/electron/.circle-sync-done" ]; then
+    #       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 [ "$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
-            # TODO(vertedinde): Let's not stress on patchup right now, just sync it
-            # 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
-        fi
+    #       ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 gclient sync --with_branch_heads --with_tags -vvvvv
+    #       if [ "$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
+    #         # TODO(vertedinde): Let's not stress on patchup right now, just sync it
+    #         # 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
+    #     fi
       # step-gclient-sync, L976
     - name: Minimize the size of the cache
       run: |
@@ -113,6 +112,94 @@ jobs:
         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
+    - name: Free up space on MacOS
+      run: |
+        sudo mkdir -p $TMPDIR/del-target
+
+        tmpify() {
+          if [ -d "$1" ]; then
+            sudo mv "$1" $TMPDIR/del-target/$(echo $1|shasum -a 256|head -n1|cut -d " " -f1)
+          fi
+        }
+
+        strip_universal_deep() {
+          opwd=$(pwd)
+          cd $1
+          f=$(find . -perm +111 -type f)
+          for fp in $f
+          do
+            if [[ $(file "$fp") == *"universal binary"* ]]; then
+              if [ "`arch`" == "arm64" ]; then
+                if [[ $(file "$fp") == *"x86_64"* ]]; then
+                  sudo lipo -remove x86_64 "$fp" -o "$fp" || true
+                fi
+              else
+                if [[ $(file "$fp") == *"arm64e)"* ]]; then
+                  sudo lipo -remove arm64e "$fp" -o "$fp" || true
+                fi
+                if [[ $(file "$fp") == *"arm64)"* ]]; then
+                  sudo lipo -remove arm64 "$fp" -o "$fp" || true
+                fi
+              fi
+            fi
+          done
+
+          cd $opwd
+        }
+
+        tmpify /Library/Developer/CoreSimulator
+        tmpify ~/Library/Developer/CoreSimulator
+        tmpify $(xcode-select -p)/Platforms/AppleTVOS.platform
+        tmpify $(xcode-select -p)/Platforms/iPhoneOS.platform
+        tmpify $(xcode-select -p)/Platforms/WatchOS.platform
+        tmpify $(xcode-select -p)/Platforms/WatchSimulator.platform
+        tmpify $(xcode-select -p)/Platforms/AppleTVSimulator.platform
+        tmpify $(xcode-select -p)/Platforms/iPhoneSimulator.platform
+        tmpify $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/metal/ios
+        tmpify $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift
+        tmpify $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0
+        tmpify ~/.rubies
+        tmpify ~/Library/Caches/Homebrew
+        tmpify /usr/local/Homebrew
+
+        sudo rm -rf $TMPDIR/del-target
+
+        # sudo rm -rf "/System/Library/Desktop Pictures"
+        # sudo rm -rf /System/Library/Templates/Data
+        # sudo rm -rf /System/Library/Speech/Voices
+        # sudo rm -rf "/System/Library/Screen Savers"
+        # sudo rm -rf /System/Volumes/Data/Library/Developer/CommandLineTools/SDKs
+        # sudo rm -rf "/System/Volumes/Data/Library/Application Support/Apple/Photos/Print Products"
+        # sudo rm -rf /System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/
+        # sudo rm -rf /System/Volumes/Data/Library/Java
+        # sudo rm -rf /System/Volumes/Data/Library/Ruby
+        # sudo rm -rf /System/Volumes/Data/Library/Printers
+        # sudo rm -rf /System/iOSSupport
+        # sudo rm -rf /System/Applications/*.app
+        # sudo rm -rf /System/Applications/Utilities/*.app
+        # sudo rm -rf /System/Library/LinguisticData
+        # sudo rm -rf /System/Volumes/Data/private/var/db/dyld/*
+        # sudo rm -rf /System/Library/Fonts/*
+        # sudo rm -rf /System/Library/PreferencePanes
+        # sudo rm -rf /System/Library/AssetsV2/*
+        sudo rm -rf /Applications/Safari.app
+        sudo rm -rf ~/project/src/third_party/catapult/tracing/test_data
+        sudo rm -rf ~/project/src/third_party/angle/third_party/VK-GL-CTS
+
+        # lipo off some huge binaries arm64 versions to save space
+        strip_universal_deep $(xcode-select -p)/../SharedFrameworks
+        # strip_arm_deep /System/Volumes/Data/Library/Developer/CommandLineTools/usr
+    # On macOS 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 all .git directories under src on MacOS to free space
+      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: Generate DEPS Hash
       run: |
         node src/electron/script/generate-deps-hash.js && cat src/electron/.depshash-target
@@ -131,7 +218,7 @@ jobs:
         --debug
     
     # TODO(vertedinde): This assumes the happy path that a cache exists
-    # TODO(vertedinde): Also handle the path of a cache not existing and needing a full sync
+    # Also handle the path of a cache not existing and needing a full sync
     # Follows https://github.com/electron/electron/blob/main/.circleci/config/base.yml#L1310
     # - name: Download Azure Blob Src Cache
     #   run: |