forked from AcademySoftwareFoundation/openexr
-
Notifications
You must be signed in to change notification settings - Fork 1
394 lines (357 loc) · 16.4 KB
/
ci_steps.yml
File metadata and controls
394 lines (357 loc) · 16.4 KB
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) Contributors to the OpenEXR Project.
# These are the steps for all CI jobs. Linux, macOS, and Windows all
# share a common set of configure/build/validate steps. The input
# variables control all variations of the jobs.
#
# Each job validates that the proper files are installed by comparing
# the install_manifest.txt to a reference for that job. This requires
# that each job have a corresponding reference, and that thes
# references are updated when any change is made to the installation
# headers/libraries/cmake/etc.
name: CI Steps
on:
workflow_call:
# This inputs receive values via the "with:" section in ci_workflow.yml
inputs:
build:
type: string
os:
type: string
container:
type: string
cmake:
type: string
cxx-standard:
type: string
cxx-compiler:
type: string
cc-compiler:
type: string
build-type:
type: string
msystem:
type: string
BUILD_SHARED_LIBS:
type: string
OPENEXR_ENABLE_THREADING:
type: string
OPENEXR_INSTALL_PKG_CONFIG:
type: string
OPENEXR_INSTALL_DOCS:
type: string
OPENEXR_BUILD_EXAMPLES:
type: string
OPENEXR_BUILD_TOOLS:
type: string
OPENEXR_FORCE_INTERNAL_IMATH:
type: string
OPENEXR_FORCE_INTERNAL_DEFLATE:
type: string
OPENEXR_FORCE_INTERNAL_OPENJPH:
type: string
CMAKE_OSX_ARCHITECTURES:
type: string
BUILD_TESTING:
type: string
RUN_TESTING:
type: string
namespace:
type: string
validate_install:
type: string
jobs:
steps:
runs-on: ${{ inputs.os }}
container:
image: ${{ inputs.container }}
env:
CXX: ${{ inputs.cxx-compiler }}
CC: ${{ inputs.cc-compiler }}
ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Set Up Directories & Environment
run: |
set -x
# Be careful to use consistent paths between Windows and
# Linux. Convert backslashed Windows paths to Linux style via cygpath,
# i.e. convert D:\a\Imath\Imath to /d/a/Imath/Imath.
# WORKSPACE is the root of the project directory
if [[ "$RUNNER_OS" == "Windows" ]]; then
WORKSPACE=$(cygpath -u "$GITHUB_WORKSPACE")
# remember the install location for Imath, libdeflate, openjph
PROGRAM_FILES=$(cygpath -u "C:/Program Files (x86)")
echo "PROGRAM_FILES=$PROGRAM_FILES" >> $GITHUB_ENV
else
WORKSPACE=$GITHUB_WORKSPACE
fi
echo "WORKSPACE=$WORKSPACE" >> $GITHUB_ENV
# BUILD_DIR is the CMake build directory
BUILD_DIR=$WORKSPACE/_build
echo "BUILD_DIR=$BUILD_DIR" >> $GITHUB_ENV
# INSTALL_DIR is the CMake install directory
INSTALL_DIR=$WORKSPACE/_install
echo "INSTALL_DIR=$INSTALL_DIR" >> $GITHUB_ENV
# Initialize the PATH necessary for the tests on Windows
echo "OPENEXR_PATH=$INSTALL_DIR/bin:$INSTALL_DIR/lib" >> $GITHUB_ENV
# Install gcc for macOS if necessary
if [[ "${{ inputs.cc-compiler }}" == "gcc" && "$RUNNER_OS" == "macOS" ]]; then
brew install gcc
fi
shell: bash
- name: Determine MSYS2 Packages
if: inputs.msystem != ''
run: |
PACKAGES="cc:p cmake:p"
if [ "${{ inputs.OPENEXR_FORCE_INTERNAL_IMATH }}" == "OFF" ]; then
PACKAGES="$PACKAGES imath:p"
fi
if [ "${{ inputs.OPENEXR_FORCE_INTERNAL_DEFLATE }}" == "OFF" ]; then
PACKAGES="$PACKAGES libdeflate:p"
fi
if [ "${{ inputs.OPENEXR_FORCE_INTERNAL_OPENJPH }}" == "OFF" && "${{ inputs.msystem }}" != "MINGW32" ]; then
PACKAGES="$PACKAGES openjph:p"
fi
echo "PACBOY_PACKAGES=$PACKAGES" >> $GITHUB_ENV
shell: bash
- name: Install MSYS2 ${{ inputs.msystem }}
if: inputs.msystem != ''
uses: msys2/setup-msys2@61f9e5e925871ba6c9e3e8da24ede83ea27fa91f # v2.27.0
with:
msystem: ${{ inputs.msystem }}
update: true
install: git
pacboy: ${{ env.PACBOY_PACKAGES }}
- name: Set Up CMake
# CMakeLists.txt specifies a minimum cmake version of 3.14 for
# the OpenEXR project, so use that for the CI by default. But
# install a specific version to test with if a different one
# is specified.
run: |
set -ex
CMAKE=cmake
CTEST=ctest
if [[ "${{ inputs.cmake }}" != "" && "$RUNNER_OS" == "Linux" ]]; then
CMAKE_VERSION=${{ inputs.cmake }}
CURRENT_CMAKE_VERSION=$(cmake --version | head -n 1 | cut -f3 -d' ')
if [ "$CMAKE_VERSION" != "$CURRENT_CMAKE_VERSION" ]; then
wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-Linux-x86_64.tar.gz
tar -xzf cmake-$CMAKE_VERSION-Linux-x86_64.tar.gz
CMAKE=$(find "$PWD" -type f -path "*/bin/cmake" | head -n 1)
CTEST=$(find "$PWD" -type f -path "*/bin/ctest" | head -n 1)
fi
fi
echo CMAKE="$CMAKE" >> $GITHUB_ENV
echo CTEST="$CTEST" >> $GITHUB_ENV
shell: bash
- name: Install Imath
# Pre-install Imath so the builds validate that find_package sees the external installation
if: inputs.OPENEXR_FORCE_INTERNAL_IMATH == 'OFF' && inputs.msystem == ''
run: |
share/ci/scripts/install_imath.sh main
echo "OPENEXR_PATH=$OPENEXR_PATH:$PROGRAM_FILES/Imath/bin:$PROGRAM_FILES/Imath/lib" >> $GITHUB_ENV
shell: bash
- name: Install libdeflate
# Pre-install libdeflate so the builds validate that find_package sees the external installation
if: inputs.OPENEXR_FORCE_INTERNAL_DEFLATE == 'OFF' && inputs.msystem == ''
run: |
share/ci/scripts/install_libdeflate.sh master
echo "OPENEXR_PATH=$OPENEXR_PATH:$PROGRAM_FILES/libdeflate/bin:$PROGRAM_FILES/libdeflate/lib" >> $GITHUB_ENV
shell: bash
- name: Install OpenJPH
# Pre-install OpenJPH so the builds validate finding the external installation
if: inputs.OPENEXR_FORCE_INTERNAL_OPENJPH == 'OFF' && inputs.msystem == ''
run: |
share/ci/scripts/install_openjph.sh 0.21.5
echo "OPENEXR_PATH=$OPENEXR_PATH:$PROGRAM_FILES/openjph/bin:$PROGRAM_FILES/openjph/lib" >> $GITHUB_ENV
shell: bash
- name: Install help2man
# TODO: this could go in the ASWF Linux docker
# container. Also, it doesn't currently work for Windows, so
# the windows builds have docs disabled.
if: inputs.OPENEXR_INSTALL_DOCS == 'ON'
run: share/ci/scripts/install_help2man.sh
shell: bash
- name: Construct CMake command
run: |
# Construct the cmake command as a variable, so the
# Configure step below can execute it, but also so we can store
# in in the install_manifest as a debugging reference
cmake_args=("-B" "$BUILD_DIR" -S "$WORKSPACE")
cmake_args+=("-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR")
cmake_args+=("-DCMAKE_BUILD_TYPE=${{ inputs.build-type }}")
cmake_args+=("-DOPENEXR_CXX_STANDARD=${{ inputs.cxx-standard }}")
cmake_args+=("-DBUILD_SHARED_LIBS=${{ inputs.BUILD_SHARED_LIBS }}")
cmake_args+=("-DOPENEXR_ENABLE_THREADING=${{ inputs.OPENEXR_ENABLE_THREADING }}")
cmake_args+=("-DOPENEXR_INSTALL_PKG_CONFIG=${{ inputs.OPENEXR_INSTALL_PKG_CONFIG }}")
cmake_args+=("-DOPENEXR_INSTALL_DOCS=${{ inputs.OPENEXR_INSTALL_DOCS }}")
cmake_args+=("-DOPENEXR_BUILD_EXAMPLES=${{ inputs.OPENEXR_BUILD_EXAMPLES }}")
cmake_args+=("-DOPENEXR_BUILD_TOOLS=${{ inputs.OPENEXR_BUILD_TOOLS }}")
cmake_args+=("-DOPENEXR_FORCE_INTERNAL_IMATH=${{ inputs.OPENEXR_FORCE_INTERNAL_IMATH }}")
cmake_args+=("-DOPENEXR_FORCE_INTERNAL_DEFLATE=${{ inputs.OPENEXR_FORCE_INTERNAL_DEFLATE }}")
cmake_args+=("-DOPENEXR_FORCE_INTERNAL_OPENJPH=${{ inputs.OPENEXR_FORCE_INTERNAL_OPENJPH }}")
cmake_args+=("-DBUILD_TESTING=${{ inputs.BUILD_TESTING }}")
cmake_args+=("-DOPENEXR_RUN_FUZZ_TESTS=OFF")
cmake_args+=("-DCMAKE_VERBOSE_MAKEFILE=ON")
if [ -n "${{ inputs.namespace }}" ]; then
cmake_args+=("-DOPENEXR_IMF_NAMESPACE=${{ inputs.namespace }}")
cmake_args+=("-DILMTHREAD_NAMESPACE=${{ inputs.namespace }}")
cmake_args+=("-DIEX_NAMESPACE=${{ inputs.namespace }}")
fi
if [ "${{ inputs.msystem }}" == "MINGW32" ]; then
cmake_args+=("-DCMAKE_C_FLAGS=-msse2 -mfpmath=sse")
cmake_args+=("-DCMAKE_CXX_FLAGS=-msse2 -mfpmath=sse")
fi
if [ -n "${{ inputs.CMAKE_OSX_ARCHITECTURES }}" ]; then
cmake_args+=("CMAKE_OSX_ARCHITECTURES='${{ inputs.CMAKE_OSX_ARCHITECTURES }}'")
fi
quoted_args=$(printf '%q ' "${cmake_args[@]}")
echo "CMAKE_ARGS=$quoted_args" >> "$GITHUB_ENV"
# Set the install manifest name to include the os and build number.
# e.g. install_manifest.macos.1.txt. Note that $RUNNER_OS is "Linux",
# while input.os is "ubuntu".
os_name=$(echo "${RUNNER_OS}" | tr '[:upper:]' '[:lower:]') # linux, macos, windows
build="${{ inputs.build }}"
echo INSTALL_MANIFEST_FILENAME="install_manifest.${os_name}.${build}.txt" >> $GITHUB_ENV
shell: bash
- name: Configure & Build
if: inputs.msystem == ''
run: |
set -x
"$CMAKE" --version
"$CMAKE" ${{ env.CMAKE_ARGS }}
"$CMAKE" --build $BUILD_DIR --target install --config ${{ inputs.build-type }}
shell: bash
- name: Configure & Build (msys2) # requires msys2 shell
if: inputs.msystem != ''
run: |
set -x
"$CMAKE" --version
"$CMAKE" ${{ env.CMAKE_ARGS }}
"$CMAKE" --build $BUILD_DIR --target install --config ${{ inputs.build-type }}
shell: msys2 {0}
- name: Test
if: inputs.BUILD_TESTING == 'ON' && inputs.RUN_TESTING == 'ON' && inputs.msystem == ''
run: |
set -x
if [[ "$RUNNER_OS" == "Windows" ]]; then
export PATH="$OPENEXR_PATH:$PATH"
fi
"$CTEST" -T Test -C ${{ inputs.build-type }} --test-dir $BUILD_DIR --timeout 7200 --output-on-failure -VV
shell: bash
- name: Test (msys2) # requires msys2 shell
if: inputs.BUILD_TESTING == 'ON' && inputs.RUN_TESTING == 'ON' && inputs.msystem != ''
run: |
set -x
export PATH="$OPENEXR_PATH:$PATH"
"$CTEST" -T Test -C ${{ inputs.build-type }} --test-dir $BUILD_DIR --timeout 7200 --output-on-failure -VV
shell: msys2 {0}
- name: Prepare install_manifest
# Store the cmake command as the first line of the manifest,
# and remove the path prefix, so the manifest contains only
# the local filenames.
run: |
set -x
INSTALL_MANIFEST_PATH="$BUILD_DIR/$INSTALL_MANIFEST_FILENAME"
echo "# SPDX-License-Identifier: BSD-3-Clause" > $INSTALL_MANIFEST_PATH
echo "# Copyright (c) Contributors to the OpenEXR Project." >> $INSTALL_MANIFEST_PATH
echo "# cmake ${{ env.CMAKE_ARGS }}" >> $INSTALL_MANIFEST_PATH
sort $BUILD_DIR/install_manifest.txt | sed -e "s:^.*/_install/::" >> $INSTALL_MANIFEST_PATH
if [[ "$RUNNER_OS" == "Windows" ]]; then
# upload-artifact expects a windows-style path
INSTALL_MANIFEST_PATH=$(cygpath -w $INSTALL_MANIFEST_PATH)
fi
echo INSTALL_MANIFEST_PATH=$INSTALL_MANIFEST_PATH >> $GITHUB_ENV
shell: bash
- name: Upload install_manifest.txt
# Upload the manifest to make it possible to download for inspection and debugging
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ env.INSTALL_MANIFEST_FILENAME }}
path: ${{ env.INSTALL_MANIFEST_PATH }}
- name: Validate install
if: inputs.validate_install == 'ON'
# Validate that the build has installed the proper files by comparing against the appropriate reference manifest
run: |
set -x
share/ci/scripts/validate_install.py "$INSTALL_MANIFEST_PATH" "share/ci/install_manifest/$INSTALL_MANIFEST_FILENAME"
shell: bash
- name: Test website examples
# Build the "hello, world" exrwriter example program from the
# website, both to confirm it builds and as an example of an
# application building against the just-installed openexr
# libary, to validate the cmake configuration for downstream
# applications.
if: inputs.namespace == '' && inputs.msystem == '' && inputs.OPENEXR_BUILD_EXAMPLES != ''
run: |
set -x
EXRWRITER_BUILD_DIR=$WORKSPACE/_build.exrwriter
"$CMAKE" -S website/src/exrwriter -B $EXRWRITER_BUILD_DIR \
-DCMAKE_PREFIX_PATH=$INSTALL_DIR \
-DCMAKE_VERBOSE_MAKEFILE=ON
"$CMAKE" --build $EXRWRITER_BUILD_DIR --config ${{ inputs.build-type }}
if [[ "$RUNNER_OS" == "Windows" ]]; then
export PATH="$OPENEXR_PATH:$PATH"
EXRWRITER=$EXRWRITER_BUILD_DIR/${{ inputs.build-type }}/exrwriter.exe
EXRINFO=$INSTALL_DIR/bin/exrinfo.exe
else
EXRWRITER=$EXRWRITER_BUILD_DIR/exrwriter
EXRINFO=$INSTALL_DIR/bin/exrinfo
fi
"$EXRWRITER"
# Validate that the image is as expected
if [ -x "$EXRINFO" ]; then
expected_output=$(<website/src/exrwriter/stripes.exrinfo.txt)
actual_output=$("$EXRINFO" stripes.exr)
if [[ "$actual_output" != "$expected_output" ]]; then
echo "error: exrwriter produced incorrect results:"
echo $actual_output
exit 1
fi
else
echo "skipping exrinfo, no tool found."
fi
shell: bash
- name: Test add_subdirectory
# Build the "hello, world" exrwriter example program from the
# src/test/add_subdirectory folder, which is the same program as
# above but configured via add_subdirectory(ext/openexr).
# Create ext/openexr as a symlink to the repo root. This
# confirms that downstream applications can use openexr in
# that way.
if: inputs.msystem == ''
run: |
set -x
"$CMAKE" --version
SRC="$RUNNER_TEMP/add_subdirectory"
cp -r "$WORKSPACE/src/test/add_subdirectory" "$SRC"
cp "$WORKSPACE/website/src/exrwriter/exrwriter.cpp" "$SRC"
mkdir -p "$SRC/ext"
ln -s "$WORKSPACE" "$SRC/ext/openexr"
ADD_SUBDIRECTORY_BUILD_DIR=$WORKSPACE/_build.add_subdirectory
cmake_args=("-B" "$ADD_SUBDIRECTORY_BUILD_DIR" -S "$SRC")
cmake_args+=("-DCMAKE_POLICY_VERSION_MINIMUM=3.26")
cmake_args+=("-DCMAKE_VERBOSE_MAKEFILE=ON")
if [ -n "${{ inputs.namespace }}" ]; then
cmake_args+=("-DOPENEXR_IMF_NAMESPACE=${{ inputs.namespace }}")
fi
cmake_args+=("-DOPENEXR_FORCE_INTERNAL_IMATH=${{ inputs.OPENEXR_FORCE_INTERNAL_IMATH }}")
cmake_args+=("-DOPENEXR_FORCE_INTERNAL_DEFLATE=${{ inputs.OPENEXR_FORCE_INTERNAL_DEFLATE }}")
cmake_args+=("-DOPENEXR_FORCE_INTERNAL_OPENJPH=${{ inputs.OPENEXR_FORCE_INTERNAL_OPENJPH }}")
cmake_args+=("-DOPENEXR_BUILD_EXAMPLES=OFF")
cmake_args+=("-DOPENEXR_BUILD_TOOLS=OFF")
quoted_args=$(printf '%q ' "${cmake_args[@]}")
"$CMAKE" $quoted_args
"$CMAKE" --build $ADD_SUBDIRECTORY_BUILD_DIR --config ${{ inputs.build-type }}
EXRWRITER=$ADD_SUBDIRECTORY_BUILD_DIR/exrwriter
if [[ "$RUNNER_OS" == "Windows" ]]; then
export PATH="$OPENEXR_PATH:$PATH"
EXRWRITER=$ADD_SUBDIRECTORY_BUILD_DIR/${{ inputs.build-type }}/exrwriter.exe
else
EXRWRITER=$ADD_SUBDIRECTORY_BUILD_DIR/exrwriter
fi
$EXRWRITER
shell: bash