Skip to content

Commit 1751c8b

Browse files
committed
ci: enable sccache in GHA build
1 parent 89d69bd commit 1751c8b

File tree

1 file changed

+70
-41
lines changed

1 file changed

+70
-41
lines changed

.github/workflows/build_python_3.yml

Lines changed: 70 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -83,52 +83,22 @@ jobs:
8383
fail-fast: false
8484
matrix:
8585
include: ${{ fromJson(needs.build-wheels-matrix.outputs.include) }}
86-
env:
87-
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE: ${{ needs.compute_version.outputs.library_version }}
88-
CIBW_SKIP: ${{ inputs.cibw_skip }}
89-
CIBW_PRERELEASE_PYTHONS: ${{ inputs.cibw_prerelease_pythons }}
90-
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
91-
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
92-
CIBW_MUSLLINUX_I686_IMAGE: ghcr.io/datadog/dd-trace-py/pypa_musllinux_1_2_i686:latest
93-
CIBW_BEFORE_ALL_WINDOWS: ${{ matrix.os == 'windows-latest' && 'rustup target add i686-pc-windows-msvc' || (matrix.os == 'windows-11-arm' && 'rustup target add aarch64-pc-windows-msvc') }}
94-
CIBW_BEFORE_ALL_MACOS: rustup target add aarch64-apple-darwin
95-
CIBW_BEFORE_ALL_LINUX: |
96-
if [[ "$(uname -m)-$(uname -i)-$(uname -o | tr '[:upper:]' '[:lower:]')-$(ldd --version 2>&1 | head -n 1 | awk '{print $1}')" != "i686-unknown-linux-musl" ]]; then
97-
curl -sSf https://sh.rustup.rs | sh -s -- -y;
98-
fi
99-
CIBW_ENVIRONMENT_LINUX: PATH=$HOME/.cargo/bin:$PATH CMAKE_BUILD_PARALLEL_LEVEL=24 CMAKE_ARGS="-DNATIVE_TESTING=OFF" SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE=${{ needs.compute_version.outputs.library_version }}
100-
# SYSTEM_VERSION_COMPAT is a workaround for versioning issue, a.k.a.
101-
# `platform.mac_ver()` reports incorrect MacOS version at 11.0
102-
# See: https://stackoverflow.com/a/65402241
103-
CIBW_ENVIRONMENT_MACOS: CMAKE_BUILD_PARALLEL_LEVEL=24 SYSTEM_VERSION_COMPAT=0 CMAKE_ARGS="-DNATIVE_TESTING=OFF" SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE=${{ needs.compute_version.outputs.library_version }}
104-
CIBW_ENVIRONMENT_WINDOWS: SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE=${{ needs.compute_version.outputs.library_version }}
105-
# cibuildwheel repair will copy anything's under /output directory from the
106-
# build container to the host machine. This is a bit hacky way, but seems
107-
# to be the only way getting debug symbols out from the container while
108-
# we don't mess up with RECORD file.
109-
CIBW_REPAIR_WHEEL_COMMAND_LINUX: |
110-
mkdir -p /output/debugwheelhouse &&
111-
python scripts/extract_debug_symbols.py {wheel} --output-dir /output/debugwheelhouse &&
112-
python scripts/zip_filter.py {wheel} \*.c \*.cpp \*.cc \*.h \*.hpp \*.pyx \*.md &&
113-
mkdir ./tempwheelhouse &&
114-
unzip -l {wheel} | grep '\.so' &&
115-
auditwheel repair -w ./tempwheelhouse {wheel} &&
116-
mv ./tempwheelhouse/*.whl {dest_dir} &&
117-
rm -rf ./tempwheelhouse
118-
CIBW_REPAIR_WHEEL_COMMAND_MACOS: |
119-
mkdir -p ./debugwheelhouse &&
120-
python scripts/extract_debug_symbols.py {wheel} --output-dir ./debugwheelhouse &&
121-
python scripts/zip_filter.py {wheel} \*.c \*.cpp \*.cc \*.h \*.hpp \*.pyx \*.md &&
122-
MACOSX_DEPLOYMENT_TARGET=12.7 delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
123-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: python scripts/zip_filter.py "{wheel}" "*.c" "*.cpp" "*.cc" "*.h" "*.hpp" "*.pyx" "*.md" && mv "{wheel}" "{dest_dir}"
124-
CIBW_TEST_COMMAND: "python {project}/tests/smoke_test.py"
125-
12686
steps:
12787
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
12888
with:
12989
persist-credentials: false
13090
fetch-depth: 0
13191

92+
- name: Enable sccache
93+
uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # 0.0.9
94+
95+
- name: Add addtional GHA cache-related env vars
96+
uses: actions/github-script@v7
97+
with:
98+
script: |
99+
core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'])
100+
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
101+
132102
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
133103
name: Install Python
134104
with:
@@ -144,7 +114,66 @@ jobs:
144114
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4
145115
with:
146116
only: ${{ matrix.only }}
147-
117+
env:
118+
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE: ${{ needs.compute_version.outputs.library_version }}
119+
CIBW_SKIP: ${{ inputs.cibw_skip }}
120+
CIBW_PRERELEASE_PYTHONS: ${{ inputs.cibw_prerelease_pythons }}
121+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
122+
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
123+
CIBW_MUSLLINUX_I686_IMAGE: ghcr.io/datadog/dd-trace-py/pypa_musllinux_1_2_i686:latest
124+
CIBW_BEFORE_ALL_WINDOWS: ${{ matrix.os == 'windows-latest' && 'rustup target add i686-pc-windows-msvc' || (matrix.os == 'windows-11-arm' && 'rustup target add aarch64-pc-windows-msvc') }}
125+
CIBW_BEFORE_ALL_MACOS: rustup target add aarch64-apple-darwin
126+
CIBW_BEFORE_ALL_LINUX: |
127+
if [[ "$(uname -m)-$(uname -i)-$(uname -o | tr '[:upper:]' '[:lower:]')-$(ldd --version 2>&1 | head -n 1 | awk '{print $1}')" != "i686-unknown-linux-musl" ]]; then
128+
curl -sSf https://sh.rustup.rs | sh -s -- -y;
129+
fi
130+
CIBW_ENVIRONMENT_LINUX: >
131+
PATH=$HOME/.cargo/bin:$PATH
132+
CARGO_BUILD_JOBS=24
133+
CMAKE_BUILD_PARALLEL_LEVEL=24
134+
CMAKE_ARGS="-DNATIVE_TESTING=OFF"
135+
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE=${{ needs.compute_version.outputs.library_version }}
136+
SCCACHE_GHA_ENABLED=true
137+
SCCACHE_DIR=/host/${{ env.SCCACHE_DIR }}
138+
SCCACHE_PATH=/host/${{ env.SCCACHE_PATH }}
139+
SCCACHE_CACHE_SIZE=1G
140+
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
141+
ACTIONS_RUNTIME_URL=${{ env.ACTIONS_RUNTIME_URL }}
142+
ACTIONS_RESULTS_URL=${{ env.ACTIONS_RESULTS_URL }}
143+
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
144+
ACTIONS_CACHE_SERVICE_V2=${{ env.ACTIONS_CACHE_SERVICE_V2 }}
145+
DD_USE_SCCACHE=1
146+
# SYSTEM_VERSION_COMPAT is a workaround for versioning issue, a.k.a.
147+
# `platform.mac_ver()` reports incorrect MacOS version at 11.0
148+
# See: https://stackoverflow.com/a/65402241
149+
CIBW_ENVIRONMENT_MACOS: >
150+
CMAKE_BUILD_PARALLEL_LEVEL=24
151+
SYSTEM_VERSION_COMPAT=0
152+
CMAKE_ARGS="-DNATIVE_TESTING=OFF"
153+
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE=${{ needs.compute_version.outputs.library_version }}
154+
CIBW_ENVIRONMENT_WINDOWS: >
155+
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE=${{ needs.compute_version.outputs.library_version }}
156+
# cibuildwheel repair will copy anything's under /output directory from the
157+
# build container to the host machine. This is a bit hacky way, but seems
158+
# to be the only way getting debug symbols out from the container while
159+
# we don't mess up with RECORD file.
160+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: |
161+
mkdir -p /output/debugwheelhouse &&
162+
python scripts/extract_debug_symbols.py {wheel} --output-dir /output/debugwheelhouse &&
163+
python scripts/zip_filter.py {wheel} \*.c \*.cpp \*.cc \*.h \*.hpp \*.pyx \*.md &&
164+
mkdir ./tempwheelhouse &&
165+
unzip -l {wheel} | grep '\.so' &&
166+
auditwheel repair -w ./tempwheelhouse {wheel} &&
167+
mv ./tempwheelhouse/*.whl {dest_dir} &&
168+
rm -rf ./tempwheelhouse
169+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: |
170+
mkdir -p ./debugwheelhouse &&
171+
python scripts/extract_debug_symbols.py {wheel} --output-dir ./debugwheelhouse &&
172+
python scripts/zip_filter.py {wheel} \*.c \*.cpp \*.cc \*.h \*.hpp \*.pyx \*.md &&
173+
MACOSX_DEPLOYMENT_TARGET=12.7 delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
174+
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: python scripts/zip_filter.py "{wheel}" "*.c" "*.cpp" "*.cc" "*.h" "*.hpp" "*.pyx" "*.md" && mv "{wheel}" "{dest_dir}"
175+
CIBW_BEFORE_TEST_LINUX: /host/${{ env.SCCACHE_PATH }} --show-stats
176+
CIBW_TEST_COMMAND: "python {project}/tests/smoke_test.py"
148177
- name: Validate wheel RECORD files
149178
shell: bash
150179
run: |

0 commit comments

Comments
 (0)