Skip to content

Commit 91b5769

Browse files
authored
add macOS unittest to GHA (#7376)
1 parent 44e8a35 commit 91b5769

File tree

4 files changed

+65
-50
lines changed

4 files changed

+65
-50
lines changed

.github/unittest.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@ CONDA_PATH=$(which conda)
77
eval "$(${CONDA_PATH} shell.bash hook)"
88
conda config --set channel_priority strict
99

10+
# Setup the OS_TYPE environment variable that should be used for conditions involving the OS below.
11+
case $(uname) in
12+
Linux)
13+
OS_TYPE=linux
14+
;;
15+
Darwin)
16+
OS_TYPE=macos
17+
;;
18+
*)
19+
echo "Unknown OS type:" $(uname)
20+
exit 1
21+
;;
22+
esac
23+
24+
echo '::group::Uninstall system JPEG libraries on macOS'
25+
# The x86 macOS runners, e.g. the GitHub Actions native "macos-12" runner, has some JPEG libraries installed by default
26+
# that interfere with our build. We uninstall them here and use the one from conda below.
27+
if [[ "${OS_TYPE}" == "macos" && $(uname -m) == x86_64 ]]; then
28+
JPEG_LIBS=$(brew list | grep jpeg)
29+
echo $JPEG_LIBS
30+
for lib in $JPEG_LIBS; do
31+
brew uninstall --ignore-dependencies --force $lib || true
32+
done
33+
fi
34+
echo '::endgroup::'
35+
1036
echo '::group::Set PyTorch conda channel and wheel index'
1137
# TODO: Can we maybe have this as environment variable in the job template? For example, `IS_RELEASE`.
1238
if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then

.github/workflows/test-m1.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/test-macos.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Unit-tests on macOS
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- nightly
8+
- main
9+
- release/*
10+
workflow_dispatch:
11+
12+
jobs:
13+
tests:
14+
strategy:
15+
matrix:
16+
python-version:
17+
- "3.8"
18+
- "3.9"
19+
- "3.10"
20+
- "3.11"
21+
runner: ["macos-12"]
22+
include:
23+
- python-version: "3.8"
24+
runner: macos-m1-12
25+
fail-fast: false
26+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
27+
with:
28+
repository: pytorch/vision
29+
# We need an increased timeout here, since the macos-12 runner is the free one from GH
30+
# and needs roughly 2 hours to just run the test suite
31+
timeout: 240
32+
runner: ${{ matrix.runner }}
33+
script: |
34+
export PYTHON_VERSION=${{ matrix.python-version }}
35+
export GPU_ARCH_TYPE=cpu
36+
37+
./.github/unittest.sh

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ def get_extensions():
298298
use_jpeg = use_jpeg and jpeg_found
299299
if use_jpeg:
300300
print("Building torchvision with JPEG image support")
301+
print(f" libpng include path: {jpeg_include}")
302+
print(f" libpng lib path: {jpeg_lib}")
301303
image_link_flags.append("jpeg")
302304
if jpeg_conda:
303305
image_library += [jpeg_lib]

0 commit comments

Comments
 (0)