Unverified Commit 91b57697 authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

add macOS unittest to GHA (#7376)

parent 44e8a350
...@@ -7,6 +7,32 @@ CONDA_PATH=$(which conda) ...@@ -7,6 +7,32 @@ CONDA_PATH=$(which conda)
eval "$(${CONDA_PATH} shell.bash hook)" eval "$(${CONDA_PATH} shell.bash hook)"
conda config --set channel_priority strict 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' 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`. # 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 if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
......
name: Unit-tests on M1
on:
pull_request:
push:
branches:
- nightly
- main
- release/*
workflow_dispatch:
env:
CHANNEL: "nightly"
jobs:
tests:
name: "Unit-tests on M1"
runs-on: macos-m1-12
strategy:
matrix:
py_vers: [ "3.8"]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set Release CHANNEL (for release)
if: ${{ (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release')) || startsWith(github.ref, 'refs/heads/release') }}
run: |
echo "CHANNEL=test" >> "$GITHUB_ENV"
- name: Install TorchVision
shell: arch -arch arm64 bash {0}
env:
ENV_NAME: conda-env-${{ github.run_id }}
PY_VERS: ${{ matrix.py_vers }}
run: |
. ~/miniconda3/etc/profile.d/conda.sh
# Needed for JPEG library detection as setup.py detects conda presence by running `shutil.which('conda')`
export PATH=~/miniconda3/bin:$PATH
set -ex
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy libpng jpeg scipy
conda run -p ${ENV_NAME} python3 -mpip install --pre torch --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
conda run -p ${ENV_NAME} python3 setup.py develop
conda run -p ${ENV_NAME} python3 -mpip install pytest pytest-mock 'av<10'
- name: Run tests
shell: arch -arch arm64 bash {0}
env:
ENV_NAME: conda-env-${{ github.run_id }}
PY_VERS: ${{ matrix.py_vers }}
run: |
. ~/miniconda3/etc/profile.d/conda.sh
set -ex
conda run -p ${ENV_NAME} --no-capture-output python3 -u -mpytest -v --tb=long --durations 20
conda env remove -p ${ENV_NAME}
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
...@@ -298,6 +298,8 @@ def get_extensions(): ...@@ -298,6 +298,8 @@ def get_extensions():
use_jpeg = use_jpeg and jpeg_found use_jpeg = use_jpeg and jpeg_found
if use_jpeg: if use_jpeg:
print("Building torchvision with JPEG image support") 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") image_link_flags.append("jpeg")
if jpeg_conda: if jpeg_conda:
image_library += [jpeg_lib] image_library += [jpeg_lib]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment