From d3a061262b3624d65969c59f4c030d7d177c0623 Mon Sep 17 00:00:00 2001 From: czcionka Date: Tue, 27 Oct 2026 18:16:57 +0000 Subject: [PATCH] Automatyzacja: check_all Docker CI i reprodukowalne artefakty --- .gitea/workflows/check.yml | 25 ++++++++++++++++++++++++ .gitignore | 4 ++++ Dockerfile | 11 +++++++++++ tools/check_all | 40 ++++++++++++++++++++++++++++++++++++++ tools/flash_release.sh | 9 +++++++++ tools/package_release.sh | 37 +++++++++++++++++++++++++++++++++++ tools/requirements.txt | 22 +++++++++++++++++++++ 7 files changed, 148 insertions(+) create mode 100644 .gitea/workflows/check.yml create mode 100644 Dockerfile create mode 100644 tools/check_all create mode 100644 tools/flash_release.sh create mode 100644 tools/package_release.sh create mode 100644 tools/requirements.txt diff --git a/.gitea/workflows/check.yml b/.gitea/workflows/check.yml new file mode 100644 index 0000000..a75c538 --- /dev/null +++ b/.gitea/workflows/check.yml @@ -0,0 +1,25 @@ +name: check +on: + push: + branches: [main, feat/release-v2] + pull_request: + +jobs: + check-without-hardware: + runs-on: docker + container: python:3.12.12-slim-bookworm + steps: + - uses: actions/checkout@v4 + - name: Install build dependencies + run: | + apt-get update + apt-get install -y --no-install-recommends build-essential cmake git libusb-1.0-0-dev pkg-config ca-certificates + - name: Install pinned Python tools + run: pip install --no-cache-dir --disable-pip-version-check -r tools/requirements.txt + - name: All tests without hardware + run: bash ./tools/check_all + - name: Upload validation reports + uses: actions/upload-artifact@v4 + with: + name: validation-reports + path: artifacts/validation/ diff --git a/.gitignore b/.gitignore index 5d17f68..ccc5fda 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ .pio/ .vscode/ +.venv/ +.cache/ +artifacts/ *.o *.elf *.bin __pycache__/ +*.pyc diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..67b16e7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.12.12-slim-bookworm + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential cmake git libusb-1.0-0-dev pkg-config ca-certificates \ + && rm -rf /var/lib/apt/lists/* +WORKDIR /work +COPY tools/requirements.txt tools/requirements.txt +RUN pip install --no-cache-dir --disable-pip-version-check -r tools/requirements.txt +COPY . . +RUN chmod +x tools/check_all tools/*.sh +CMD ["bash", "./tools/check_all"] diff --git a/tools/check_all b/tools/check_all new file mode 100644 index 0000000..28b5665 --- /dev/null +++ b/tools/check_all @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Wszystkie testy mozliwe bez ESP32/CC1101/RTL-SDR/samochodu. +set -euo pipefail +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT" +mkdir -p artifacts/validation + +if [ -n "${PIO:-}" ]; then + PIO_BIN="$PIO" +elif [ -x "$ROOT/.venv/bin/pio" ]; then + PIO_BIN="$ROOT/.venv/bin/pio" +elif command -v pio >/dev/null 2>&1; then + PIO_BIN="$(command -v pio)" +else + python3 -m venv "$ROOT/.venv" + "$ROOT/.venv/bin/pip" install --disable-pip-version-check -r tools/requirements.txt + PIO_BIN="$ROOT/.venv/bin/pio" +fi + +run() { + local name="$1" + shift + echo "== $name ==" + "$@" 2>&1 | tee "artifacts/validation/$name.log" +} + +run python-self-test python3 tools/tpms_frame.py --self-test +run native-tests "$PIO_BIN" test -e native +run esp32-build "$PIO_BIN" run -e esp32dev +run cppcheck "$PIO_BIN" check -e native \ + --flags='--enable=warning,performance,portability --inline-suppr' \ + --fail-on-defect=low + +if [ ! -x "${RTL433:-$ROOT/.cache/rtl_433/build/src/rtl_433}" ] \ + || [ ! -f "${REFERENCE_DIR:-$ROOT/.cache/rtl_433_tests/tests/Schrader_EG53MA4_TPMS/01}/gfile001.cu8" ]; then + run fetch-references bash ./tools/fetch_references.sh +fi +run rtl433 bash ./tools/verify_rtl433.sh + +echo "PASS: wszystkie testy bez sprzetu zakonczone sukcesem" diff --git a/tools/flash_release.sh b/tools/flash_release.sh new file mode 100644 index 0000000..7e67f74 --- /dev/null +++ b/tools/flash_release.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Wgrywa pelny obraz release; PORT=np. /dev/ttyUSB0. Kasuje flash ESP32. +set -euo pipefail +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +PORT="${PORT:?Ustaw PORT=/dev/ttyUSBX}" +ESPTOOL="${ESPTOOL:-${PLATFORMIO_CORE_DIR:-$HOME/.platformio}/packages/tool-esptool/esptool}" +IMAGE="$ROOT/artifacts/release/firmware-full.bin" +[ -f "$IMAGE" ] || { echo "Brak $IMAGE; uruchom tools/package_release.sh"; exit 1; } +"$ESPTOOL" --chip esp32 --port "$PORT" --baud 460800 write-flash 0x0 "$IMAGE" diff --git a/tools/package_release.sh b/tools/package_release.sh new file mode 100644 index 0000000..46729cb --- /dev/null +++ b/tools/package_release.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# Buduje obrazy ESP32 i pelny obraz 4 MB oraz manifest SHA-256. +set -euo pipefail +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT" +PIO_BIN="${PIO:-$ROOT/.venv/bin/pio}" +if [ ! -x "$PIO_BIN" ]; then PIO_BIN="${PIO:-pio}"; fi +export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-1761600000}" +OUT="$ROOT/artifacts/release" +BUILD="$ROOT/.pio/build/esp32dev" +BOOT_APP0="${PLATFORMIO_CORE_DIR:-$HOME/.platformio}/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin" +ESPTOOL="${ESPTOOL:-${PLATFORMIO_CORE_DIR:-$HOME/.platformio}/packages/tool-esptool/esptool}" + +"$PIO_BIN" run -e esp32dev +mkdir -p "$OUT" +cp "$BUILD/bootloader.bin" "$BUILD/partitions.bin" "$BUILD/firmware.bin" \ + "$BUILD/firmware.elf" "$OUT/" +cp "$BOOT_APP0" "$OUT/boot_app0.bin" +"$ESPTOOL" --chip esp32 merge-bin -o "$OUT/firmware-full.bin" \ + --flash-mode dio --flash-freq 40m --flash-size 4MB \ + 0x1000 "$OUT/bootloader.bin" 0x8000 "$OUT/partitions.bin" \ + 0xe000 "$OUT/boot_app0.bin" 0x10000 "$OUT/firmware.bin" +( + cd "$OUT" + sha256sum bootloader.bin partitions.bin boot_app0.bin firmware.bin \ + firmware-full.bin firmware.elf > SHA256SUMS +) +cat > "$OUT/BUILD-INFO.txt" <<'EOF' +Wersja: 2.0.0-rc.1 (release candidate, bez HIL) +PlatformIO: 6.1.18 +Platforma: espressif32 8.0.0 +CC1101: de6757ef633b3e626dae5c7835cdb66ab53f9a1d +Adresy: 0x1000 bootloader, 0x8000 partitions, 0xe000 boot_app0, 0x10000 firmware +Pelny obraz firmware-full.bin: flash od 0x0. +EOF +cat "$OUT/BUILD-INFO.txt" +cat "$OUT/SHA256SUMS" diff --git a/tools/requirements.txt b/tools/requirements.txt new file mode 100644 index 0000000..d8f80db --- /dev/null +++ b/tools/requirements.txt @@ -0,0 +1,22 @@ +ajsonrpc==1.2.0 +anyio==4.15.1 +bottle==0.13.4 +certifi==2026.10.23 +charset-normalizer==3.5.2 +click==8.1.7 +colorama==0.4.6 +h11==0.16.0 +idna==3.20 +marshmallow==3.26.2 +packaging==26.3 +platformio==6.1.18 +pyelftools==0.33 +pyserial==3.5 +requests==2.34.2 +semantic-version==2.10.0 +starlette==0.46.2 +tabulate==0.10.0 +typing_extensions==4.16.0 +urllib3==2.8.0 +uvicorn==0.34.3 +wsproto==1.3.2