Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to fix clang-format workflow #12670

Merged
merged 1 commit into from
Jan 17, 2024
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
17 changes: 9 additions & 8 deletions .github/workflows/clang_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,30 @@ jobs:
clangFormatVersion: 14
inplace: true
- run: git diff HEAD > format_patch.txt
- run: if [ "$(cat format_patch.txt)" == "" ] ; then rm format_patch.txt ; fi
- run: if [ "$(cat format_patch.txt)" == "" ] ; then rm format_patch.txt ; else cat format_patch.txt; fi

- uses: actions/upload-artifact@v4
id: upload-artf
if: ${{ hashFiles('format_patch.txt') != '' }}
with:
name: clang format patch
path: format_patch.txt

- name: Artifact ID test
run: |
echo "Artifact ID is ${{ steps.upload-artf.outputs.artifact-id }}"
echo "Link: https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/artifacts/${{ steps.upload-artf.outputs.artifact-id }}"

echo "Link: ${{ steps.upload-artf.outputs.artifact-url }}"

# This does not work for PRs from forks.
- name: Post artifact in issue comment
uses: mshick/[email protected]
if: ${{ hashFiles('format_patch.txt') != '' }}
if: ${{ (hashFiles('format_patch.txt') != '') && (github.event.pull_request.head.repo.full_name == github.repository) }}
with:
message: |
Your PR updated files that did not respect package clang formatting settings. Please apply the patch found [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.upload-artf.outputs.artifact-id }})
Your PR updated files that did not respect package clang formatting settings. Please apply the patch found [here](${{ steps.upload-artf.outputs.artifact-url }})

- uses: actions/github-script@v3
if: ${{ hashFiles('format_patch.txt') != '' }}
with:
script: |
core.setFailed('Please download and apply the formatting patch! It is located at the bottom of the summary tab for this workflow.')
core.setFailed('Your PR updated files that did not respect package clang formatting settings. Please download and apply the formatting patch! It is located at the bottom of the summary tab for this workflow and at this link: ${{ steps.upload-artf.outputs.artifact-url }}')