Skip to content

Commit 5446c1d

Browse files
authored
ci: break out reusable build steps (#1919)
Modeled after what we recently did for OIIO. Now the new build-steps.yml contains all the logic for the sequence of how to build and test for any configuration, and the main ci.yml has the specifications of all the different testing configurations. The different platforms share the same build steps, so there's a lot less needless repetition (and opportunity for divergence and mistakes). Also add MacOS 15 to the CI suite. --------- Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 8d523a8 commit 5446c1d

File tree

5 files changed

+329
-264
lines changed

5 files changed

+329
-264
lines changed

.github/workflows/build-steps.yml

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
# Copyright Contributors to the Open Shading Language project.
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
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+
cc_compiler:
22+
type: string
23+
cxx_compiler:
24+
type: string
25+
cxx_std:
26+
type: string
27+
batched:
28+
type: string
29+
build_type:
30+
type: string
31+
depcmds:
32+
type: string
33+
extra_artifacts:
34+
type: string
35+
fmt_ver:
36+
type: string
37+
opencolorio_ver:
38+
type: string
39+
openexr_ver:
40+
type: string
41+
openimageio_ver:
42+
type: string
43+
pybind11_ver:
44+
type: string
45+
python_ver:
46+
type: string
47+
setenvs:
48+
type: string
49+
simd:
50+
type: string
51+
skip_build:
52+
type: string
53+
skip_tests:
54+
type: string
55+
abi_check:
56+
type: string
57+
build_docs:
58+
type: string
59+
generator:
60+
type: string
61+
ctest_args:
62+
type: string
63+
ctest_test_timeout:
64+
type: string
65+
coverage:
66+
type: string
67+
sonar:
68+
type: string
69+
nametag:
70+
type: string
71+
secrets:
72+
PASSED_GITHUB_TOKEN:
73+
required: false
74+
PASSED_SONAR_TOKEN:
75+
required: false
76+
77+
permissions: read-all
78+
79+
80+
jobs:
81+
82+
steps:
83+
name: "${{inputs.cxx_compiler}} c++${{inputs.cxx_std}} py${{inputs.python_ver}}"
84+
runs-on: ${{ inputs.runner }}
85+
container:
86+
image: ${{ inputs.container }}
87+
88+
env:
89+
CXX: ${{inputs.cxx_compiler}}
90+
CC: ${{inputs.cc_compiler}}
91+
CMAKE_BUILD_TYPE: ${{inputs.build_type}}
92+
CMAKE_CXX_STANDARD: ${{inputs.cxx_std}}
93+
CMAKE_GENERATOR: ${{inputs.generator}}
94+
CTEST_ARGS: ${{inputs.ctest_args}}
95+
CTEST_TEST_TIMEOUT: ${{inputs.ctest_test_timeout}}
96+
USE_SIMD: ${{inputs.simd}}
97+
FMT_VERSION: ${{inputs.fmt_ver}}
98+
OPENCOLORIO_VERSION: ${{inputs.opencolorio_ver}}
99+
OPENEXR_VERSION: ${{inputs.openexr_ver}}
100+
OPENIMAGEIO_VERSION: ${{inputs.openimageio_ver}}
101+
PYBIND11_VERSION: ${{inputs.pybind11_ver}}
102+
PYTHON_VERSION: ${{inputs.python_ver}}
103+
USE_BATCHED: ${{inputs.batched}}
104+
ABI_CHECK: ${{inputs.abi_check}}
105+
ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16
106+
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
107+
108+
steps:
109+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
110+
with:
111+
fetch-depth: '0'
112+
- name: Prepare ccache timestamp
113+
id: ccache_cache_keys
114+
shell: bash
115+
run: echo "date=`date -u +'%Y-%m-%dT%H:%M:%SZ'`" >> $GITHUB_OUTPUT
116+
- name: ccache
117+
id: ccache
118+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
119+
with:
120+
path: ./ccache
121+
key: ${{github.job}}-${{inputs.nametag}}-${{steps.ccache_cache_keys.outputs.date}}
122+
restore-keys: ${{github.job}}-
123+
- name: Setup Nuget.exe (Windows only)
124+
if: runner.os == 'Windows'
125+
uses: nuget/setup-nuget@a21f25cd3998bf370fde17e3f1b4c12c175172f9 # v2.0.0
126+
- name: Build setup
127+
shell: bash
128+
run: |
129+
${{inputs.setenvs}}
130+
src/build-scripts/ci-startup.bash
131+
- name: Dependencies
132+
shell: bash
133+
run: |
134+
${{inputs.depcmds}}
135+
if [[ "$RUNNER_OS" == "Linux" ]]; then
136+
src/build-scripts/gh-installdeps.bash
137+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
138+
src/build-scripts/install_homebrew_deps.bash
139+
if [[ "$OPENIMAGEIO_VERSION" != "" ]] ; then \
140+
OPENIMAGEIO_CMAKE_FLAGS="-DOIIO_BUILD_TESTS=0 -DUSE_OPENGL=0 -DCMAKE_UNITY_BUILD=ON" ; \
141+
source src/build-scripts/build_openimageio.bash ; \
142+
else \
143+
brew install --display-times -q openimageio ; \
144+
PYTHONPATH=$PYTHONPATH:/usr/local/lib/python${PYTHON_VERSION}/site-packages ; \
145+
fi
146+
src/build-scripts/save-env.bash
147+
elif [[ "$RUNNER_OS" == "Windows" ]]; then
148+
src/build-scripts/gh-win-installdeps.bash
149+
fi
150+
- name: Install sonar-scanner and build-wrapper
151+
if: inputs.sonar == '1'
152+
uses: sonarsource/sonarcloud-github-c-cpp@e4882e1621ad2fb48dddfa48287411bed34789b1 # v2.0.2
153+
- name: Build
154+
if: inputs.skip_build != '1'
155+
shell: bash
156+
run: src/build-scripts/ci-build.bash
157+
- name: Testsuite
158+
if: inputs.skip_tests != '1'
159+
shell: bash
160+
run: src/build-scripts/ci-test.bash
161+
- name: Code coverage
162+
if: inputs.coverage == '1'
163+
run: src/build-scripts/ci-coverage.bash
164+
- name: Sonar-scanner
165+
if: inputs.sonar == 1
166+
env:
167+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
169+
run: |
170+
which sonar-scanner
171+
ls -l /__w/OpenShadingLanguage/OpenShadingLanguage/bw_output
172+
echo "BUILD_OUTPUT_DIR is " "${{ env.BUILD_WRAPPER_OUT_DIR }}"
173+
find . -name "*.gcov" -print
174+
# sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
175+
time sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="$BUILD_WRAPPER_OUT_DIR" --define sonar.cfamily.gcov.reportsPath="_coverage" --define sonar.cfamily.threads="$PARALLEL"
176+
# Consult https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-cli/ for more information and options
177+
- name: Check out ABI standard
178+
if: inputs.abi_check != ''
179+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
180+
with:
181+
ref: ${{inputs.abi_check}}
182+
path: abi_standard
183+
- name: Build ABI standard
184+
if: inputs.abi_check != ''
185+
shell: bash
186+
run: |
187+
mkdir -p abi_standard/build
188+
pushd abi_standard
189+
src/build-scripts/ci-build.bash
190+
popd
191+
- name: Check ABI
192+
if: inputs.abi_check != ''
193+
shell: bash
194+
run: |
195+
src/build-scripts/ci-abicheck.bash ./build abi_standard/build \
196+
liboslexec liboslcomp liboslquery liboslnoise
197+
- name: Build Docs
198+
if: inputs.build_docs == '1'
199+
shell: bash
200+
run: |
201+
cd src/doc
202+
time make doxygen
203+
time make sphinx
204+
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
205+
if: ${{ failure() || inputs.build_docs == '1'}}
206+
with:
207+
name: osl-${{github.job}}-${{inputs.nametag}}
208+
path: |
209+
build/cmake-save
210+
build/compat_reports
211+
build/sphinx
212+
build/*.cmake
213+
build/CMake*
214+
build/testsuite/*/*.*
215+
${{ inputs.extra_artifacts }}

0 commit comments

Comments
 (0)