Check formatting in GitHub Actions
This commit is contained in:
parent
d2bd33cdeb
commit
0fa21ab247
|
|
@ -0,0 +1,41 @@
|
|||
name: Format
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
format:
|
||||
# Skip checking pull requests from the same repository
|
||||
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository }}
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Run Formatter
|
||||
run: .github/format/AStyleHelper.exe Silent || true
|
||||
|
||||
- name: Check for Changes
|
||||
id: check_changes
|
||||
run: |
|
||||
git diff --exit-code
|
||||
continue-on-error: true
|
||||
|
||||
- name: Report Failure
|
||||
if: steps.check_changes.outcome == 'failure'
|
||||
run: |
|
||||
echo "::error::Code is not formatted correctly! Please run 'format.bat' locally and commit the changes."
|
||||
git diff --color
|
||||
git diff > format.patch
|
||||
exit 1
|
||||
|
||||
- name: Upload Patch
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: format-patch
|
||||
path: format.patch
|
||||
Loading…
Reference in New Issue