mirror of
https://github.com/crosspoint-reader/crosspoint-reader.git
synced 2026-08-13 14:21:57 -07:00
## Summary Build action take too much time. Lets see if splitting it to two seperate action would speed things up. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**< PARTIALLY >**_
212 lines
6.1 KiB
YAML
212 lines
6.1 KiB
YAML
name: CI (build)
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
clang-format:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
submodules: recursive
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.14'
|
|
|
|
- name: Install clang-format-21
|
|
run: |
|
|
wget https://apt.llvm.org/llvm.sh
|
|
chmod +x llvm.sh
|
|
sudo ./llvm.sh 21
|
|
sudo apt-get update
|
|
sudo apt-get install -y clang-format-21
|
|
|
|
- name: Run clang-format
|
|
run: |
|
|
PATH="/usr/lib/llvm-21/bin:$PATH" ./bin/clang-format-fix
|
|
git diff --exit-code || (echo "Please run 'bin/clang-format-fix' to fix formatting issues" && exit 1)
|
|
|
|
cppcheck:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
submodules: recursive
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.14'
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v7
|
|
with:
|
|
version: "latest"
|
|
enable-cache: false
|
|
|
|
- name: Install PlatformIO Core
|
|
run: uv pip install --system -U https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.19.zip
|
|
|
|
- name: Cache PlatformIO packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.platformio
|
|
key: pio-${{ runner.os }}-${{ hashFiles('platformio.ini') }}
|
|
restore-keys: pio-${{ runner.os }}-
|
|
|
|
- name: Run cppcheck
|
|
run: pio check --fail-on-defect low --fail-on-defect medium --fail-on-defect high
|
|
|
|
build-default:
|
|
name: Build default
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
submodules: recursive
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.14'
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v7
|
|
with:
|
|
version: "latest"
|
|
enable-cache: false
|
|
|
|
- name: Install PlatformIO Core
|
|
run: uv pip install --system -U https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.19.zip
|
|
|
|
- name: Cache PlatformIO packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.platformio
|
|
key: pio-${{ runner.os }}-${{ hashFiles('platformio.ini') }}
|
|
restore-keys: pio-${{ runner.os }}-
|
|
|
|
- name: Build default firmware
|
|
run: |
|
|
set -euo pipefail
|
|
pio run -e default | tee pio.log
|
|
|
|
- name: Extract firmware stats
|
|
|
|
run: |
|
|
set -euo pipefail
|
|
ram_line="$(grep -E "RAM:\\s" -m1 pio.log || true)"
|
|
flash_line="$(grep -E "Flash:\\s" -m1 pio.log || true)"
|
|
echo "ram_line=${ram_line}" >> "$GITHUB_OUTPUT"
|
|
echo "flash_line=${flash_line}" >> "$GITHUB_OUTPUT"
|
|
{
|
|
echo "## Firmware build stats"
|
|
if [ -n "$ram_line" ]; then echo "- ${ram_line}"; else echo "- RAM: not found"; fi
|
|
if [ -n "$flash_line" ]; then echo "- ${flash_line}"; else echo "- Flash: not found"; fi
|
|
} >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
- name: Upload firmware.bin artifact
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: firmware.bin
|
|
path: .pio/build/default/firmware.bin
|
|
if-no-files-found: error
|
|
|
|
build-sticky:
|
|
name: Build sticky
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
submodules: recursive
|
|
|
|
- uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.14'
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v7
|
|
with:
|
|
version: "latest"
|
|
enable-cache: false
|
|
|
|
- name: Install PlatformIO Core
|
|
run: uv pip install --system -U https://github.com/pioarduino/platformio-core/archive/refs/tags/v6.1.19.zip
|
|
|
|
- name: Cache PlatformIO packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.platformio
|
|
key: pio-${{ runner.os }}-${{ hashFiles('platformio.ini') }}
|
|
restore-keys: pio-${{ runner.os }}-
|
|
|
|
- name: Build sticky firmware
|
|
run: |
|
|
set -euo pipefail
|
|
pio run -e sticky | tee pio.log
|
|
|
|
- name: Extract firmware stats
|
|
run: |
|
|
set -euo pipefail
|
|
ram_line="$(grep -E "RAM:\\s" -m1 pio.log || true)"
|
|
flash_line="$(grep -E "Flash:\\s" -m1 pio.log || true)"
|
|
echo "ram_line=${ram_line}" >> "$GITHUB_OUTPUT"
|
|
echo "flash_line=${flash_line}" >> "$GITHUB_OUTPUT"
|
|
{
|
|
echo "## Sticky firmware build stats"
|
|
if [ -n "$ram_line" ]; then echo "- ${ram_line}"; else echo "- RAM: not found"; fi
|
|
if [ -n "$flash_line" ]; then echo "- ${flash_line}"; else echo "- Flash: not found"; fi
|
|
} >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
unit-tests:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Install build tools
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y cmake ninja-build
|
|
|
|
- name: Cache googletest source
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: build/test/_deps/googletest-src
|
|
key: ${{ runner.os }}-googletest-${{ hashFiles('test/CMakeLists.txt') }}
|
|
|
|
- name: Configure
|
|
run: cmake -S test -B build/test -G Ninja -DCMAKE_BUILD_TYPE=Release
|
|
|
|
- name: Build
|
|
run: cmake --build build/test
|
|
|
|
- name: Run tests
|
|
run: ctest --test-dir build/test --output-on-failure -j
|
|
|
|
# This job is used as the PR required actions check, allows for changes to other steps in the future without breaking
|
|
# PR requirements.
|
|
test-status:
|
|
name: Test Status
|
|
needs:
|
|
- build-default
|
|
- build-sticky
|
|
- clang-format
|
|
- cppcheck
|
|
- unit-tests
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Fail because needed jobs failed
|
|
# Fail if any job failed or was cancelled (skipped jobs are ok)
|
|
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
|
|
run: exit 1
|
|
- name: Success
|
|
run: exit 0
|