Skip to content

Commit 1d00052

Browse files
committed
ci: break out reusable build steps
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 opportunty for divergence and mistakes). Signed-off-by: Larry Gritz <[email protected]>
1 parent 8d523a8 commit 1d00052

File tree

3 files changed

+311
-252
lines changed

3 files changed

+311
-252
lines changed

.github/workflows/build-steps.yml

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
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: Remove existing OpenEXR
132+
if: inputs.openexr_ver != ''
133+
shell: bash
134+
run: |
135+
sudo rm -rf /usr/local/include/OpenEXR
136+
sudo rm -rf /usr/local/lib*/cmake/OpenEXR
137+
sudo rm -rf /usr/local/lib*/libOpenOpenEXR*
138+
sudo rm -rf /usr/local/lib*/python*/site-packages/OpenOpenEXR*
139+
- name: Remove existing OIIO
140+
if: inputs.openimageio_ver != ''
141+
shell: bash
142+
run: |
143+
sudo rm -rf /usr/local/include/OpenImageIO
144+
sudo rm -rf /usr/local/lib*/cmake/OpenImageIO
145+
sudo rm -rf /usr/local/lib*/libOpenImageIO*
146+
sudo rm -rf /usr/local/lib*/python*/site-packages/OpenImageIO*
147+
- name: Dependencies
148+
shell: bash
149+
run: |
150+
${{inputs.depcmds}}
151+
if [[ "$RUNNER_OS" == "Linux" ]]; then
152+
src/build-scripts/gh-installdeps.bash
153+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
154+
src/build-scripts/install_homebrew_deps.bash
155+
if [[ "$OPENIMAGEIO_VERSION" != "" ]] ; then \
156+
OPENIMAGEIO_CMAKE_FLAGS="-DOIIO_BUILD_TESTS=0 -DUSE_OPENGL=0 -DCMAKE_UNITY_BUILD=ON" ; \
157+
source src/build-scripts/build_openimageio.bash ; \
158+
fi
159+
src/build-scripts/save-env.bash
160+
elif [[ "$RUNNER_OS" == "Windows" ]]; then
161+
src/build-scripts/gh-win-installdeps.bash
162+
fi
163+
- name: Install sonar-scanner and build-wrapper
164+
if: inputs.sonar == '1'
165+
uses: sonarsource/sonarcloud-github-c-cpp@e4882e1621ad2fb48dddfa48287411bed34789b1 # v2.0.2
166+
- name: Build
167+
if: inputs.skip_build != '1'
168+
shell: bash
169+
run: src/build-scripts/ci-build.bash
170+
- name: Testsuite
171+
if: inputs.skip_tests != '1'
172+
shell: bash
173+
run: src/build-scripts/ci-test.bash
174+
- name: Code coverage
175+
if: inputs.coverage == '1'
176+
run: src/build-scripts/ci-coverage.bash
177+
- name: Sonar-scanner
178+
if: inputs.sonar == 1
179+
env:
180+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
181+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
182+
run: |
183+
which sonar-scanner
184+
ls -l /__w/OpenShadingLanguage/OpenShadingLanguage/bw_output
185+
echo "BUILD_OUTPUT_DIR is " "${{ env.BUILD_WRAPPER_OUT_DIR }}"
186+
find . -name "*.gcov" -print
187+
# sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
188+
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"
189+
# Consult https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-cli/ for more information and options
190+
- name: Check out ABI standard
191+
if: inputs.abi_check != ''
192+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
193+
with:
194+
ref: ${{inputs.abi_check}}
195+
path: abi_standard
196+
- name: Build ABI standard
197+
if: inputs.abi_check != ''
198+
shell: bash
199+
run: |
200+
mkdir -p abi_standard/build
201+
pushd abi_standard
202+
src/build-scripts/ci-build.bash
203+
popd
204+
- name: Check ABI
205+
if: inputs.abi_check != ''
206+
shell: bash
207+
run: |
208+
src/build-scripts/ci-abicheck.bash ./build abi_standard/build \
209+
liboslexec liboslcomp liboslquery liboslnoise
210+
- name: Build Docs
211+
if: inputs.build_docs == '1'
212+
shell: bash
213+
run: |
214+
cd src/doc
215+
time make doxygen
216+
time make sphinx
217+
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
218+
if: ${{ failure() || inputs.build_docs == '1'}}
219+
with:
220+
name: osl-${{github.job}}-${{inputs.nametag}}
221+
path: |
222+
build/cmake-save
223+
build/compat_reports
224+
build/sphinx
225+
build/*.cmake
226+
build/CMake*
227+
build/testsuite/*/*.*
228+
${{ inputs.extra_artifacts }}

0 commit comments

Comments
 (0)