|
| 1 | +name: Unit-tests on Linux CPU |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - nightly |
| 8 | + - main |
| 9 | + - release/* |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +env: |
| 13 | + CHANNEL: "nightly" |
| 14 | + |
| 15 | +jobs: |
| 16 | + tests: |
| 17 | + name: "Unit-tests on Linux CPU" |
| 18 | + runs-on: [self-hosted, linux.12xlarge] |
| 19 | + container: |
| 20 | + image: pytorch/conda-builder:cpu |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + py_vers: ["3.7", "3.8", "3.9", "3.10"] |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v2 |
| 28 | + - name: Set Release CHANNEL (for release) |
| 29 | + if: ${{ (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release')) || startsWith(github.ref, 'refs/heads/release') }} |
| 30 | + run: | |
| 31 | + echo "CHANNEL=test" >> "$GITHUB_ENV" |
| 32 | + - name: Setup Conda |
| 33 | + shell: bash -l {0} |
| 34 | + env: |
| 35 | + ENV_NAME: conda-env-${{ github.run_id }} |
| 36 | + PY_VERS: ${{ matrix.py_vers }} |
| 37 | + run: | |
| 38 | + git config --global --add safe.directory /__w/vision/vision |
| 39 | + . ~/miniconda3/etc/profile.d/conda.sh |
| 40 | + conda create -yp ${ENV_NAME} python=${PY_VERS} numpy libpng jpeg scipy |
| 41 | + echo "CONDA_RUN=conda run -p ${ENV_NAME}" >> "$GITHUB_ENV" |
| 42 | + - name: Install TorchVision |
| 43 | + shell: bash -l {0} |
| 44 | + env: |
| 45 | + VERSION: cpu |
| 46 | + CUDATOOLKIT: cpuonly |
| 47 | + run: | |
| 48 | + # Needed for JPEG library detection as setup.py detects conda presence |
| 49 | + # by running `shutil.which('conda')` |
| 50 | + export PATH=~/miniconda3/bin:$PATH |
| 51 | + set -ex |
| 52 | + ${CONDA_RUN} conda install \ |
| 53 | + --yes \ |
| 54 | + -c "pytorch-${CHANNEL}" \ |
| 55 | + -c nvidia "pytorch-${CHANNEL}"::pytorch[build="*${VERSION}*"] \ |
| 56 | + "${CUDATOOLKIT}" |
| 57 | + ${CONDA_RUN} python3 setup.py develop |
| 58 | + ${CONDA_RUN} python3 -m pip install pytest pytest-mock av |
| 59 | + - name: Run tests |
| 60 | + shell: bash -l {0} |
| 61 | + env: |
| 62 | + ENV_NAME: conda-env-${{ github.run_id }} |
| 63 | + PY_VERS: ${{ matrix.py_vers }} |
| 64 | + run: | |
| 65 | + . ~/miniconda3/etc/profile.d/conda.sh |
| 66 | + set -ex |
| 67 | + ${CONDA_RUN} python3 -m torch.utils.collect_env |
| 68 | + ${CONDA_RUN} python3 -m pytest --junitxml=test-results/junit.xml -v --durations 20 |
| 69 | + conda env remove -p ${ENV_NAME} |
0 commit comments