@@ -2,79 +2,35 @@ name: Check mergeability of ghstack PR
2
2
3
3
on :
4
4
pull_request :
5
- types : [opened, synchronize, reopened, edited]
5
+ types : [opened, synchronize, reopened]
6
+ branches : [gh/**/base]
6
7
7
8
jobs :
8
9
ghstack-mergeability-check :
9
10
runs-on : ubuntu-latest
10
11
steps :
11
- - id : check-if-ghstack
12
- # checks whether the PR is a ghstack PR
13
- uses : actions-ecosystem/action-regex-match@d50fd2e7a37d0e617aea3d7ada663bd56862b9cc
14
- with :
15
- text : ${{ github.head_ref }}
16
- regex : ' ^(gh/[^/]+/[0-9]+/)head$'
17
-
18
- - name : Determine if should run
19
- # checks whether the PR is a ghstack PR or whether PR changes the workflow files
20
- id : should-run
21
- shell : bash
22
- run : |
23
- # use GITHUB API to get the files changed in the PR
24
- # and check if the following files were changed:
25
- # .github/workflows/check_mergeability_ghstack.yml
26
- # .github/scripts/trymerge.py
27
- FILES_CHANGED=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
28
- "https://api.github.com/repos/pytorch/pytorch/pulls/${{ github.event.pull_request.number }}/files" | \
29
- jq -r '.[].filename' | \
30
- grep -Ec '^.github/workflows/check_mergeability_ghstack.yml$|^.github/scripts/trymerge.py$')
31
-
32
- IS_GHSTACK_PR="${{ steps.check-if-ghstack.outputs.match != '' }}"
33
-
34
- echo "Is ghstack PR: $IS_GHSTACK_PR"
35
- echo "Workflow files affected by the PR: $FILES_CHANGED"
36
-
37
- if [ "$IS_GHSTACK_PR" = "true" ] || [ "$FILES_CHANGED" -gt 0 ]; then
38
- echo "should-run=true" >> "$GITHUB_OUTPUT"
39
- else
40
- echo "should-run=false" >> "$GITHUB_OUTPUT"
41
-
42
- {
43
- echo "# The $PR_NUM is not a ghstack PR"
44
- echo "For regular PRs the mergeability is reported correctly by GitHub."
45
- echo "To debug the dependencies of the PR manually, run the diagnostic workflow:"
46
- echo "https://github.com/pytorch/test-infra/actions/workflows/pr-dependencies-check.yml"
47
- } >> "$GITHUB_STEP_SUMMARY"
48
-
49
- fi
50
-
51
12
- uses : actions/checkout@v4
52
- if : steps.should-run.outputs.should-run == 'true'
53
13
with :
54
14
fetch-depth : 0
55
15
56
16
- name : Setup git
57
- if : steps.should-run.outputs.should-run == 'true'
58
17
shell : bash
59
18
run : |
60
19
git config --global user.email "pytorchmergebot@users.noreply.github.com"
61
20
git config --global user.name "PyTorch MergeBot"
62
- git fetch origin main
21
+ git fetch origin main:main
63
22
64
23
- name : Setup Python
65
- if : steps.should-run.outputs.should-run == 'true'
66
24
uses : actions/setup-python@v4
67
25
with :
68
26
python-version : ' 3.8'
69
27
cache : pip
70
28
architecture : x64
71
29
72
30
- run : pip install pyyaml==6.0 rockset==1.0.3
73
- if : steps.should-run.outputs.should-run == 'true'
74
31
shell : bash
75
32
76
33
- name : Verify mergeability
77
- if : steps.should-run.outputs.should-run == 'true'
78
34
shell : bash
79
35
env :
80
36
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments