Merge pull request #71 from per1234/spi-macro-namespace #84
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
name: Code Formatting Check | |
on: | |
pull_request: | |
paths: | |
- ".github/workflows/code-formatting-check.yml" | |
- ".clang-format" | |
- "examples_formatter.sh" | |
- "examples/**" | |
push: | |
paths: | |
- ".github/workflows/code-formatting-check.yml" | |
- ".clang-format" | |
- "examples_formatter.sh" | |
- "examples/**" | |
jobs: | |
check-formatting: | |
runs-on: ubuntu-latest | |
env: | |
# See: https://github.com/arduino/arduino-ide/blob/main/arduino-ide-extension/package.json | |
CLANG_FORMAT_VERSION: 14.0.0 | |
steps: | |
- name: Set environment variables | |
run: | | |
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable | |
echo "CLANG_FORMAT_INSTALL_PATH=${{ runner.temp }}/clang-format" >> "$GITHUB_ENV" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download ClangFormat | |
id: download | |
uses: MrOctopus/[email protected] | |
with: | |
repository: arduino/clang-static-binaries | |
tag: ${{ env.CLANG_FORMAT_VERSION }} | |
asset: clang-format_${{ env.CLANG_FORMAT_VERSION }}_Linux_64bit.tar.bz2 | |
target: ${{ env.CLANG_FORMAT_INSTALL_PATH }} | |
- name: Install ClangFormat | |
run: | | |
cd "${{ env.CLANG_FORMAT_INSTALL_PATH }}" | |
tar --extract --file="${{ steps.download.outputs.name }}" | |
# Add installation to PATH: | |
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path | |
echo "${{ env.CLANG_FORMAT_INSTALL_PATH }}/clang_Linux_64bit" >> "$GITHUB_PATH" | |
- name: Format examples | |
run: ./examples_formatter.sh | |
- name: Check formatting | |
run: | | |
if ! git diff --color --exit-code; then | |
echo "Please do an Auto Format on the sketches:" | |
echo "Arduino IDE: Tools > Auto Format" | |
echo "Arduino Web Editor: Ctrl + B" | |
exit 1 | |
fi |