From 1c46b17ec3c5aed6d1197265c8457bb12f876fea Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Wed, 10 Dec 2025 16:13:39 -0800 Subject: [PATCH 1/5] Auto-format action --- .github/workflows/format.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..d765ce41 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,32 @@ + +name: Run clang-format on PR comment + +on: + issue_comment: + types: [ created ] + +permissions: + contents: write + pull-requests: read + +jobs: + run-clang-format: + if: > + github.event.issue.pull_request && + contains(github.event.comment.body, '!run-clang-format') + runs-on: windows-latest + + steps: + - name: Run clang-format + shell: cmd + run: + ./scripts/run-clang-format.cmd origin/master + + - name: Commit changes + shell: cmd + run: + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add -a + git commit -m "Run clang-format on PR changes" + git push From 1fa37845e376064c882a8f7402dc75496f885de7 Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Wed, 10 Dec 2025 16:13:59 -0800 Subject: [PATCH 2/5] Something that should fail formatting --- include/wil/com.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/wil/com.h b/include/wil/com.h index f6ff5d1e..1f983ac6 100644 --- a/include/wil/com.h +++ b/include/wil/com.h @@ -3271,7 +3271,7 @@ struct com_iterator auto hr = m_enum->Next(1, &m_currentValue, nullptr); if (hr == S_FALSE) { - m_enum = nullptr; + m_enum = nullptr ; } else { From aee17a78eeddbf22a9098745fa70404857c2c6b4 Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Wed, 10 Dec 2025 16:49:25 -0800 Subject: [PATCH 3/5] Can't test this just yet --- include/wil/com.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/wil/com.h b/include/wil/com.h index 1f983ac6..f6ff5d1e 100644 --- a/include/wil/com.h +++ b/include/wil/com.h @@ -3271,7 +3271,7 @@ struct com_iterator auto hr = m_enum->Next(1, &m_currentValue, nullptr); if (hr == S_FALSE) { - m_enum = nullptr ; + m_enum = nullptr; } else { From 8bef44d0f1fbc9d7166fea48d0bcbae08ecbdbe8 Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Thu, 11 Dec 2025 14:49:02 -0800 Subject: [PATCH 4/5] Scope access down --- .github/workflows/format.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index d765ce41..ac7644aa 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -13,7 +13,12 @@ jobs: run-clang-format: if: > github.event.issue.pull_request && - contains(github.event.comment.body, '!run-clang-format') + contains(github.event.comment.body, '!run-clang-format') && + ( + github.event.comment.author_association == 'OWNER' || + github.event.comment.author_association == 'MEMBER' || + github.event.comment.user.login == github.event.issue.user.login + ) runs-on: windows-latest steps: From 64b15111d29b97218b24066bafd477c5a0a4fc32 Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Thu, 11 Dec 2025 15:02:04 -0800 Subject: [PATCH 5/5] Need to run from VS command window --- .github/workflows/format.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index ac7644aa..ebd68fe5 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -25,6 +25,8 @@ jobs: - name: Run clang-format shell: cmd run: + REM 'run-clang-format' script needs 'VCINSTALLDIR' env (among maybe others) to be set + ./scripts/call-vcvars.cmd x64 ./scripts/run-clang-format.cmd origin/master - name: Commit changes