Skip to content

Commit

Permalink
ci: update to latest intel osx runner and download 10.15 SDK (#5387)
Browse files Browse the repository at this point in the history
  • Loading branch information
beckermr authored Jun 27, 2024
1 parent c7a1e9b commit c49182f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 23 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,10 @@ jobs:
needs: changes
if: github.event_name == 'schedule' || needs.changes.outputs.code == 'true'

# Old macOS needed for old SDK (see xcode step below)
# This is needed for some MACOSX_DEPLOYMENT_TARGET tests
# We could also install SDKs from a external provider in the future
# if we want to update this runner to a non-deprecated version
runs-on: macos-11
# we still need intel macs so we are stuck on macos-13 (not -14 or -latest)
# the issue is that there are recipes that depend on packages
# that do not exist for osx-arm64 - see #5388
runs-on: macos-13
defaults:
run:
# https://github.com/conda-incubator/setup-miniconda#use-a-default-shell
Expand Down Expand Up @@ -376,7 +375,9 @@ jobs:
- name: Cache Conda
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ~/conda_pkgs_dir
path: |
~/conda_pkgs_dir
~/macosx_sdks
key: cache-${{ env.HASH }}

- name: Setup Miniconda
Expand All @@ -385,8 +386,23 @@ jobs:
condarc-file: .github/condarc
run-post: false # skip post cleanup

- name: Xcode Install
run: sudo xcode-select --switch /Applications/Xcode_11.7.app
- name: SDK Download
run: |
echo "MACOSX_SDK_DIR=${HOME}/macosx_sdks" >> "$GITHUB_ENV"
export MACOSX_SDK_DIR=${HOME}/macosx_sdks
echo "MACOSX_SDK_VERSION=10.15" >> "$GITHUB_ENV"
export MACOSX_SDK_VERSION=10.15
echo "MACOSX_SDK_ROOT=${MACOSX_SDK_DIR}/MacOSX${MACOSX_SDK_VERSION}.sdk" >> "$GITHUB_ENV"
export MACOSX_SDK_ROOT=${MACOSX_SDK_DIR}/MacOSX${MACOSX_SDK_VERSION}.sdk
if [ ! -d ${MACOSX_SDK_DIR} ]; then mkdir ${MACOSX_SDK_DIR}; fi
if [ ! -d ${MACOSX_SDK_ROOT} ]; then
url="https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX${MACOSX_SDK_VERSION}.sdk.tar.xz"
curl -L --output MacOSX${MACOSX_SDK_VERSION}.sdk.tar.xz "${url}"
sdk_sha256=ac75d9e0eb619881f5aa6240689fce862dcb8e123f710032b7409ff5f4c3d18b
echo "${sdk_sha256} *MacOSX${MACOSX_SDK_VERSION}.sdk.tar.xz" | shasum -a 256 -c
tar -xf MacOSX${MACOSX_SDK_VERSION}.sdk.tar.xz -C "${MACOSX_SDK_DIR}"
fi
- name: Conda Install
run: >
Expand Down Expand Up @@ -415,6 +431,8 @@ jobs:
--cov=conda_build
-n auto
-m "${{ env.PYTEST_MARKER }}"
env:
CONDA_BUILD_SYSROOT: ${{ env.MACOSX_SDK_ROOT }}

- name: Upload Coverage
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
Expand Down
3 changes: 3 additions & 0 deletions news/5387-ci-osx-sdk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Other

* Updated the CI to download the MacOSX 10.15 SDK.
49 changes: 34 additions & 15 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,15 @@ def boolify(v):
exit_on_verify_error=exit_on_verify_error_default,
conda_pkg_format=conda_pkg_format_default,
)
result = Config(variant=None, **testing_config_kwargs)

if on_mac and "CONDA_BUILD_SYSROOT" in os.environ:
var_dict = {
"CONDA_BUILD_SYSROOT": [os.environ["CONDA_BUILD_SYSROOT"]],
}
else:
var_dict = None

result = Config(variant=var_dict, **testing_config_kwargs)
result._testing_config_kwargs = testing_config_kwargs
assert result.no_rewrite_stdout_env is False
assert result._src_cache_root is None
Expand Down Expand Up @@ -204,24 +212,35 @@ def variants_conda_build_sysroot(monkeypatch, request):
if not on_mac:
return {}

monkeypatch.setenv(
"CONDA_BUILD_SYSROOT",
subprocess.run(
["xcrun", "--sdk", "macosx", "--show-sdk-path"],
check=True,
capture_output=True,
text=True,
).stdout.strip(),
)
monkeypatch.setenv(
"MACOSX_DEPLOYMENT_TARGET",
subprocess.run(
# if we do not speciy a custom sysroot, we get what the
# current SDK has
if "CONDA_BUILD_SYSROOT" not in os.environ:
monkeypatch.setenv(
"CONDA_BUILD_SYSROOT",
subprocess.run(
["xcrun", "--sdk", "macosx", "--show-sdk-path"],
check=True,
capture_output=True,
text=True,
).stdout.strip(),
)

mdt = subprocess.run(
["xcrun", "--sdk", "macosx", "--show-sdk-version"],
check=True,
capture_output=True,
text=True,
).stdout.strip(),
)
).stdout.strip()
else:
# custom sysroots always have names like MacOSX<version>.sdk
mdt = (
os.path.basename(os.environ["CONDA_BUILD_SYSROOT"])
.replace("MacOSX", "")
.replace(".sdk", "")
)

monkeypatch.setenv("MACOSX_DEPLOYMENT_TARGET", mdt)

return request.param


Expand Down

0 comments on commit c49182f

Please sign in to comment.