Skip to content

Commit 7c02b01

Browse files
committed
mypy_primer: use 'needs: mypy_primer' for comment job (python#5428)
1 parent 0d5a1df commit 7c02b01

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

.github/workflows/mypy_primer.yml

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,58 @@ 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+
let body
88+
if (data.trim()) {
89+
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 + '```'
90+
} else {
91+
body = 'According to [mypy_primer](https://github.com/hauntsaninja/mypy_primer), this change has no effect on the checked open source code. 🤖🎉'
92+
}
93+
94+
await github.issues.createComment({
95+
issue_number: context.issue.number,
96+
owner: context.repo.owner,
97+
repo: context.repo.repo,
98+
body
99+
})
100+
101+
- uses: kanga333/comment-hider@9141763feccc8da773595675adc567d6616b6e6f
102+
name: Hide old comments
103+
with:
104+
github_token: ${{ secrets.GITHUB_TOKEN }}
105+
leave_visible: 1

0 commit comments

Comments
 (0)