mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-21 05:37:50 -06:00
Add PR review workflows
Using the pull-request-comments-from-clang-tidy-reports GH action https://github.com/marketplace/actions/pull-request-comments-from-clang-tidy-reports Which is possible because the printer-linter auto puts the suggested fixes in the same format as clang-tidy. It consists of two workflows, to ensure safe handling of forks PR's. The first workflows is the analysis and the suggested fixes, these are then upload to the second workflow which will use the suggested fixes to past comments on the PR
This commit is contained in:
parent
67688aad95
commit
32673bedea
2 changed files with 139 additions and 0 deletions
59
.github/workflows/printer-linter-pr-diagnose.yml
vendored
Normal file
59
.github/workflows/printer-linter-pr-diagnose.yml
vendored
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
name: printer-linter-pr-diagnose
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
path:
|
||||||
|
- 'resources/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
printer-linter-diagnose:
|
||||||
|
name: Printer linter PR diagnose
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
- name: Setup Python and pip
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: 3.11.x
|
||||||
|
cache: 'pip'
|
||||||
|
cache-dependency-path: .github/workflows/requirements-printer-linter.txt
|
||||||
|
|
||||||
|
- uses: technote-space/get-diff-action@v6
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
resources/+(extruders|definitions)/*.def.json
|
||||||
|
resources/+(intent|quality|variants)/**/*.inst.cfg
|
||||||
|
|
||||||
|
- name: Install Python requirements for runner
|
||||||
|
if: env.GIT_DIFF && !env.MATCHED_FILES
|
||||||
|
run: pip install -r .github/workflows/requirements-printer-linter.txt
|
||||||
|
|
||||||
|
- name: Create results directory
|
||||||
|
run: mkdir printer-linter-result
|
||||||
|
|
||||||
|
- name: Diagnose file(s)
|
||||||
|
if: env.GIT_DIFF && !env.MATCHED_FILES
|
||||||
|
run: python printer-linter/src/terminal.py --diagnose --report printer-linter-result/fixes.yml ${{ env.GIT_DIFF_FILTERED }}
|
||||||
|
|
||||||
|
- name: Save PR metadata
|
||||||
|
run: |
|
||||||
|
echo ${{ github.event.number }} > printer-linter-result/pr-id.txt
|
||||||
|
echo ${{ github.event.pull_request.head.repo.full_name }} > printer-linter-result/pr-head-repo.txt
|
||||||
|
echo ${{ github.event.pull_request.head.ref }} > printer-linter-result/pr-head-ref.txt
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: printer-linter-result
|
||||||
|
path: printer-linter-result/
|
||||||
|
|
||||||
|
- name: Run clang-tidy-pr-comments action
|
||||||
|
uses: platisd/clang-tidy-pr-comments@master
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
clang_tidy_fixes: result.yml
|
||||||
|
request_changes: true
|
80
.github/workflows/printer-linter-pr-post.yml
vendored
Normal file
80
.github/workflows/printer-linter-pr-post.yml
vendored
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
name: printer-linter-pr-post
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: [ "printer-linter-pr-diagnose" ]
|
||||||
|
types: [ completed ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
clang-tidy-results:
|
||||||
|
# Trigger the job only if the previous (insecure) workflow completed successfully
|
||||||
|
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download analysis results
|
||||||
|
uses: actions/github-script@v3.1.0
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
let artifacts = await github.actions.listWorkflowRunArtifacts({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
run_id: ${{github.event.workflow_run.id }},
|
||||||
|
});
|
||||||
|
let matchArtifact = artifacts.data.artifacts.filter((artifact) => {
|
||||||
|
return artifact.name == "printer-linter-result"
|
||||||
|
})[0];
|
||||||
|
let download = await github.actions.downloadArtifact({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
artifact_id: matchArtifact.id,
|
||||||
|
archive_format: "zip",
|
||||||
|
});
|
||||||
|
let fs = require("fs");
|
||||||
|
fs.writeFileSync("${{github.workspace}}/printer-linter-result.zip", Buffer.from(download.data));
|
||||||
|
|
||||||
|
- name: Set environment variables
|
||||||
|
run: |
|
||||||
|
mkdir printer-linter-result
|
||||||
|
unzip printer-linter-result.zip -d printer-linter-result
|
||||||
|
echo "pr_id=$(cat printer-linter-result/pr-id.txt)" >> $GITHUB_ENV
|
||||||
|
echo "pr_head_repo=$(cat printer-linter-result/pr-head-repo.txt)" >> $GITHUB_ENV
|
||||||
|
echo "pr_head_ref=$(cat printer-linter-result/pr-head-ref.txt)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
repository: ${{ env.pr_head_repo }}
|
||||||
|
ref: ${{ env.pr_head_ref }}
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: Redownload analysis results
|
||||||
|
uses: actions/github-script@v3.1.0
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
let artifacts = await github.actions.listWorkflowRunArtifacts({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
run_id: ${{github.event.workflow_run.id }},
|
||||||
|
});
|
||||||
|
let matchArtifact = artifacts.data.artifacts.filter((artifact) => {
|
||||||
|
return artifact.name == "printer-linter-result"
|
||||||
|
})[0];
|
||||||
|
let download = await github.actions.downloadArtifact({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
artifact_id: matchArtifact.id,
|
||||||
|
archive_format: "zip",
|
||||||
|
});
|
||||||
|
let fs = require("fs");
|
||||||
|
fs.writeFileSync("${{github.workspace}}/printer-linter-result.zip", Buffer.from(download.data));
|
||||||
|
|
||||||
|
- name: Extract analysis results
|
||||||
|
run: |
|
||||||
|
mkdir printer-linter-result
|
||||||
|
unzip printer-linter-result.zip -d printer-linter-result
|
||||||
|
|
||||||
|
- name: Run clang-tidy-pr-comments action
|
||||||
|
uses: platisd/clang-tidy-pr-comments@master
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
clang_tidy_fixes: printer-linter-result/fixes.yml
|
||||||
|
pull_request_id: ${{ env.pr_id }}
|
Loading…
Add table
Add a link
Reference in a new issue