ci #26
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 | |
echo "matrix=$(jq -c . < ${{ github.workspace }}/test/full_versions.json)" >> $GITHUB_OUTPUT | |
else | |
echo "matrix=$(jq -c . < ${{ github.workspace }}/test/pr_versions.json)" >> $GITHUB_OUTPUT | |
fi | |
build: | |
needs: prepare-matrix | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.prepare-matrix.outputs.matrix)}} | |
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 | |
- name: Install dependencies on macOS | |
if: runner.os == 'macOS' | |
run: | | |
ls /Applications | grep Xcode | |
sudo xcode-select -s /Applications/Xcode_14.1.app | |
brew install cmake 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 | |
if: runner.os == 'Windows' | |
run: Expand-Archive -Path "usd-${{ matrix.usd_version }}-${{ matrix.os }}.zip" -DestinationPath usd_build -Force | |
- name: Unzip artifact | |
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 | |
echo "PYTHONPATH=${{ github.workspace }}/usd_build/lib/python" >> "$GITHUB_ENV" | |
- name: Adjust paths in USD build runner paths | |
shell: bash | |
run: | | |
if [ "${{ runner.os }}" == "macOS" ]; then | |
sed -i '' 's|/Users/runner/work/usdbuilds/usdbuilds/|${{ github.workspace }}/|g' ${{ github.workspace }}/usd_build/cmake/pxrTargets.cmake | |
sed -i '' 's|/Users/runner/work/usdbuilds/usdbuilds/|${{ github.workspace }}/|g' ${{ github.workspace }}/usd_build/lib/cmake/OpenImageIO/OpenImageIOConfig.cmake | |
sed -i '' 's|/Users/runner/work/usdbuilds/usdbuilds/|${{ github.workspace }}/|g' ${{ github.workspace }}/usd_build/lib/cmake/OpenImageIO/OpenImageIOTargets.cmake | |
elif [ "${{ runner.os }}" == "Linux" ]; then | |
sed -i 's|/home/runner/work/usdbuilds/usdbuilds/|${{ github.workspace }}/|g' ${{ github.workspace }}/usd_build/cmake/pxrTargets.cmake | |
sed -i 's|/home/runner/work/usdbuilds/usdbuilds/|${{ github.workspace }}/|g' ${{ github.workspace }}/usd_build/lib/cmake/OpenImageIO/OpenImageIOConfig.cmake | |
sed -i 's|/home/runner/work/usdbuilds/usdbuilds/|${{ github.workspace }}/|g' ${{ github.workspace }}/usd_build/lib/cmake/OpenImageIO/OpenImageIOTargets.cmake | |
elif [ "${{ runner.os }}" == "Windows" ]; then | |
fixedPath="${{ github.workspace }}/" | |
fixedPath="${fixedPath//\\//}" | |
sed -i "s|D:/a/usdbuilds/usdbuilds/|$fixedPath|g" "${fixedPath}usd_build/cmake/pxrTargets.cmake" | |
sed -i "s|D:/a/usdbuilds/usdbuilds/|$fixedPath|g" "${fixedPath}usd_build/lib/cmake/OpenImageIO/OpenImageIOConfig.cmake" | |
sed -i "s|D:/a/usdbuilds/usdbuilds/|$fixedPath|g" "${fixedPath}usd_build/lib/cmake/OpenImageIO/OpenImageIOTargets.cmake" | |
fi | |
- name: Configure CMake (Cross-Platform) | |
shell: bash | |
run: | | |
baseArgs="-S . -B build -G Ninja" | |
# Common arguments for all platforms | |
commonArgs=( | |
"-DCMAKE_INSTALL_PREFIX=bin" | |
"-DCMAKE_BUILD_TYPE=Release" | |
"-Dpxr_ROOT=${{ github.workspace }}/usd_build" | |
"-DUSD_FILEFORMATS_ENABLE_FBX=OFF" | |
"-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 | |
platformArgs=() | |
case "$RUNNER_OS" in | |
"Windows") | |
platformArgs=( | |
"-DOpenImageIO_DIR=${{ github.workspace }}/usd_build/lib/cmake/OpenImageIO" | |
"-DOpenImageIO_LIB_DIR=${{ github.workspace }}/usd_build/lib" | |
) | |
;; | |
"Linux") | |
platformArgs=( | |
"-DOpenImageIO_DIR=${{ github.workspace }}/usd_build/lib64/cmake/OpenImageIO" | |
"-DOpenImageIO_LIB_DIR=${{ github.workspace }}/usd_build/lib64" | |
) | |
;; | |
"macOS") | |
platformArgs=( | |
"-DOpenImageIO_DIR=${{ github.workspace }}/usd_build/lib/cmake/OpenImageIO" | |
"-DOpenImageIO_LIB_DIR=${{ github.workspace }}/usd_build/lib" | |
) | |
;; | |
esac | |
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 }}" | |
if [[ "$result" -eq 0 ]]; then | |
echo "${suffix},Passed,green" >> ${{ matrix.os }}-${{ matrix.usd_version }}-results.csv | |
else | |
echo "${suffix},Failed,red" >> ${{ matrix.os }}-${{ matrix.usd_version }}-results.csv | |
fi | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: test-${{ matrix.os }}-${{ matrix.usd_version }}-results | |
path: build/${{ matrix.os }}-${{ matrix.usd_version }}-results.csv | |
update_badge: | |
needs: [build, prepare-matrix] | |
runs-on: ubuntu-latest | |
if: always() | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.prepare-matrix.outputs.matrix)}} | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: test-${{ matrix.os }}-${{ matrix.usd_version }}-results | |
- name: Setup Badge Data | |
id: setup_badge | |
run: | | |
suffix="${{ matrix.os }}-${{ matrix.usd_version }}" | |
IFS=',' read -r _ status color < <(grep "^${suffix}," ${{ matrix.os }}-${{ matrix.usd_version }}-results.csv) | |
echo "STATUS=$status" >> $GITHUB_OUTPUT | |
echo "COLOR=$color" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Badge | |
uses: RubbaBoy/BYOB@v1.3.0 | |
with: | |
NAME: usd-build-${{ matrix.os }}-${{ matrix.usd_version }} | |
LABEL: ${{ matrix.os }} USD ${{ matrix.usd_version }} | |
STATUS: ${{ steps.setup_badge.outputs.status }} | |
COLOR: ${{ steps.setup_badge.outputs.color }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |