8000 [BE][GHA] Further refactor `checkout_pytorch` · pytorch/pytorch@9950f3b · GitHub
[go: up one dir, main page]

Skip to content

Commit 9950f3b

Browse files
malfetpytorchmergebot
authored andcommitted
[BE][GHA] Further refactor checkout_pytorch
Rename `checkout_pytorch` to `checkout` and assign `submodules` argument a default values, which allow one to replace 10+ `common.checkout_pytorch("recursive")` with `common.checkout()` And also use the same macro to checkout builder in binary builds workflow Pull Request resolved: #71664
1 parent dcc1e1c commit 9950f3b
Collapse file tree

14 files changed

+728
-201
lines changed

.github/templates/android_ci_full_workflow.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ on:
3232
- name: print labels
3333
run: echo "${PR_LABELS}"
3434
!{{ common.setup_ec2_linux() }}
35-
!{{ common.checkout_pytorch("recursive") }}
35+
!{{ common.checkout() }}
3636
!{{ common.calculate_docker_image(false) }}
3737
- name: Pull Docker image
3838
run: |

.github/templates/android_ci_workflow.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ on:
3232
- name: print labels
3333
run: echo "${PR_LABELS}"
3434
!{{ common.setup_ec2_linux() }}
35-
!{{ common.checkout_pytorch("recursive") }}
35+
!{{ common.checkout() }}
3636
!{{ common.calculate_docker_image(false) }}
3737
- name: Pull Docker image
3838
run: |

.github/templates/bazel_ci_workflow.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ on:
3232
- name: print labels
3333
run: echo "${PR_LABELS}"
3434
!{{ common.setup_ec2_linux() }}
35-
!{{ common.checkout_pytorch("recursive") }}
35+
!{{ common.checkout() }}
3636
!{{ common.calculate_docker_image(false) }}
3737
- name: Pull Docker image
3838
run: |

.github/templates/common.yml.j2

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,24 +177,27 @@ concurrency:
177177
docker system prune -af
178178
{%- endmacro -%}
179179

180-
{%- macro checkout_pytorch(submodules, deep_clone=True, pytorch_directory="") -%}
181-
- name: Checkout PyTorch
180+
{%- macro checkout(submodules="recursive", deep_clone=True, directory="", repository="pytorch/pytorch") -%}
181+
- name: Checkout !{{ 'PyTorch' if repository == "pytorch/pytorch" else repository }}
182182
uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9
183183
with:
184184
{%- if deep_clone %}
185185
# deep clone, to allow use of git merge-base
186186
fetch-depth: 0
187187
{%- endif %}
188188
submodules: !{{ submodules }}
189-
{%- if pytorch_directory %}
190-
path: !{{ pytorch_directory }}
189+
{%- if repository != "pytorch/pytorch" %}
190+
repository: !{{ repository }}
191191
{%- endif %}
192-
- name: Clean PyTorch checkout
192+
{%- if directory %}
193+
path: !{{ directory }}
194+
{%- endif %}
195+
- name: Clean !{{ 'PyTorch' if repository == "pytorch/pytorch" else repository }} checkout
193196
run: |
194197
# Remove any artifacts from the previous checkouts
195198
git clean -fxd
196-
{%- if pytorch_directory%}
197-
working-directory: !{{ pytorch_directory }}
199+
{%- if directory%}
200+
working-directory: !{{ directory }}
198201
{%- endif %}
199202
{%- endmacro -%}
200203

.github/templates/docker_builds_ci_workflow.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
name: docker-build (${{ matrix.docker_image_short_name }})
4141
steps:
4242
!{{ common.setup_ec2_linux() }}
43-
!{{ common.checkout_pytorch("recursive") }}
43+
!{{ common.checkout() }}
4444
!{{ common.calculate_docker_image(true) }}
4545
- name: Pull Docker image
4646
run: |

.github/templates/ios_ci_workflow.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
steps:
5454
- name: print labels
5555
run: echo "${PR_LABELS}"
56-
!{{ common.checkout_pytorch("recursive") }}
56+
!{{ common.checkout() }}
5757< B41A /td>
!{{ common.setup_miniconda("3.8") }}
5858
- name: Install ios / conda Dependencies
5959
run: |

.github/templates/linux_binary_build_workflow.yml.j2

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,8 @@ jobs:
7777
!{{ binary_env(config) }}
7878
steps:
7979
!{{ common.setup_ec2_linux() }}
80-
!{{ common.checkout_pytorch("recursive", deep_clone=False, pytorch_directory="pytorch") }}
81-
- name: Clone pytorch/builder
82-
uses: actions/checkout@v2
83-
with:
84-
repository: pytorch/builder
85-
path: builder
80+
!{{ common.checkout(deep_clone=False, directory="pytorch") }}
81+
!{{ common.checkout(deep_clone=False, directory="builder", repository="pytorch/builder") }}
8682
{%- if config["gpu_arch_type"] == 'cuda' and config["gpu_arch_version"].startswith('11') %}
8783
- name: Set BUILD_SPLIT_CUDA
8884
run: |

.github/templates/linux_ci_workflow.yml.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: print labels
6868
run: echo "${PR_LABELS}"
6969
!{{ common.setup_ec2_linux() }}
70-
!{{ common.checkout_pytorch("recursive") }}
70+
!{{ common.checkout() }}
7171
!{{ common.calculate_docker_image(false) }}
7272
- name: Pull Docker image
7373
run: |
@@ -207,7 +207,7 @@ jobs:
207207
{%- else %}
208208
!{{ common.setup_ec2_linux() }}
209209
{%- endif %}
210-
!{{ common.checkout_pytorch("recursive") }}
210+
!{{ common.checkout() }}
211211
- name: Pull Docker image
212212
run: |
213213
!{{ common.add_retry_to_env() }}
@@ -367,7 +367,7 @@ jobs:
367367
WITH_PUSH: ${{ github.event_name == 'schedule' }}
368368
steps:
369369
!{{ common.setup_ec2_linux() }}
370-
!{{ common.checkout_pytorch("recursive") }}
370+
!{{ common.checkout() }}
371371
- name: Pull Docker image
372372
run: |
373373
!{{ common.add_retry_to_env() }}

.github/templates/macos_ci_workflow.yml.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
steps:
5656
- name: print labels
5757
run: echo "${PR_LABELS}"
58-
!{{ common.checkout_pytorch("recursive") }}
58+
!{{ common.checkout() }}
5959
!{{ common.setup_miniconda("3.8") }}
6060
- name: Install macOS homebrew dependencies
6161
run: |
@@ -125,7 +125,7 @@ jobs:
125125
NUM_TEST_SHARDS: ${{ matrix.num_shards }}
126126
PYTORCH_IGNORE_DISABLED_ISSUES: ${{ needs.generate-test-matrix.outputs.ignore-disabled-issues }}
127127
steps:
128-
!{{ common.checkout_pytorch("false") }}
128+
!{{ common.checkout(submodules="false") }}
129129
- uses: actions/download-artifact@v2
130130
name: Download PyTorch Build Artifacts from GHA
131131
with:

.github/templates/windows_ci_workflow.yml.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
uses: seemethere/add-github-ssh-key@v1
8888
with:
8989
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90-
!{{ common.checkout_pytorch("recursive") }}
90+
!{{ common.checkout() }}
9191
!{{ common.display_ec2_information() }}
9292
- name: Install Visual Studio 2019 toolchain
9393
shell: powershell
@@ -178,7 +178,7 @@ jobs:
178178
uses: seemethere/add-github-ssh-key@v1
179179
with:
180180
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
181-
!{{ common.checkout_pytorch("recursive") }}
181+
!{{ common.checkout() }}
182182
- name: Install Visual Studio 2019 toolchain
183183
shell: powershell
184184
run: |

0 commit comments

Comments
 (0)
0