• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{% import 'common.yml.j2' as common %}
2{% import 'upload.yml.j2' as upload %}
3
4{%- block name -%}
5# Template is at:    .github/templates/macos_binary_build_workflow.yml.j2
6# Generation script: .github/scripts/generate_ci_workflows.py
7name: !{{ build_environment }}
8{%- endblock %}
9
10{%- macro set_runner_specific_vars() -%}
11      # NOTE: These environment variables are put here so that they can be applied on every job equally
12      #       They are also here because setting them at a workflow level doesn't give us access to the
13      #       runner.temp variable, which we need.
14      - name: Populate binary env
15        shell: bash
16        run: |
17          # shellcheck disable=SC2129
18          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
19          # shellcheck disable=SC2129
20          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
21          # shellcheck disable=SC2129
22          echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
23{%- endmacro %}
24
25on:
26# TODO: Migrate to new ciflow trigger, reference https://github.com/pytorch/pytorch/pull/70321
27  push:
28    # NOTE: Meta Employees can trigger new nightlies using: https://fburl.com/trigger_pytorch_nightly_build
29    branches:
30      - nightly
31    tags:
32      # NOTE: Binary build pipelines should only get triggered on release candidate builds
33      # Release candidate tags look like: v1.11.0-rc1
34      - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
35{%- for label in ciflow_config.labels | sort %}
36    {%- if loop.first and branches != "nightly" %}
37    tags:
38    {%- endif %}
39      - '!{{ label }}/*'
40{%- endfor %}
41  workflow_dispatch:
42
43env:
44  # Needed for conda builds
45  ALPINE_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/tool/alpine"
46  ANACONDA_USER: pytorch
47  AWS_DEFAULT_REGION: us-east-1
48  BUILD_ENVIRONMENT: !{{ build_environment }}
49  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50  PR_NUMBER: ${{ github.event.pull_request.number }}
51  SKIP_ALL_TESTS: 0
52{%- if cross_compile_arm64 %}
53  CROSS_COMPILE_ARM64: 1
54{% endif %}
55!{{ common.concurrency(build_environment) }}
56
57jobs:
58{%- for config in build_configs %}
59  !{{ config["build_name"] }}-build:
60    if: ${{ github.repository_owner == 'pytorch' }}
61    runs-on: !{{ macos_runner }}
62    timeout-minutes: !{{ common.timeout_minutes }}
63    !{{ upload.binary_env(config, true) }}
64    {%- if config.pytorch_extra_install_requirements is defined and config.pytorch_extra_install_requirements|d('')|length > 0  %}
65      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: !{{ config.pytorch_extra_install_requirements }}
66    {%- endif %}
67    steps:
68      !{{ set_runner_specific_vars() }}
69      - name: Install conda and dependencies
70        run: |
71          # Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on
72          curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh"
73          chmod +x "${RUNNER_TEMP}/conda.sh"
74          /bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda"
75          echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}"
76          if [ -d "/Applications/Xcode_14.3.1.app" ]; then
77            echo "DEVELOPER_DIR=/Applications/Xcode_14.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
78          elif [ -d "/Applications/Xcode_13.3.1.app" ]; then
79            echo "DEVELOPER_DIR=/Applications/Xcode_13.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
80          fi
81      !{{ common.checkout(deep_clone=False, directory="pytorch", checkout_pr_head=False) }}
82      !{{ common.checkout(deep_clone=False, directory="builder", repository=common.builder_repo, branch=common.builder_branch, checkout_pr_head=False) }}
83      - name: Install sccache (only for non-forked PRs, and pushes to trunk)
84        uses: nick-fields/retry@v3.0.0
85        if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
86        with:
87          timeout_minutes: 5
88          max_attempts: 3
89          retry_wait_seconds: 90
90          command: |
91            sudo curl --retry 3 --retry-all-errors https://s3.amazonaws.com/ossci-macos/sccache_v2.15 --output /usr/local/bin/sccache
92            sudo chmod +x /usr/local/bin/sccache
93            echo "SCCACHE_BUCKET=ossci-compiler-cache-circleci-v2" >> "${GITHUB_ENV}"
94      - name: Populate binary env
95        run: |
96          # shellcheck disable=SC1091
97          source "${RUNNER_TEMP}/anaconda/bin/activate"
98          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
99      - name: Build PyTorch binary
100        run: |
101          # shellcheck disable=SC1091
102          source "${RUNNER_TEMP}/anaconda/bin/activate"
103          "${PYTORCH_ROOT}/.circleci/scripts/binary_macos_build.sh"
104      - uses: actions/upload-artifact@v4.4.0
105        if: always()
106        with:
107          name: !{{ config["build_name"] }}
108          retention-days: 14
109          if-no-files-found: error
110          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
111  !{{ upload.upload_binaries(config, has_test=False, use_s3=False) }}
112{%- endfor %}
113