Skip to content

build: make cppcheck a real gate instead of a no-op #496

build: make cppcheck a real gate instead of a no-op

build: make cppcheck a real gate instead of a no-op #496

Workflow file for this run

name: Build
on:
pull_request:
push:
branches:
- '**'
tags-ignore:
- '**'
env:
UNCRUSTIFY_VERSION: 0.83.0
CPPCHECK_VERSION: 2.22.0
jobs:
build:
runs-on: ${{ matrix.os[0] }}
strategy:
matrix:
os: [
[macos-latest, arm64, bash],
[macos-15-intel, x86_64, bash],
[ubuntu-latest, x86_64, bash],
[ubuntu-24.04-arm, arm64, bash]
]
fail-fast: false
defaults:
run:
shell: ${{ matrix.os[2] }} {0}
steps:
- uses: actions/checkout@v5
with:
submodules: 'true'
- &setup_pspdev
name: Setup PSPDEV Environment
run: |
.github/scripts/setup_pspdev.sh "${{ matrix.os[0] }}" "${{ matrix.os[1] }}"
- name: Runs build in shell
run: |
set -euo pipefail
make
make install
- name: Build all samples (Vanilla Makefile)
run: |
set -euo pipefail
for d in samples/*/ ; do
if [ -f "$d/makefile" ] || [ -f "$d/Makefile" ]; then
echo "Building $d"
make -C "$d"
fi
done
- name: Build all samples (CMake)
run: |
set -euo pipefail
for d in samples/*/ ; do
if [ -f "$d/CMakeLists.txt" ]; then
echo "Building (CMake) $d"
(
cd "$d"
cmake --preset psp
cmake --build --preset psp -j
)
fi
done
format:
name: Code format (Uncrustify)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Cache Uncrustify
id: cache-uncrustify
uses: actions/cache@v4
with:
path: ~/.local/bin/uncrustify
key: uncrustify-${{ env.UNCRUSTIFY_VERSION }}-ubuntu-latest
- name: Build Uncrustify ${{ env.UNCRUSTIFY_VERSION }}
if: steps.cache-uncrustify.outputs.cache-hit != 'true'
run: |
set -euo pipefail
git clone --depth 1 --branch "uncrustify-${UNCRUSTIFY_VERSION}" \
https://github.com/uncrustify/uncrustify.git /tmp/uncrustify
cmake -S /tmp/uncrustify -B /tmp/uncrustify/build -DCMAKE_BUILD_TYPE=Release
cmake --build /tmp/uncrustify/build -j"$(nproc)"
mkdir -p ~/.local/bin
install /tmp/uncrustify/build/uncrustify ~/.local/bin/uncrustify
- name: Check formatting
run: |
set -euo pipefail
export PATH="$HOME/.local/bin:$PATH"
uncrustify --version
./run-uncrustify.sh --check
static-analysis:
name: Static analysis (Cppcheck)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: 'true'
# The anchored step in `build` is matrix-driven, so the arguments are
# spelled out here; passing none would fall back to `linux`/`x86_64` and
# request a release asset that does not exist.
- name: Setup PSPDEV Environment
run: |
.github/scripts/setup_pspdev.sh ubuntu-latest x86_64
- name: Cache Cppcheck
id: cache-cppcheck
uses: actions/cache@v4
with:
path: ~/.local/cppcheck
key: cppcheck-${{ env.CPPCHECK_VERSION }}-ubuntu-latest
- name: Build Cppcheck ${{ env.CPPCHECK_VERSION }}
if: steps.cache-cppcheck.outputs.cache-hit != 'true'
run: |
set -euo pipefail
git clone --depth 1 --branch "${CPPCHECK_VERSION}" \
https://github.com/danmar/cppcheck.git /tmp/cppcheck
cmake -S /tmp/cppcheck -B /tmp/cppcheck/build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="$HOME/.local/cppcheck" \
-DUSE_MATCHCOMPILER=ON
cmake --build /tmp/cppcheck/build -j"$(nproc)"
cmake --install /tmp/cppcheck/build
- name: Generate the compilation database
run: |
set -euo pipefail
export PATH="$HOME/.local/cppcheck/bin:$PATH"
cmake --preset psp
- name: Run Cppcheck
run: |
set -euo pipefail
export PATH="$HOME/.local/cppcheck/bin:$PATH"
cppcheck --version
./run-cppcheck.sh