瀏覽代碼

Utilize arm64 native runners for 3p builds (#286)

Signed-off-by: Mike Chang <[email protected]>
Mike Chang 2 周之前
父節點
當前提交
179d337c75
共有 1 個文件被更改,包括 44 次插入54 次删除
  1. 44 54
      .github/workflows/build-package.yaml

+ 44 - 54
.github/workflows/build-package.yaml

@@ -34,41 +34,61 @@ jobs:
         
         for FILE in $CHANGED_FILES; do
           if [[ $FILE == package_build_list_host_* ]]; then
+            echo "Checking file $FILE"
             PLATFORM=$(echo $FILE | sed -n 's/package_build_list_host_\(.*\).json/\1/p')
-            case $PLATFORM in
-            linux*)
-              OS_RUNNER="ubuntu-20.04"
-              ;;
-            windows)
-              OS_RUNNER="windows-latest" # This is bundled with VS2022
-              ;;
-            darwin)
-              OS_RUNNER="macos-13" # Use x86 runner image. Latest uses ARM64
-              ;;
-            *)
-              OS_RUNNER="windows-latest" # default
-              ;;
-            esac
+            echo "Using platform $PLATFORM"
 
             # Only get the changes that can be built
+            # First, get the diff output
+            DIFF=$(git diff ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} \
+                  --no-ext-diff --unified=0 \
+                  --exit-code -a --no-prefix -- $FILE | egrep "^\+[^\+]" | egrep -v "^\+\+\+ ")
+            
+            # Use an associative array to track which packages we've already processed
+            declare -A PROCESSED_PACKAGES
+            
+            # Then, iterate over the lines
             IFS=$'\n' # Process each line in the package build file
-            for LINE in DIFF=$(git diff ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} \
-                      --no-ext-diff --unified=0 \
-                      --exit-code -a --no-prefix -- $FILE | egrep "^\+[^\+]" | egrep -v "^\+\+\+ "); do
+            for LINE in $DIFF; do
               unset IFS # Reset IFS to avoid word splitting
               PACKAGE=$(echo $LINE | cut -d'"' -f2)
-              PACKPATH=$(echo $LINE | egrep -o "package-system/[^/ ]+(?=/| )" | head -n 1)
+              
+              # Skip if we've already processed this package
+              if [[ -n "${PROCESSED_PACKAGES[$PACKAGE]}" ]]; then
+                continue
+              fi
+              
+              PACKPATH=$(echo $LINE | grep -oE "package-system/[^/ ]+" | head -n 1)
               if [[ -z "${DOCKERFILE["$PACKAGE"]}" && -n "$PACKPATH" ]]; then
                 DOCKER=$(test -e ${PACKPATH%% }/Dockerfile* && echo 1 || echo 0) # Assume the build scripts will use the Dockerfile if found in the package path
                 DOCKERFILE["$PACKAGE"]=1 # Mark Dockerfile check as done
               fi
 
-              # Special cases for certain packages
-              if [[ $PACKAGE =~ "DirectXShaderCompilerDxc" ]] && [[ $PLATFORM =~ "windows" ]]; then
-                OS_RUNNER="windows-2019"
+              # Determine the OS runner based on the package name
+              if [[ $PACKAGE =~ "aarch64" ]]; then
+                PACKAGE_OS="ubuntu-22.04-arm"
+                echo "OS Image selected for $PACKAGE: $PACKAGE_OS"
+              elif [[ $PACKAGE =~ "DirectXShaderCompilerDxc" ]] && [[ $PLATFORM =~ "windows" ]]; then
+                PACKAGE_OS="windows-2019"
+                echo "OS Image selected for $PACKAGE: $PACKAGE_OS"
+              elif [[ $PLATFORM =~ "linux" ]]; then
+                PACKAGE_OS="ubuntu-22.04"
+                echo "OS Image selected for $PACKAGE: $PACKAGE_OS"
+              elif [[ $PLATFORM =~ "windows" ]]; then
+                PACKAGE_OS="windows-latest"
+                echo "OS Image selected for $PACKAGE: $PACKAGE_OS"
+              elif [[ $PLATFORM =~ "darwin" ]]; then
+                PACKAGE_OS="macos-13"
+                echo "OS Image selected for $PACKAGE: $PACKAGE_OS"
+              else
+                PACKAGE_OS="windows-latest" # Default
+                echo "OS Image selected for $PACKAGE: $PACKAGE_OS (default)"
               fi
               
-              PACKAGES_JSON["$PACKAGE"]="{\"package\": \"$PACKAGE\", \"os\": \"$OS_RUNNER\", \"dockerfile\": \"$DOCKER\"}"
+              PACKAGES_JSON["$PACKAGE"]="{\"package\": \"$PACKAGE\", \"os\": \"$PACKAGE_OS\", \"dockerfile\": \"$DOCKER\"}"
+              
+              # Mark as processed
+              PROCESSED_PACKAGES[$PACKAGE]=1
             done
             unset IFS
           fi
@@ -138,7 +158,7 @@ jobs:
 
     - name: Expand disk size for Linux
       uses: easimon/maximize-build-space@v10
-      if: runner.os == 'Linux'
+      if: runner.os == 'Linux' && !contains(matrix.os, 'arm')
       with:
         root-reserve-mb: 20000
         swap-size-mb: 200
@@ -231,6 +251,7 @@ jobs:
 
     - name: Use sccache
       uses: hendrikmuhs/[email protected]
+      if: ${{ !contains(matrix.os, 'arm') }}
       with:
         variant: sccache
         max-size: 2048M
@@ -244,43 +265,12 @@ jobs:
         sudo apt-get install -y qemu qemu-user-static
 
     - name: Run build command
-      if: ${{ (!contains(matrix.package, 'aarch64')) || (matrix.dockerfile == '1') }}
       env:
         CMAKE_CXX_COMPILER_LAUNCHER: sccache
         CMAKE_C_COMPILER_LAUNCHER: sccache
         CMAKE_GENERATOR: Ninja # ccache/sccache cannot be used as the compiler launcher under cmake if the generator is MSBuild
       run: |
         python3 scripts/o3de_package_scripts/build_package.py --search_path source ${{ matrix.package }}
-
-    - name: Run build command (aarch64) # Generic build for packages without a Dockerfile
-      if: ${{ (contains(matrix.package, 'aarch64')) && (matrix.dockerfile != '1') }}
-      uses: uraimo/[email protected]
-      with:
-        arch: none
-        distro: none
-        base_image: ghcr.io/${{ github.repository }}/run-on-arch-${{ github.repository_owner }}-${{ github.event.repository.name }}-build-container-aarch64-ubuntu20-04:latest # built from build-container.yaml
-        setup: |
-          grep -q ${{ matrix.package }} ${PWD}/source/package_build_list_host_linux.json || rm ${PWD}/source/package_build_list_host_linux.json
-        dockerRunArgs: |
-          --platform=linux/arm64 
-          --user ${{ steps.configure.outputs.uid_gid }}
-          --volume "${PWD}:/workspace"
-          --volume "${PWD}/scripts:/scripts"
-          --volume "${PWD}/source:/source"
-        env: |
-          CMAKE_CXX_COMPILER_LAUNCHER: sccache
-          CMAKE_C_COMPILER_LAUNCHER: sccache
-          SCCACHE_IDLE_TIMEOUT: 0 
-          SCCACHE_DIR: /workspace/.sccache
-          SCCACHE_CACHE_SIZE: 2048M
-        shell: /bin/bash
-        run: |
-          lsb_release -a
-          uname -a
-          sccache --start-server
-          sccache -z
-          ls -lah /workspace
-          python3 /scripts/o3de_package_scripts/build_package.py --search_path /source/ ${{ matrix.package }}
           
     - name: Upload packages
       uses: actions/upload-artifact@v4