mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 20:24:30 +08:00
Match mypy primer comment code (#13318)
These actions diverged, making them more closely match makes it easier to maintain
This commit is contained in:
35
.github/workflows/mypy_primer.yml
vendored
35
.github/workflows/mypy_primer.yml
vendored
@@ -57,18 +57,35 @@ jobs:
|
||||
--output concise \
|
||||
| tee diff_${{ matrix.shard-index }}.txt
|
||||
) || [ $? -eq 1 ]
|
||||
- name: Upload mypy_primer diff
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mypy_primer_diff_${{ matrix.shard-index }}
|
||||
path: diff_${{ matrix.shard-index }}.txt
|
||||
- if: ${{ matrix.shard-index == 0 }}
|
||||
name: Save PR number
|
||||
run: |
|
||||
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
|
||||
- if: ${{ matrix.shard-index == 0 }}
|
||||
name: Upload PR number
|
||||
- name: Upload mypy_primer diff + PR number
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ matrix.shard-index == 0 }}
|
||||
with:
|
||||
name: mypy_primer_diff_pr_number
|
||||
path: pr_number.txt
|
||||
name: mypy_primer_diffs-${{ matrix.shard-index }}
|
||||
path: |
|
||||
diff_${{ matrix.shard-index }}.txt
|
||||
pr_number.txt
|
||||
- name: Upload mypy_primer diff
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ matrix.shard-index != 0 }}
|
||||
with:
|
||||
name: mypy_primer_diffs-${{ matrix.shard-index }}
|
||||
path: diff_${{ matrix.shard-index }}.txt
|
||||
|
||||
join_artifacts:
|
||||
name: Join artifacts
|
||||
runs-on: ubuntu-latest
|
||||
needs: [mypy_primer]
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Merge artifacts
|
||||
uses: actions/upload-artifact/merge@v4
|
||||
with:
|
||||
name: mypy_primer_diffs
|
||||
pattern: mypy_primer_diffs-*
|
||||
delete-merged: true
|
||||
|
||||
31
.github/workflows/mypy_primer_comment.yml
vendored
31
.github/workflows/mypy_primer_comment.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Post mypy_primer comment
|
||||
name: Comment with mypy_primer diff
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
@@ -14,8 +14,8 @@ permissions:
|
||||
jobs:
|
||||
comment:
|
||||
name: Comment PR from mypy_primer
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
steps:
|
||||
- name: Download diffs
|
||||
uses: actions/github-script@v7
|
||||
@@ -27,20 +27,18 @@ jobs:
|
||||
repo: context.repo.repo,
|
||||
run_id: ${{ github.event.workflow_run.id }},
|
||||
});
|
||||
const matchArtifacts = artifacts.data.artifacts.filter((artifact) =>
|
||||
artifact.name.startsWith("mypy_primer_diff"));
|
||||
const [matchArtifact] = artifacts.data.artifacts.filter((artifact) =>
|
||||
artifact.name == "mypy_primer_diffs");
|
||||
|
||||
for (const matchArtifact of matchArtifacts) {
|
||||
const download = await github.rest.actions.downloadArtifact({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
artifact_id: matchArtifact.id,
|
||||
archive_format: "zip",
|
||||
});
|
||||
fs.writeFileSync(`${matchArtifact.name}.zip`, Buffer.from(download.data));
|
||||
}
|
||||
const download = await github.rest.actions.downloadArtifact({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
artifact_id: matchArtifact.id,
|
||||
archive_format: "zip",
|
||||
});
|
||||
fs.writeFileSync("diff.zip", Buffer.from(download.data));
|
||||
|
||||
- run: for file in *.zip; do unzip $file; done
|
||||
- run: unzip diff.zip
|
||||
- run: |
|
||||
cat diff_*.txt | tee fulldiff.txt
|
||||
|
||||
@@ -48,7 +46,7 @@ jobs:
|
||||
id: post-comment
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const fs = require('fs')
|
||||
let data = fs.readFileSync('fulldiff.txt', { encoding: 'utf8' })
|
||||
@@ -61,6 +59,9 @@ jobs:
|
||||
data = truncated_data + `\n\n... (truncated ${lines_truncated} lines) ...\n`
|
||||
}
|
||||
|
||||
console.log("Diff from mypy_primer:")
|
||||
console.log(data)
|
||||
|
||||
let body
|
||||
if (data.trim()) {
|
||||
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 + '```'
|
||||
|
||||
Reference in New Issue
Block a user