Skip to content

Commit

Permalink
add macOS unittest to GHA (#7376)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmeier authored Mar 8, 2023
1 parent 44e8a35 commit 91b5769
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 50 deletions.
26 changes: 26 additions & 0 deletions .github/unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@ CONDA_PATH=$(which conda)
eval "$(${CONDA_PATH} shell.bash hook)"
conda config --set channel_priority strict

# Setup the OS_TYPE environment variable that should be used for conditions involving the OS below.
case $(uname) in
Linux)
OS_TYPE=linux
;;
Darwin)
OS_TYPE=macos
;;
*)
echo "Unknown OS type:" $(uname)
exit 1
;;
esac

echo '::group::Uninstall system JPEG libraries on macOS'
# The x86 macOS runners, e.g. the GitHub Actions native "macos-12" runner, has some JPEG libraries installed by default
# that interfere with our build. We uninstall them here and use the one from conda below.
if [[ "${OS_TYPE}" == "macos" && $(uname -m) == x86_64 ]]; then
JPEG_LIBS=$(brew list | grep jpeg)
echo $JPEG_LIBS
for lib in $JPEG_LIBS; do
brew uninstall --ignore-dependencies --force $lib || true
done
fi
echo '::endgroup::'

echo '::group::Set PyTorch conda channel and wheel index'
# TODO: Can we maybe have this as environment variable in the job template? For example, `IS_RELEASE`.
if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
Expand Down
50 changes: 0 additions & 50 deletions .github/workflows/test-m1.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Unit-tests on macOS

on:
pull_request:
push:
branches:
- nightly
- main
- release/*
workflow_dispatch:

jobs:
tests:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
runner: ["macos-12"]
include:
- python-version: "3.8"
runner: macos-m1-12
fail-fast: false
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
with:
repository: pytorch/vision
# We need an increased timeout here, since the macos-12 runner is the free one from GH
# and needs roughly 2 hours to just run the test suite
timeout: 240
runner: ${{ matrix.runner }}
script: |
export PYTHON_VERSION=${{ matrix.python-version }}
export GPU_ARCH_TYPE=cpu
./.github/unittest.sh
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ def get_extensions():
use_jpeg = use_jpeg and jpeg_found
if use_jpeg:
print("Building torchvision with JPEG image support")
print(f" libpng include path: {jpeg_include}")
print(f" libpng lib path: {jpeg_lib}")
image_link_flags.append("jpeg")
if jpeg_conda:
image_library += [jpeg_lib]
Expand Down

0 comments on commit 91b5769

Please sign in to comment.