-
Notifications
You must be signed in to change notification settings - Fork 118
50 lines (44 loc) · 1.47 KB
/
formatting.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Check formatting
concurrency:
group: ${{ github.workflow }}#${{ github.ref }}
cancel-in-progress: true
on:
merge_group:
push:
branches:
- release/**
pull_request:
branches:
- master
- release/**
jobs:
all:
name: C/C++, CMake and Python
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Update submodule
working-directory: ${{runner.workspace}}/nrn
run: git submodule update --init external/coding-conventions
- name: Check formatting
working-directory: ${{runner.workspace}}/nrn
run: external/coding-conventions/bin/format -v --dry-run
# If formatting fails, apply formatting and push changes.
# This will trigger another workflow run, which will cancel the current one.
- name: Apply formatting
working-directory: ${{runner.workspace}}/nrn
if: failure() && github.event_name == 'pull_request'
run: |
# Checkout PR
gh pr checkout ${{ github.event.pull_request.number }}
# Apply formatting
external/coding-conventions/bin/format -v
# Commit & push changes
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -u :/
git commit -a -m "Fix formatting"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}