• 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/windows_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          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
18          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
19          echo "WIN_PACKAGE_WORK_DIR=${RUNNER_TEMP}"
20{%- endmacro %}
21
22on:
23  push:
24    {%- if branches == "nightly" %}
25    # NOTE: Meta Employees can trigger new nightlies using: https://fburl.com/trigger_pytorch_nightly_build
26    {%- endif %}
27    branches:
28      - !{{ branches }}
29    {%- if branches == "nightly" %}
30    tags:
31      # NOTE: Binary build pipelines should only get triggered on release candidate builds
32      # Release candidate tags look like: v1.11.0-rc1
33      - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
34    {%- endif %}
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  SHA1: ${{ github.event.pull_request.head.sha || github.sha }}
52  SKIP_ALL_TESTS: 1
53!{{ common.concurrency(build_environment) }}
54
55jobs:
56{%- for config in build_configs %}
57  !{{ config["build_name"] }}-build:
58    if: ${{ github.repository_owner == 'pytorch' }}
59    {%- if branches == "nightly" %}
60    runs-on: windows.4xlarge
61    {%- else %}
62    runs-on: windows.4xlarge.nonephemeral
63    {%- endif %}
64    timeout-minutes: !{{ common.timeout_minutes }}
65    !{{ upload.binary_env(config, True) }}
66    {%- if config.pytorch_extra_install_requirements is defined and config.pytorch_extra_install_requirements|d('')|length > 0  %}
67      PYTORCH_EXTRA_INSTALL_REQUIREMENTS: !{{ config.pytorch_extra_install_requirements }}
68    {%- endif %}
69    steps:
70      !{{ common.setup_ec2_windows() }}
71      !{{ set_runner_specific_vars() }}
72      !{{ common.checkout(deep_clone=False, directory="pytorch", checkout_pr_head=False) }}
73      !{{ common.checkout(deep_clone=False, directory="builder", repository=common.builder_repo, branch=common.builder_branch, checkout_pr_head=False) }}
74      - name: Populate binary env
75        shell: bash
76        run: |
77          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
78      - name: Build PyTorch binary
79        shell: bash
80        run: |
81          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_build.sh"
82      - uses: !{{ common.upload_artifact_action }}
83        if: always()
84        with:
85          name: !{{ config["build_name"] }}
86          retention-days: 14
87          if-no-files-found: error
88          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
89      !{{ common.wait_and_kill_ssh_windows('pytorch') }}
90  !{{ config["build_name"] }}-test:  # Testing
91    if: ${{ github.repository_owner == 'pytorch' }}
92    needs: !{{ config["build_name"] }}-build
93{%- if config["gpu_arch_type"] == "cuda" %}
94{%- if branches == "nightly" %}
95    runs-on: windows.8xlarge.nvidia.gpu
96{%- else %}
97    runs-on: windows.8xlarge.nvidia.gpu.nonephemeral
98{%- endif %}
99{%- else %}
100    runs-on: windows.4xlarge.nonephemeral
101{%- endif %}
102    timeout-minutes: !{{ common.timeout_minutes }}
103    !{{ upload.binary_env(config, True) }}
104    steps:
105      !{{ common.setup_ec2_windows() }}
106      !{{ set_runner_specific_vars() }}
107      - uses: !{{ common.download_artifact_action }}
108        name: Download Build Artifacts
109        with:
110          name: !{{ config["build_name"] }}
111          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
112      !{{ common.checkout(deep_clone=False, directory="pytorch", checkout_pr_head=False) }}
113      !{{ common.checkout(deep_clone=False, directory="builder", repository=common.builder_repo, branch=common.builder_branch, checkout_pr_head=False) }}
114      - name: Populate binary env
115        shell: bash
116        run: |
117          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
118      - name: Test PyTorch binary
119        shell: bash
120        run: |
121          "${PYTORCH_ROOT}/.circleci/scripts/binary_windows_test.sh"
122      !{{ common.wait_and_kill_ssh_windows('pytorch') }}
123  {%- if branches == "nightly" %}
124  !{{ upload.upload_binaries(config, True) }}
125  {%- endif %}
126{%- endfor %}
127