Skip to content

Commit 030d661

Browse files
authored
mypy_primer: use 'needs: mypy_primer' for comment job (#10474)
1 parent 0d5a1df commit 030d661

File tree

2 files changed

+41
-107
lines changed

2 files changed

+41
-107
lines changed

.github/workflows/mypy_primer.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,48 @@ jobs:
4848
--num-shards 3 --shard-index ${{ matrix.shard-index }} \
4949
--debug \
5050
--output concise \
51-
| tee diff.txt
51+
| tee diff_${{ matrix.shard-index }}.txt
5252
) || [ $? -eq 1 ]
5353
- name: Upload mypy_primer diff
5454
uses: actions/upload-artifact@v2
5555
with:
56-
name: mypy_primer_diff_${{ matrix.shard-index }}
57-
path: diff.txt
56+
name: mypy_primer_diffs
57+
path: diff_${{ matrix.shard-index }}.txt
58+
59+
comment:
60+
name: Comment
61+
runs-on: ubuntu-latest
62+
needs: mypy_primer
63+
permissions:
64+
pull-requests: write
65+
steps:
66+
- name: Download diffs
67+
uses: actions/download-artifact@v2
68+
with:
69+
name: mypy_primer_diffs
70+
71+
- name: Post comment
72+
uses: actions/github-script@v3
73+
with:
74+
github-token: ${{secrets.GITHUB_TOKEN}}
75+
script: |
76+
const fs = require('fs')
77+
const data = (
78+
['diff_0.txt', 'diff_1.txt']
79+
.map(fileName => fs.readFileSync(fileName, { encoding: 'utf8' }))
80+
.join('')
81+
.substr(0, 30000) // About 300 lines
82+
)
83+
84+
console.log("Diff from mypy_primer:")
85+
console.log(data)
86+
87+
if (data.trim()) {
88+
const body = 'Diff from [mypy_primer](https://github.com/hauntsaninja/mypy_primer), showing the effect of this PR on open source code:\n```diff\n' + data + '```'
89+
await github.issues.createComment({
90+
issue_number: context.issue.number,
91+
owner: context.repo.owner,
92+
repo: context.repo.repo,
93+
body
94+
})
95+
}

.github/workflows/mypy_primer_comment.yml

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)