forked from adobe/USD-Fileformat-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
240 lines (215 loc) · 10 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
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 }}