Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 72 additions & 2 deletions .github/workflows/process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ jobs:
uses: Fusion-Power-Plant-Framework/fppf-actions/hatch-lint@c6af22fc8d00be67cca53a61177301462f499fb2

improve_quality_check:
permissions:
pull-requests: write
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs: [pre-commit-quality-check]
Expand Down Expand Up @@ -147,13 +149,81 @@ jobs:

- name: Run improvement lint
if: steps.changes.outputs.files != ''
id: improvement-lint
shell: bash
run: |
set -euo pipefail
set -uo pipefail

mapfile -t files <<< "${{ steps.changes.outputs.files }}"

hatch run lint:fmt_extra "${files[@]}"
set +e
lint_output=$(hatch run lint:fmt_extra "${files[@]}" 2>&1)
lint_status=$?
set -e

printf '%s\n' "$lint_output"

num_pr_errors=$(
printf '%s\n' "$lint_output" |
grep -oE '[0-9]+' |
tail -n 1 ||
true
)

num_pr_errors=${num_pr_errors:-0}
echo "num_pr_errors=$num_pr_errors" >> "$GITHUB_OUTPUT"
echo "PR lint error count: $num_pr_errors"

exit "$lint_status"

- name: Get information about the current run
if: failure()
uses: Fusion-Power-Plant-Framework/fppf-actions/get-workflow-origin@f94a8de5f658cf65c79e1f143a7a31fb94a05793
id: workflow-run-info
- name: Checkout and lint on main
# check out main
if: failure() && steps.workflow-run-info.outputs.pullRequestNumber != ''
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ steps.workflow-run-info.outputs.targetBranch }}
- name: Numbers of errors
# want to compare number of errors on main, to see if this PR is introducing more
if: failure()
run: |
mapfile -t files <<< "${{ steps.changes.outputs.files }}"
num_main_errors=$((hatch run lint:fmt_extra "${files[@]}" | tail -1) | tr -dc '0-9')
num_main_errors=${num_main_errors:-0}

echo $num_main_errors

echo compared_errors=$(( ${{ steps.improvement-lint.outputs.num_pr_errors }} - $num_main_errors )) >> $GITHUB_OUTPUT
# echo $compared_errors
id: num-errors

- name: Find warning report comment
if: failure() && steps.num-errors.outputs.compared_errors > 0
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0
id: find-warning-report-comment
with:
issue-number: ${{ steps.workflow-run-info.outputs.pullRequestNumber }}
comment-author: "github-actions[bot]"
body-includes: ⚠️ improve_quality_job warning!
direction: last

- name: Warning comment
if: failure() && steps.num-errors.outputs.compared_errors > 0
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
comment-id: ${{ steps.find-warning-report-comment.outputs.comment-id }}
issue-number: ${{ steps.workflow-run-info.outputs.pullRequestNumber }}
body: |
## ⚠️ improve_quality_job warning!
Files changed by this PR have introduced **${{steps.num-errors.outputs.compared_errors}} more linting errors** when compared to main

Please fix these

To check what these are, run `hatch run lint:fmt_extra` on your branch and on main
edit-mode: replace


tracking:
Expand Down
Loading