|
| 1 | +# Copyright Contributors to the OpenImageIO project. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | +# https://github.com/AcademySoftwareFoundation/OpenImageIO |
| 4 | + |
| 5 | +########################################################################## |
| 6 | +# Common steps for all CI workflows |
| 7 | +########################################################################## |
| 8 | + |
| 9 | +name: CI Steps |
| 10 | + |
| 11 | +on: |
| 12 | + workflow_call: |
| 13 | + # This inputs receive values via the "with:" section in ci_workflow.yml |
| 14 | + inputs: |
| 15 | + build: |
| 16 | + type: string |
| 17 | + runner: |
| 18 | + type: string |
| 19 | + container: |
| 20 | + type: string |
| 21 | + container_volumes: |
| 22 | + type: string |
| 23 | + default: '[]' |
| 24 | + cc_compiler: |
| 25 | + type: string |
| 26 | + cxx_compiler: |
| 27 | + type: string |
| 28 | + cxx_std: |
| 29 | + type: string |
| 30 | + build_type: |
| 31 | + type: string |
| 32 | + depcmds: |
| 33 | + type: string |
| 34 | + extra_artifacts: |
| 35 | + type: string |
| 36 | + fmt_ver: |
| 37 | + type: string |
| 38 | + opencolorio_ver: |
| 39 | + type: string |
| 40 | + openexr_ver: |
| 41 | + type: string |
| 42 | + pybind11_ver: |
| 43 | + type: string |
| 44 | + python_ver: |
| 45 | + type: string |
| 46 | + setenvs: |
| 47 | + type: string |
| 48 | + simd: |
| 49 | + type: string |
| 50 | + skip_build: |
| 51 | + type: string |
| 52 | + skip_tests: |
| 53 | + type: string |
| 54 | + abi_check: |
| 55 | + type: string |
| 56 | + benchmark: |
| 57 | + type: string |
| 58 | + build_docs: |
| 59 | + type: string |
| 60 | + clang_format: |
| 61 | + type: string |
| 62 | + generator: |
| 63 | + type: string |
| 64 | + ctest_args: |
| 65 | + type: string |
| 66 | + ctest_test_timeout: |
| 67 | + type: string |
| 68 | + coverage: |
| 69 | + type: string |
| 70 | + sonar: |
| 71 | + type: string |
| 72 | + old_node: |
| 73 | + type: string |
| 74 | + default: 0 |
| 75 | + nametag: |
| 76 | + type: string |
| 77 | + required_deps: |
| 78 | + type: string |
| 79 | + optional_deps: |
| 80 | + type: string |
| 81 | + secrets: |
| 82 | + PASSED_GITHUB_TOKEN: |
| 83 | + required: false |
| 84 | + PASSED_SONAR_TOKEN: |
| 85 | + required: false |
| 86 | + |
| 87 | +permissions: read-all |
| 88 | + |
| 89 | + |
| 90 | +jobs: |
| 91 | + |
| 92 | + steps: |
| 93 | + name: "${{inputs.cxx_compiler}} c++${{inputs.cxx_std}} py${{inputs.python_ver}}" |
| 94 | + runs-on: ${{ inputs.runner }} |
| 95 | + container: |
| 96 | + image: ${{ inputs.container }} |
| 97 | + volumes: ${{ fromJson( inputs.container_volumes ) }} |
| 98 | + options: -v /:/host/root ${{ (contains(inputs.runner, 'gpu') && '-e NVIDIA_DRIVER_CAPABILITIES=compute,graphics,utility --gpus all') || '-e A=x' }} |
| 99 | + # Extra options: |
| 100 | + # - Ensure the GPU runners have OptiX is visible in the container. |
| 101 | + # - Mount the native filesystem under /host/root |
| 102 | + env: |
| 103 | + CXX: ${{inputs.cxx_compiler}} |
| 104 | + CC: ${{inputs.cc_compiler}} |
| 105 | + CMAKE_BUILD_TYPE: ${{inputs.build_type}} |
| 106 | + CMAKE_CXX_STANDARD: ${{inputs.cxx_std}} |
| 107 | + CMAKE_GENERATOR: ${{inputs.generator}} |
| 108 | + CTEST_ARGS: ${{inputs.ctest_args}} |
| 109 | + CTEST_TEST_TIMEOUT: ${{inputs.ctest_test_timeout}} |
| 110 | + USE_SIMD: ${{inputs.simd}} |
| 111 | + fmt_BUILD_VERSION: ${{inputs.fmt_ver}} |
| 112 | + OPENCOLORIO_VERSION: ${{inputs.opencolorio_ver}} |
| 113 | + OPENEXR_VERSION: ${{inputs.openexr_ver}} |
| 114 | + PYBIND11_VERSION: ${{inputs.pybind11_ver}} |
| 115 | + PYTHON_VERSION: ${{inputs.python_ver}} |
| 116 | + ABI_CHECK: ${{inputs.abi_check}} |
| 117 | + ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16 |
| 118 | + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true |
| 119 | + # For CI, sometimes we want to require all dependencies to be present, |
| 120 | + # except for a select few listed explicitly. This ensures that we don't |
| 121 | + # accidentally have a situation in which we think we are building |
| 122 | + # against and testing an optional dependency, but in fact are not. |
| 123 | + OpenImageIO_REQUIRED_DEPS: ${{inputs.required_deps}} |
| 124 | + OpenImageIO_OPTIONAL_DEPS: ${{inputs.optional_deps}} |
| 125 | + |
| 126 | + steps: |
| 127 | + - name: install nodejs20glibc2.17 |
| 128 | + if: inputs.old_node == '1' |
| 129 | + run: | |
| 130 | + curl --silent https://unofficial-builds.nodejs.org/download/release/v20.18.1/node-v20.18.1-linux-x64-glibc-217.tar.xz | tar -xJ --strip-components 1 -C /node20217 -f - |
| 131 | + - name: Checkout repo |
| 132 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 133 | + - name: Build setup |
| 134 | + shell: bash |
| 135 | + run: | |
| 136 | + ${{inputs.setenvs}} |
| 137 | + src/build-scripts/ci-startup.bash |
| 138 | + - name: Prepare ccache timestamp |
| 139 | + id: ccache_cache_keys |
| 140 | + shell: bash |
| 141 | + run: echo "date=`date -u +'%Y-%m-%dT%H:%M:%SZ'`" >> $GITHUB_OUTPUT |
| 142 | + - name: ccache-restore |
| 143 | + id: ccache-restore |
| 144 | + uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 145 | + with: |
| 146 | + path: ${{ env.CCACHE_DIR }} |
| 147 | + # path: ./ccache |
| 148 | + key: ${{inputs.nametag}}-${{steps.ccache_cache_keys.outputs.date}} |
| 149 | + restore-keys: ${{inputs.nametag}} |
| 150 | + - name: Dependencies |
| 151 | + shell: bash |
| 152 | + run: | |
| 153 | + ${{inputs.depcmds}} |
| 154 | + if [[ "$RUNNER_OS" == "Linux" ]]; then |
| 155 | + src/build-scripts/gh-installdeps.bash |
| 156 | + elif [[ "$RUNNER_OS" == "macOS" ]]; then |
| 157 | + src/build-scripts/install_homebrew_deps.bash |
| 158 | + elif [[ "$RUNNER_OS" == "Windows" ]]; then |
| 159 | + src/build-scripts/gh-win-installdeps.bash |
| 160 | + fi |
| 161 | + - name: Install sonar-scanner and build-wrapper |
| 162 | + if: inputs.sonar == '1' |
| 163 | + uses: sonarsource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 # v6.0.0 |
| 164 | + - name: Build |
| 165 | + if: inputs.skip_build != '1' |
| 166 | + shell: bash |
| 167 | + run: src/build-scripts/ci-build.bash |
| 168 | + - name: Check out ABI standard |
| 169 | + if: inputs.abi_check != '' |
| 170 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 171 | + with: |
| 172 | + ref: ${{inputs.abi_check}} |
| 173 | + path: abi_standard |
| 174 | + - name: Build ABI standard |
| 175 | + if: inputs.abi_check != '' |
| 176 | + shell: bash |
| 177 | + run: | |
| 178 | + mkdir -p abi_standard/build |
| 179 | + pushd abi_standard |
| 180 | + src/build-scripts/ci-build.bash |
| 181 | + popd |
| 182 | + - name: ccache-save |
| 183 | + id: ccache-save |
| 184 | + uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 185 | + with: |
| 186 | + path: ${{ env.CCACHE_DIR }} |
| 187 | + key: ${{inputs.nametag}}-${{steps.ccache_cache_keys.outputs.date}} |
| 188 | + - name: Testsuite |
| 189 | + if: inputs.skip_tests != '1' |
| 190 | + shell: bash |
| 191 | + run: src/build-scripts/ci-test.bash |
| 192 | + - name: Benchmarks |
| 193 | + if: inputs.benchmark == '1' |
| 194 | + shell: bash |
| 195 | + run: src/build-scripts/ci-benchmark.bash |
| 196 | + - name: clang-format |
| 197 | + if: inputs.clang_format == '1' |
| 198 | + shell: bash |
| 199 | + run: src/build-scripts/run-clang-format.bash |
| 200 | + - name: Code coverage |
| 201 | + if: inputs.coverage == '1' |
| 202 | + run: src/build-scripts/ci-coverage.bash |
| 203 | + - name: Sonar-scanner |
| 204 | + if: inputs.sonar == '1' |
| 205 | + env: |
| 206 | + GITHUB_TOKEN: ${{ secrets.PASSED_GITHUB_TOKEN }} |
| 207 | + SONAR_TOKEN: ${{ secrets.PASSED_SONAR_TOKEN }} |
| 208 | + run: | |
| 209 | + which sonar-scanner |
| 210 | + ls -l /__w/OpenImageIO/OpenImageIO/bw_output |
| 211 | + echo "BUILD_OUTPUT_DIR is " "${{ env.BUILD_WRAPPER_OUT_DIR }}" |
| 212 | + find . -name "*.gcov" -print |
| 213 | + # sonar-scanner --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" |
| 214 | + time sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.compile-commands="$BUILD_WRAPPER_OUT_DIR/compile_commands.json" --define sonar.cfamily.gcov.reportsPath="_coverage" --define sonar.cfamily.threads="$PARALLEL" |
| 215 | + # Consult https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-cli/ for more information and options |
| 216 | + - name: Check ABI |
| 217 | + if: inputs.abi_check != '' |
| 218 | + shell: bash |
| 219 | + run: | |
| 220 | + src/build-scripts/ci-abicheck.bash ./build abi_standard/build libOpenImageIO libOpenImageIO_Util |
| 221 | + - name: Build Docs |
| 222 | + if: inputs.build_docs == '1' |
| 223 | + shell: bash |
| 224 | + run: | |
| 225 | + cd src/doc |
| 226 | + time make doxygen |
| 227 | + time make sphinx |
| 228 | + - name: Upload testsuite debugging artifacts |
| 229 | + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 |
| 230 | + if: ${{ failure() || inputs.build_docs == '1' || inputs.benchmark == '1' || inputs.abi_check != '' }} |
| 231 | + with: |
| 232 | + name: oiio-${{github.job}}-${{inputs.nametag}} |
| 233 | + path: | |
| 234 | + build/cmake-save |
| 235 | + build/compat_reports |
| 236 | + build/sphinx |
| 237 | + build/benchmarks |
| 238 | + build/testsuite/*/*.* |
| 239 | + !build/testsuite/oiio-images |
| 240 | + !build/testsuite/openexr-images |
| 241 | + !build/testsuite/fits-images |
| 242 | + !build/testsuite/j2kp4files_v1_5 |
| 243 | + ${{ inputs.extra_artifacts }} |
0 commit comments