1name: mac-test-arm64 2 3on: 4 workflow_call: 5 inputs: 6 build-environment: 7 required: true 8 type: string 9 description: Top-level label for what's being built/tested. 10 sync-tag: 11 required: false 12 type: string 13 default: "" 14 description: | 15 If this is set, our linter will use this to make sure that every other 16 job with the same `sync-tag` is identical. 17 python-version: 18 required: false 19 type: string 20 default: "3.8" 21 description: | 22 The python version to be used. Will be 3.8 by default 23 test-matrix: 24 required: true 25 type: string 26 description: | 27 A JSON description of what configs to run later on. 28 29jobs: 30 filter: 31 if: github.repository_owner == 'pytorch' 32 runs-on: [self-hosted, linux.large] 33 outputs: 34 test-matrix: ${{ steps.filter.outputs.test-matrix }} 35 is-test-matrix-empty: ${{ steps.filter.outputs.is-test-matrix-empty }} 36 keep-going: ${{ steps.filter.outputs.keep-going }} 37 ci-verbose-test-logs: ${{ steps.filter.outputs.ci-verbose-test-logs }} 38 ci-no-test-timeout: ${{ steps.filter.outputs.ci-no-test-timeout }} 39 ci-no-td: ${{ steps.filter.outputs.ci-no-td }} 40 reenabled-issues: ${{ steps.filter.outputs.reenabled-issues }} 41 steps: 42 - name: Checkout PyTorch 43 uses: pytorch/pytorch/.github/actions/checkout-pytorch@release/2.4 44 with: 45 submodules: false 46 47 - name: Select all requested test configurations 48 id: filter 49 uses: ./.github/actions/filter-test-configs 50 with: 51 github-token: ${{ secrets.GITHUB_TOKEN }} 52 test-matrix: ${{ inputs.test-matrix }} 53 54 test: 55 needs: filter 56 # Don't run on forked repos. 57 if: github.repository_owner == 'pytorch' && needs.filter.outputs.is-test-matrix-empty == 'False' 58 strategy: 59 matrix: ${{ fromJSON(needs.filter.outputs.test-matrix) }} 60 fail-fast: false 61 runs-on: ${{ matrix.runner }} 62 steps: 63 - name: Print runner OS/HW info 64 run: | 65 sysctl machdep.cpu.brand_string kern.osproductversion 66 67 - name: Checkout PyTorch 68 uses: malfet/checkout@silent-checkout 69 with: 70 ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} 71 quiet-checkout: true 72 73 - name: Clean checkout 74 run: | 75 git clean -fxd 76 77 - name: Download build artifacts 78 uses: ./.github/actions/download-build-artifacts 79 with: 80 name: ${{ inputs.build-environment }} 81 use-gha: true 82 83 - name: Setup miniconda 84 uses: pytorch/test-infra/.github/actions/setup-miniconda@release/2.4 85 with: 86 python-version: ${{ inputs.python-version }} 87 environment-file: .github/requirements/conda-env-${{ runner.os }}-${{ runner.arch }} 88 pip-requirements-file: .github/requirements/pip-requirements-${{ runner.os }}.txt 89 90 - name: Install PyTorch and run MPS tests 91 id: test 92 env: 93 GIT_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} 94 BUILD_ENVIRONMENT: ${{ inputs.build-environment }} 95 TEST_CONFIG: ${{ matrix.config }} 96 ENV_NAME: conda-test-env-${{ github.run_id }} 97 PY_VERS: 3.9 98 PR_BODY: ${{ github.event.pull_request.body }} 99 CONTINUE_THROUGH_ERROR: ${{ needs.filter.outputs.keep-going }} 100 VERBOSE_TEST_LOGS: ${{ needs.filter.outputs.ci-verbose-test-logs }} 101 NO_TEST_TIMEOUT: ${{ needs.filter.outputs.ci-no-test-timeout }} 102 NO_TD: ${{ needs.filter.outputs.ci-no-td }} 103 PIP_REQUIREMENTS_FILE: .github/requirements/pip-requirements-${{ runner.os }}.txt 104 REENABLED_ISSUES: ${{ needs.filter.outputs.reenabled-issues }} 105 run: | 106 # shellcheck disable=SC1090 107 set -ex 108 109 if [[ -n "$CONDA_ENV" ]]; then 110 # Use binaries under conda environment 111 export PATH="$CONDA_ENV/bin":$PATH 112 fi 113 114 # Print out some information about the test environment 115 which conda 116 conda --version 117 ${CONDA_RUN} which python3 118 ${CONDA_RUN} python3 --version 119 ${CONDA_RUN} which python 120 ${CONDA_RUN} python --version 121 122 ${CONDA_RUN} python3 -mpip install --no-index --no-deps dist/*.whl 123 124 set +e 125 pushd "${RUNNER_TEMP}" 126 # Install pip dependencies if they are not found. This is to mitigate a peculiar 127 # flaky missing dependencies on MacOS 128 ${CONDA_RUN} python3 -c "import torch" 129 RC=$? 130 popd 131 132 if [ "${RC}" -ne 0 ]; then 133 ${CONDA_RUN} python3 -mpip install --ignore-installed -r "${PIP_REQUIREMENTS_FILE}" 134 fi 135 set -e 136 137 ${CONDA_RUN} python3 test/run_test.py --mps --verbose 138 139 - name: Print remaining test logs 140 shell: bash 141 if: always() && steps.test.conclusion 142 run: | 143 cat test/**/*_toprint.log || true 144 145 - name: Get workflow job id 146 id: get-job-id 147 uses: ./.github/actions/get-workflow-job-id 148 if: always() 149 with: 150 github-token: ${{ secrets.GITHUB_TOKEN }} 151 152 - name: Upload test artifacts 153 uses: ./.github/actions/upload-test-artifacts 154 if: always() && steps.test.conclusion && steps.test.conclusion != 'skipped' 155 with: 156 use-gha: true 157 file-suffix: ${{ github.job }}-${{ matrix.config }}-${{ matrix.shard }}-${{ matrix.num_shards }}-${{ matrix.runner }}_${{ steps.get-job-id.outputs.job-id }} 158 159 - name: Clean up disk space 160 if: always() 161 continue-on-error: true 162 uses: pytorch/test-infra/.github/actions/check-disk-space@release/2.4 163