8000 [CI] simplify mergeability check workflow (#118415) · pytorch/pytorch@d41cfc9 · GitHub
[go: up one dir, main page]

Skip to content

Commit d41cfc9

Browse files
izaitsevfbpytorchmergebot
authored andcommitted
1 parent 84251d1 commit d41cfc9

File tree

1 file changed

+3
-47
lines changed

1 file changed

+3
-47
lines changed

.github/workflows/check_mergeability_ghstack.yml

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,79 +2,35 @@ name: Check mergeability of ghstack PR
22

33
on:
44
pull_request:
5-
types: [opened, synchronize, reopened, edited]
5+
types: [opened, synchronize, reopened]
6+
branches: [gh/**/base]
67

78
jobs:
89
ghstack-mergeability-check:
910
runs-on: ubuntu-latest
1011
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-
5112
- uses: actions/checkout@v4
52-
if: steps.should-run.outputs.should-run == 'true'
5313
with:
5414
fetch-depth: 0
5515

5616
- name: Setup git
57-
if: steps.should-run.outputs.should-run == 'true'
5817
shell: bash
5918
run: |
6019
git config --global user.email "pytorchmergebot@users.noreply.github.com"
6120
git config --global user.name "PyTorch MergeBot"
62-
git fetch origin main
21+
git fetch origin main:main
6322
6423
- name: Setup Python
65-
if: steps.should-run.outputs.should-run == 'true'
6624
uses: actions/setup-python@v4
6725
with:
6826
python-version: '3.8'
6927
cache: pip
7028
architecture: x64
7129

7230
- run: pip install pyyaml==6.0 rockset==1.0.3
73-
if: steps.should-run.outputs.should-run == 'true'
7431
shell: bash
7532

7633
- name: Verify mergeability
77-
if: steps.should-run.outputs.should-run == 'true'
7834
shell: bash
7935
env:
8036
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)
0