Skip to content

Commit 1cad60d

Browse files
Auto-apply formatting from PR (neuronsimulator#2395)
when the code formatting check fails, run code formatting and push the changes to the same PR branch.
1 parent f7aba0a commit 1cad60d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.github/workflows/formatting.yml

+21
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,24 @@ jobs:
2727
- name: Check formatting
2828
working-directory: ${{runner.workspace}}/nrn
2929
run: external/coding-conventions/bin/format -v --dry-run
30+
31+
# If formatting fails, apply formatting and push changes.
32+
# This will trigger another workflow run, which will cancel the current one.
33+
- name: Apply formatting
34+
working-directory: ${{runner.workspace}}/nrn
35+
if: failure() && github.event_name == 'pull_request'
36+
run: |
37+
# Checkout PR
38+
gh pr checkout ${{ github.event.pull_request.number }}
39+
40+
# Apply formatting
41+
external/coding-conventions/bin/format -v
42+
43+
# Commit & push changes
44+
git config --global user.name "github-actions[bot]"
45+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
46+
git add -u :/
47+
git commit -a -m "Fix formatting"
48+
git push
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

src/nrniv/netpar.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ NetParEvent::~NetParEvent() {}
240240
void NetParEvent::send(double tt, NetCvode* nc, NrnThread* nt) {
241241
nc->event(tt + usable_mindelay_, this, nt);
242242
}
243+
244+
243245
void NetParEvent::deliver(double tt, NetCvode* nc, NrnThread* nt) {
244246
int seq;
245247
if (nrn_use_selfqueue_) { // first handle pending flag=1 self events

0 commit comments

Comments
 (0)