mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
add workflow run to trigger clippy annotation on pr
Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
This commit is contained in:
parent
5ea329855d
commit
5eb3c56c95
2 changed files with 59 additions and 3 deletions
56
.github/workflows/lint-annotation.yml
vendored
Normal file
56
.github/workflows/lint-annotation.yml
vendored
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
name: Lint Annotation On PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: [Main]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pr-annotation:
|
||||||
|
name: Create PR annotation
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
outputs:
|
||||||
|
configuration: ${{ steps.configuration.outputs.result }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: clippy-lint-result
|
||||||
|
- name: Retrieve Head Sha
|
||||||
|
run: |
|
||||||
|
echo "HEAD_SHA=$(cat ./pr/head_sha)" >> $GITHUB_OUTPUT
|
||||||
|
id: head_sha
|
||||||
|
- name: Comment on PR with E2E results
|
||||||
|
if: ${{ !cancelled() }}
|
||||||
|
uses: actions/github-script@v7.0.1
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const fs = require('fs')
|
||||||
|
const headSha = fs.readFileSync('./pr/head_sha', 'utf8').trim()
|
||||||
|
const data = fs.readFileSync('./temp/clippy-output.json', 'utf8')
|
||||||
|
const annotations = JSON.parse(data)
|
||||||
|
|
||||||
|
if (!Array.isArray(annotations) || annotations.length === 0) {
|
||||||
|
console.log("✅ No annotations to report.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (annotations.length > 10) {
|
||||||
|
console.warn("⚠️ GitHub only allows 10 annotations per check run. Truncated.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const limitedAnnotations = annotations.slice(0, 10); // GitHub limit
|
||||||
|
|
||||||
|
await github.rest.checks.create({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
name: "Rust Clippy Lint Report",
|
||||||
|
head_sha: headSha,
|
||||||
|
status: "completed",
|
||||||
|
conclusion: "neutral",
|
||||||
|
output: {
|
||||||
|
title: "Rust Clippy Code Annotations",
|
||||||
|
summary: `${limitedAnnotations.length} issue(s) reported`,
|
||||||
|
annotations: limitedAnnotations
|
||||||
|
}
|
||||||
|
});
|
6
.github/workflows/lint.yml
vendored
6
.github/workflows/lint.yml
vendored
|
@ -47,12 +47,12 @@ jobs:
|
||||||
- name: Give permission to script
|
- name: Give permission to script
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./etc/ci/clippy-annotation.sh
|
chmod +x ./etc/ci/clippy-annotation.sh
|
||||||
- name: Save PR number & Create temp directory
|
- name: Save Head Sha & Create temp directory
|
||||||
if: ${{ !cancelled() }}
|
if: ${{ !cancelled() }}
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./pr
|
mkdir -p ./pr
|
||||||
mkdir -p ./temp
|
mkdir -p ./temp
|
||||||
echo ${{ github.event.number }} > ./pr/number
|
echo ${{ github.event.pull_request.head.sha }} > ./pr/head_sha
|
||||||
- name: Clippy
|
- name: Clippy
|
||||||
run: |
|
run: |
|
||||||
./mach clippy --message-format=json --use-crown --locked -- -- --deny warnings | ./etc/ci/clippy-annotation.sh > temp/clippy-output.json
|
./mach clippy --message-format=json --use-crown --locked -- -- --deny warnings | ./etc/ci/clippy-annotation.sh > temp/clippy-output.json
|
||||||
|
@ -63,7 +63,7 @@ jobs:
|
||||||
name: clippy-lint-result
|
name: clippy-lint-result
|
||||||
path: |
|
path: |
|
||||||
temp/clippy-output.json
|
temp/clippy-output.json
|
||||||
pr/number
|
pr/head_sha
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
- name: Tidy
|
- name: Tidy
|
||||||
run: ./mach test-tidy --no-progress --all
|
run: ./mach test-tidy --no-progress --all
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue