-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make GitHub Actions enforce clang-format-clean code
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright (c) 2023 Sebastian Pipping <sebastian@pipping.org> | ||
# Licensed under Apache License Version 2.0 | ||
|
||
name: Enforce clang-format | ||
|
||
on: | ||
pull_request: | ||
push: | ||
schedule: | ||
- cron: '0 3 * * 5' # Every Friday at 3am | ||
workflow_dispatch: | ||
|
||
# Minimum permissions for security | ||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
clang-format: | ||
name: Enforce clang-format | ||
runs-on: ubuntu-22.04 | ||
env: | ||
CLANG_MAJOR_VERSION: 17 | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Add Clang/LLVM repositories | ||
run: |- | ||
set -x | ||
source /etc/os-release | ||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - | ||
sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-${CLANG_MAJOR_VERSION} main" | ||
- name: Install clang-format | ||
run: |- | ||
set -x | ||
sudo apt-get update | ||
sudo apt-get install --yes --no-install-recommends -V \ | ||
clang-format-${CLANG_MAJOR_VERSION} | ||
- name: Enforce clang-format | ||
run: |- | ||
set -x | ||
clang-format-${CLANG_MAJOR_VERSION} --version | ||
clang-format-${CLANG_MAJOR_VERSION} -i *.c | ||
git diff --exit-code # i.e. reject non-empty diff |