CI Workflow #71
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Workflow | |
on: | |
pull_request: | |
branches: [main] | |
push: | |
branches: [main] | |
schedule: | |
# Cron runs at 16:00 UTC which corresponds to 09:00 AM PT | |
- cron: "0 16 * * 1" | |
jobs: | |
prepare-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Matrix | |
id: set-matrix | |
run: | | |
if [ "${{ github.event_name }}" == "schedule" ]; then | |
MATRIX_FILE="${{ github.workspace }}/test/full_versions.json" | |
else | |
MATRIX_FILE="${{ github.workspace }}/test/pr_versions.json" | |
fi | |
JSON=$(jq -c . < "$MATRIX_FILE") | |
MODIFIED_JSON='{"include":[]}' | |
PLUGINS=("GLTF" "PLY" "OBJ" "STL" "FBX") | |
for row in $(echo "${JSON}" | jq -c '.include[]'); do | |
for plugin in "${PLUGINS[@]}"; do | |
NEW_ROW=$(echo "$row" | jq '. + {"config":"'$plugin'"}') | |
MODIFIED_JSON=$(echo "$MODIFIED_JSON" | jq '.include += ['"$NEW_ROW"']') | |
done | |
ALL_ON_ROW=$(echo "$row" | jq '. + {"config":"ALL"}') | |
MODIFIED_JSON=$(echo "$MODIFIED_JSON" | jq '.include += ['"$ALL_ON_ROW"']') | |
done | |
echo "matrix=$(echo "$MODIFIED_JSON" | jq -c .)" >> $GITHUB_OUTPUT | |
build: | |
needs: prepare-matrix | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.prepare-matrix.outputs.matrix)}} | |
name: build (${{ matrix.os }}-${{ matrix.usd_version }}-${{ matrix.config }}) | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ilammy/msvc-dev-cmd@v1 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10.11" | |
id: setup-python | |
- name: Install Ninja (Cross-platform) | |
run: | | |
python -m pip install ninja | |
- name: Install dependencies on Linux | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y unzip | |
sudo apt-get remove --purge -y cmake | |
wget https://cmake.org/files/v3.24/cmake-3.24.4-linux-x86_64.sh | |
chmod +x cmake-3.24.4-linux-x86_64.sh | |
sudo ./cmake-3.24.4-linux-x86_64.sh --prefix=/usr/local --skip-license | |
cmake --version | |
- name: Install dependencies on Windows | |
if: runner.os == 'Windows' | |
run: choco install cmake 7zip | |
- name: Install dependencies on macOS | |
if: runner.os == 'macOS' | |
run: | | |
brew install libheif libraw openjpeg || true | |
- name: Download release asset | |
run: gh release download USD-${{ matrix.usd_version }}-Artifacts -p "usd-${{ matrix.usd_version }}-${{ matrix.os }}.zip" --repo ${{ github.repository }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Unzip artifact Windows | |
if: runner.os == 'Windows' | |
run: Expand-Archive -Path "usd-${{ matrix.usd_version }}-${{ matrix.os }}.zip" -DestinationPath usd_build -Force | |
- name: Unzip artifact Unix | |
if: runner.os != 'Windows' | |
run: unzip -q usd-${{ matrix.usd_version }}-${{ matrix.os }}.zip -d usd_build | |
- name: Set Environment Variables | |
shell: bash | |
run: | | |
if [ "${{ runner.os }}" == "Windows" ]; then | |
echo "${PYTHON_PATH}" >> "$GITHUB_PATH" | |
echo "${{ github.workspace }}/usd_build/bin" >> "$GITHUB_PATH" | |
echo "${{ github.workspace }}/usd_build/lib" >> "$GITHUB_PATH" | |
echo "${{ github.workspace }}/usd_build/lib64" >> "$GITHUB_PATH" | |
echo "${{ github.workspace }}/usd_build/plugin/usd" >> "$GITHUB_PATH" | |
echo "${{ github.workspace }}/bin/bin" >> "$GITHUB_PATH" | |
echo "${{ github.workspace }}/bin/plugin/usd" >> "$GITHUB_PATH" | |
echo "PXR_PLUGINPATH_NAME=${{ github.workspace }}/bin/plugin/usd;${{ github.workspace }}/usd_build/plugin/usd" >> "$GITHUB_ENV" | |
else | |
# Concatenate paths for LD_LIBRARY_PATH | |
ldLibraryPath="${{ github.workspace }}/usd_build/bin:" | |
ldLibraryPath+="${{ github.workspace }}/usd_build/lib:" | |
ldLibraryPath+="${{ github.workspace }}/usd_build/lib64:" | |
ldLibraryPath+="${{ github.workspace }}/usd_build/plugin/usd:" | |
ldLibraryPath+="${{ github.workspace }}/bin/bin:" | |
ldLibraryPath+="${{ github.workspace }}/bin/lib:" | |
ldLibraryPath+="${{ github.workspace }}/bin/plugin/usd" | |
echo "LD_LIBRARY_PATH=$ldLibraryPath" >> "$GITHUB_ENV" | |
echo "PXR_PLUGINPATH_NAME=${{ github.workspace }}/bin/plugin/usd:${{ github.workspace }}/usd_build/plugin/usd" >> "$GITHUB_ENV" | |
fi | |
USD_BUILD_PATH="${{ github.workspace }}/usd_build" | |
USD_BUILD_PATH="${USD_BUILD_PATH//\\//}" | |
echo "USD_BUILD_PATH=$USD_BUILD_PATH" >> "$GITHUB_ENV" | |
echo "PYTHONPATH=${{ github.workspace }}/usd_build/lib/python" >> "$GITHUB_ENV" | |
- name: Get latest successful run ID of the fbx sdk workflow | |
shell: bash | |
if: matrix.config == 'FBX' || matrix.config == 'ALL' | |
id: get-run-id | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
RUN_ID=$(gh run list --repo ${{ github.repository }} --workflow fbx-sdk.yml --limit 1 --json databaseId,status --jq '.[] | select(.status=="completed") | .databaseId') | |
echo "RUN_ID=$RUN_ID" >> $GITHUB_ENV | |
echo "Run ID: $RUN_ID" | |
- name: Download FBX SDK Artifact | |
if: matrix.config == 'FBX' || matrix.config == 'ALL' | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ runner.os }}-FBX-SDK | |
path: ${{ github.workspace }}/FBXSDK | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
run-id: ${{ env.RUN_ID }} | |
- name: Set up FBX | |
if: matrix.config == 'FBX' || matrix.config == 'ALL' | |
shell: bash | |
run: | | |
FBX_FOLDER=$(echo "${{ github.workspace }}/FBXSDK" | sed 's|\\|/|g') | |
echo "FBX_FOLDER=$FBX_FOLDER" >> $GITHUB_ENV | |
if [ "${{ runner.os }}" == "Windows" ]; then | |
echo "FBX_OUTFILE=$FBX_FOLDER/fbx202037_fbxsdk_vs2022_win.exe" >> $GITHUB_ENV | |
elif [ "${{ runner.os }}" == "macOS" ]; then | |
echo "FBX_OUTFILE=$FBX_FOLDER/fbx202037_fbxsdk_clang_mac.pkg" >> $GITHUB_ENV | |
else | |
echo "FBX_OUTFILE=$FBX_FOLDER/fbx202037_fbxsdk_gcc_linux" >> $GITHUB_ENV | |
fi | |
- name: Install FBX SDK Windows | |
if: runner.os == 'Windows' && (matrix.config == 'FBX' || matrix.config == 'ALL') | |
shell: bash | |
run: | | |
mkdir -p ${{ env.FBX_FOLDER }} | |
FBX_INSTALL_DIR=$(echo "${{ github.workspace }}/FBX_SDK_INSTALL" | sed 's|\\|/|g') | |
mkdir -p $FBX_INSTALL_DIR | |
7z x "$FBX_OUTFILE" -o"$FBX_INSTALL_DIR" -y | |
echo "FBX_INSTALL_DIR=$FBX_INSTALL_DIR" >> $GITHUB_ENV | |
- name: Install FBX SDK Unix | |
if: runner.os != 'Windows' && (matrix.config == 'FBX' || matrix.config == 'ALL') | |
run: | | |
mkdir -p ${{ env.FBX_FOLDER }} | |
if [ "${{ runner.os }}" == "macOS" ]; then | |
FBX_INSTALL_DIR="/Applications/Autodesk/FBXSDK/2020.3.7" | |
tar -xzf ${{ env.FBX_OUTFILE }}.tgz -C ${{ env.FBX_FOLDER }} | |
FBX_OUTFILE_CORRECTED=$(echo "${{ env.FBX_OUTFILE }}" | sed 's/_mac.pkg/_macos.pkg/') | |
sudo installer -pkg $FBX_OUTFILE_CORRECTED -target / -verboseR | |
sudo mv "/Applications/Autodesk/FBX SDK/" "/Applications/Autodesk/FBXSDK" | |
else # Linux | |
FBX_INSTALL_DIR=${{ github.workspace }}/FBX_SDK_INSTALL | |
chmod +r ${{ env.FBX_OUTFILE }}.tar.gz | |
tar -xzf ${{ env.FBX_OUTFILE }}.tar.gz -C ${{ env.FBX_FOLDER }} | |
mkdir -p ${{ github.workspace }}/FBX_SDK_INSTALL | |
yes yes | ${{ env.FBX_FOLDER }}/fbx202037_fbxsdk_linux $FBX_INSTALL_DIR | |
fi | |
echo "FBX_INSTALL_DIR=$FBX_INSTALL_DIR" >> $GITHUB_ENV | |
- name: Configure CMake (Cross-Platform) | |
shell: bash | |
run: | | |
baseArgs="-S . -B build -G Ninja" | |
commonArgs=( | |
"-DCMAKE_INSTALL_PREFIX=bin" | |
"-DCMAKE_BUILD_TYPE=Release" | |
"-Dpxr_ROOT=${{ github.workspace }}/usd_build" | |
"-DUSD_FILEFORMATS_ENABLE_GLTF=$([[ "${{ matrix.config }}" == "ALL" || "${{ matrix.config }}" == "GLTF" ]] && echo "ON" || echo "OFF")" | |
"-DUSD_FILEFORMATS_ENABLE_PLY=$([[ "${{ matrix.config }}" == "ALL" || "${{ matrix.config }}" == "PLY" ]] && echo "ON" || echo "OFF")" | |
"-DUSD_FILEFORMATS_ENABLE_OBJ=$([[ "${{ matrix.config }}" == "ALL" || "${{ matrix.config }}" == "OBJ" ]] && echo "ON" || echo "OFF")" | |
"-DUSD_FILEFORMATS_ENABLE_STL=$([[ "${{ matrix.config }}" == "ALL" || "${{ matrix.config }}" == "STL" ]] && echo "ON" || echo "OFF")" | |
"-DUSD_FILEFORMATS_ENABLE_FBX=$([[ "${{ matrix.config }}" == "ALL" || "${{ matrix.config }}" == "FBX" ]] && echo "ON" || echo "OFF")" | |
"-DFBXSDK_ROOT=${{ env.FBX_INSTALL_DIR }}" | |
"-DUSD_FILEFORMATS_BUILD_TESTS=ON" | |
"-DOpenImageIO_INCLUDE_DIR=${{ github.workspace }}/usd_build/include" | |
"-DOpenImageIO_INCLUDES=${{ github.workspace }}/usd_build/include" | |
"-DPython3_LIBRARY=" | |
"-DPython3_INCLUDE_DIR=" | |
"-DPython3_VERSION=3.10.11" | |
) | |
# Platform specific arguments based on RUNNER_OS | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
libFolder="lib64" | |
else | |
libFolder="lib" | |
fi | |
platformArgs=( | |
"-DOpenImageIO_DIR=${{ github.workspace }}/usd_build/${libFolder}/cmake/OpenImageIO" | |
"-DOpenImageIO_LIB_DIR=${{ github.workspace }}/usd_build/${libFolder}/cmake/OpenImageIO" | |
) | |
fullCmakeArgs="$baseArgs ${commonArgs[@]} ${platformArgs[@]}" | |
cmake $fullCmakeArgs | |
- name: Build and Display Linker Command | |
run: cmake --build build --config Release | |
- name: Install | |
run: cmake --install build --config Release | |
- name: Remap Dependency in dylib Files | |
if: runner.os == 'macOS' | |
shell: bash | |
run: | | |
for dylib in ${{ github.workspace }}/bin/plugin/usd/*.dylib; do | |
if otool -L "$dylib" | grep -q "@rpath/libfileformatUtils.dylib"; then | |
echo "Remapping @rpath for $dylib" | |
install_name_tool -change @rpath/libfileformatUtils.dylib ${{ github.workspace }}/bin/lib/libfileformatUtils.dylib "$dylib" | |
fi | |
done | |
- name: Install test requirements | |
run: pip install -r scripts/requirements.txt | |
- name: Run tests and inspect dependencies | |
shell: bash | |
run: | | |
cd build | |
ctest -VV -C Release | |
result=$? | |
echo "Test exit status: $result" | |
suffix="${{ matrix.os }}-${{ matrix.usd_version }}-${{ matrix.config }}" | |
if [[ "$result" -eq 0 ]]; then | |
echo "BUILD_STATUS_STRING=Passed" >> $GITHUB_ENV | |
echo "BUILD_STATUS_COLOR=#00cc11" >> $GITHUB_ENV | |
else | |
echo "BUILD_STATUS_STRING=Failed" >> $GITHUB_ENV | |
echo "BUILD_STATUS_COLOR=red" >> $GITHUB_ENV | |
fi | |
- name: Handle Failure | |
if: failure() | |
run: | | |
echo "BUILD_STATUS_STRING=Failed" >> $GITHUB_ENV | |
echo "BUILD_STATUS_COLOR=red" >> $GITHUB_ENV | |
- name: Update Badge | |
if: always() | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 264643f3d2acacc5369a0ba70854dfb6 | |
filename: ${{ matrix.os }}-${{ matrix.usd_version }}-${{ matrix.config }}.json | |
label: ${{ matrix.os }}-${{ matrix.usd_version }}-${{ matrix.config }} | |
message: ${{ env.BUILD_STATUS_STRING }} | |
color: "${{ env.BUILD_STATUS_COLOR }}" | |
forceUpdate: true |