-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added post PR reviews * fixed value error causing typo * added action to create/upload suggestions and added workflow call * removed worklflow call in post-pr-reviews * added referenced action * changes action path * change to ation dir only * added workflow_call * removed trigger in post PR review * added remote action and workflow trigger * commented condition for workflow run
- Loading branch information
Showing
2 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# from https://github.com/OSGeo/grass/blob/main/.github/workflows/post-pr-reviews.yml and slightly modified | ||
--- | ||
name: Post PR code suggestions | ||
|
||
on: | ||
workflow_call: | ||
|
||
permissions: {} | ||
jobs: | ||
post-suggestions: | ||
runs-on: ubuntu-latest | ||
# Only run on failures, since no changes are needed on success | ||
# if: > | ||
# (github.event.workflow_run.event == 'pull_request' && | ||
# github.event.workflow_run.conclusion == 'failure') | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- name: Create a .git directory needed by reviewdog | ||
run: git init | ||
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | ||
id: diff | ||
continue-on-error: true | ||
with: | ||
name: diff | ||
github-token: ${{ github.token }} | ||
run-id: ${{github.event.workflow_run.id }} | ||
- uses: reviewdog/action-setup@3f401fe1d58fe77e10d665ab713057375e39b887 # v1.3.0 | ||
- name: Check what tools have suggestions to post | ||
# Using this pattern to have expected file names explicitly named | ||
id: tools | ||
run: | | ||
for tool_name in $INPUT_TOOL_NAMES | ||
do | ||
INPUT_TOOL_NAME_FILE="diff-${tool_name}.patch" | ||
echo "Checking if tool ${tool_name} left suggestions in ${INPUT_TOOL_NAME_FILE}..." | ||
if [[ -f "${INPUT_TOOL_NAME_FILE}" ]]; then | ||
echo " ${INPUT_TOOL_NAME_FILE} was found for tool ${tool_name}" | ||
echo "$tool_name=true" >> "${GITHUB_OUTPUT}" | ||
else | ||
echo " ${INPUT_TOOL_NAME_FILE} was not found for tool ${tool_name}" | ||
echo "$tool_name=false" >> "${GITHUB_OUTPUT}" | ||
fi | ||
done | ||
env: | ||
INPUT_TOOL_NAMES: >- | ||
black | ||
ruff | ||
- name: Post black suggestions | ||
if: ${{ steps.tools.outputs.black == 'true' }} | ||
run: | | ||
TMPFILE="diff-${INPUT_TOOL_NAME}.patch" | ||
GITHUB_ACTIONS="" reviewdog \ | ||
-name="${INPUT_TOOL_NAME:-reviewdog-suggester}" \ | ||
-f=diff \ | ||
-f.diff.strip=1 \ | ||
-filter-mode=nofilter \ | ||
-guess \ | ||
-reporter="github-pr-review" < "${TMPFILE}" | ||
env: | ||
INPUT_TOOL_NAME: black | ||
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CI_COMMIT: ${{ github.event.workflow_run.head_sha }} | ||
CI_REPO_OWNER: ${{ github.event.workflow_run.repository.owner.login }} | ||
CI_REPO_NAME: ${{ github.event.workflow_run.repository.name }} | ||
# CI_PULL_REQUEST: "" # Populated from reviewdog's "-guess" flag since hard to get | ||
- name: Post ruff suggestions | ||
if: ${{ steps.tools.outputs.ruff == 'true' }} | ||
run: | | ||
TMPFILE="diff-${INPUT_TOOL_NAME}.patch" | ||
GITHUB_ACTIONS="" reviewdog \ | ||
-name="${INPUT_TOOL_NAME:-reviewdog-suggester}" \ | ||
-f=diff \ | ||
-f.diff.strip=1 \ | ||
-filter-mode=nofilter \ | ||
-guess \ | ||
-reporter="github-pr-review" < "${TMPFILE}" | ||
env: | ||
INPUT_TOOL_NAME: ruff | ||
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CI_COMMIT: ${{ github.event.workflow_run.head_sha }} | ||
CI_REPO_OWNER: ${{ github.event.workflow_run.repository.owner.login }} | ||
CI_REPO_NAME: ${{ github.event.workflow_run.repository.name }} | ||
# CI_PULL_REQUEST: "" # Populated from reviewdog's "-guess" flag since hard to get |