Skip to content

Bump actions/checkout from 3 to 4 #15

Bump actions/checkout from 3 to 4

Bump actions/checkout from 3 to 4 #15

name: Code Formatting Check
on:
pull_request:
paths:
- ".github/workflows/code-formatting-check.yml"
- ".clang-format"
- "formatter.sh"
- "./**"
push:
paths:
- ".github/workflows/code-formatting-check.yml"
- ".clang-format"
- "formatter.sh"
- "./**"
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/download-asset-action@main
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 projects
run: ./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