Merge pull request #26 from hartwork/dependabot/github_actions/action… #171
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
# Copyright (c) 2023 Sebastian Pipping <sebastian@pipping.org> | |
# SPDX-License-Identifier: Apache-2.0 | |
name: Enforce clang-format | |
# Drop permissions to minimum, for security | |
permissions: | |
contents: read | |
on: | |
pull_request: | |
push: | |
schedule: | |
- cron: '0 2 * * 5' # Every Friday at 2am | |
workflow_dispatch: | |
jobs: | |
clang-format: | |
name: Enforce clang-format | |
runs-on: ubuntu-22.04 | |
env: | |
CLANG_MAJOR_VERSION: 18 | |
steps: | |
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | |
- 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 |