Skip to content

Commit

Permalink
Add dockerfile detection, qemu env for build scripts, longpath support (
Browse files Browse the repository at this point in the history
  • Loading branch information
amzn-changml authored Oct 12, 2023
1 parent 280f5e2 commit a8019a5
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions .github/workflows/build-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
OS_RUNNER="ubuntu-20.04"
;;
windows)
OS_RUNNER="windows-2019"
OS_RUNNER="windows-latest" # This is bundled with VS2022
;;
darwin)
OS_RUNNER="macos-latest"
Expand All @@ -49,14 +49,11 @@ jobs:
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 "^\+" | grep Scripts) # Get oly the changes that can be built
if [[ $? -ne 0 ]]; then
echo No valid build change found. Exiting with non-zero
fi
PACKAGE=$(echo $DIFF | cut -d'"' -f2)
JSONline="{\"package\": \"$PACKAGE\", \"os\": \"$OS_RUNNER\"},"
PACKPATH=$(echo $DIFF | egrep -o "package-system/[^ ]*")
DOCKER=$(test -f "$PACKPATH/Dockerfile" && echo 1 || echo 0)
JSONline="{\"package\": \"$PACKAGE\", \"os\": \"$OS_RUNNER\", \"dockerfile\": \"$DOCKER\"},"
if [[ "$JSON" != *"$JSONline"* ]]; then
JSON="$JSON$JSONline"
fi
Expand Down Expand Up @@ -114,20 +111,22 @@ jobs:

steps:
- name: Configure
id: get-user
run: echo "uid_gid=$(id -u):$(id -g)" >> $GITHUB_OUTPUT
id: configure
run: |
git config --global core.longpaths true
echo "uid_gid=$(id -u):$(id -g)" >> $GITHUB_OUTPUT
- name: Checkout 3P source repo
uses: actions/checkout@v4
with:
path: 3p-package-source
path: source
fetch-depth: 0

- name: Checkout 3P scripts repo
uses: actions/checkout@v4
with:
repository: o3de/3p-package-scripts
path: 3p-package-scripts
path: scripts

- name: Update python
uses: actions/setup-python@v4
Expand Down Expand Up @@ -165,32 +164,37 @@ jobs:
max-size: 2048M
key: ${{ matrix.package }}-${{ matrix.os }}
restore-keys:
${{ matrix.package }}-${{ matrix.os }}

${{ matrix.package }}-${{ matrix.os }}

- name: Set up QEMU (aarch64) # Only if the package folder contains a Dockerfile
if: ${{ (contains(matrix.package, 'aarch64')) && (matrix.dockerfile == '1') }}
run: |
sudo apt-get install -y qemu qemu-user-static
- name: Run build command
if: ${{ !contains(matrix.package, 'aarch64') }}
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 3p-package-scripts/o3de_package_scripts/build_package.py --search_path 3p-package-source ${{ matrix.package }}
python3 scripts/o3de_package_scripts/build_package.py --search_path source ${{ matrix.package }}
- name: Run build command (aarch64)
if: contains(matrix.package, 'aarch64')
- name: Run build command (aarch64) # Generic build for packages without a Dockerfile
if: ${{ (contains(matrix.package, 'aarch64')) && (matrix.dockerfile != '1') }}
uses: uraimo/run-on-arch-action@v2.5.1
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}/3p-package-source/package_build_list_host_linux.json || rm ${PWD}/3p-package-source/package_build_list_host_linux.json
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.get-user.outputs.uid_gid }}
--user ${{ steps.configure.outputs.uid_gid }}
--volume "${PWD}:/workspace"
--volume "${PWD}/3p-package-scripts:/scripts"
--volume "${PWD}/3p-package-source:/source"
--volume "${PWD}/scripts:/scripts"
--volume "${PWD}/source:/source"
env: |
CMAKE_CXX_COMPILER_LAUNCHER: sccache
CMAKE_C_COMPILER_LAUNCHER: sccache
Expand All @@ -210,7 +214,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.package }}
path: 3p-package-source/packages/*
path: source/packages/*

validate-packages:
name: Validating ${{ matrix.package }}
Expand Down

0 comments on commit a8019a5

Please sign in to comment.