ci: cache de build compartilhado e compilação em paralelo
Compilar exemplos / esp32c2 (push) Failing after 7m16s
Compilar exemplos / esp32 (push) Failing after 3h10m42s
Compilar exemplos / esp32c3 (push) Failing after 9m42s
Compilar exemplos / esp32c5 (push) Failing after 1h51m31s
Compilar exemplos / esp32c6 (push) Failing after 14m41s
Compilar exemplos / esp32c61 (push) Failing after 9m54s
Compilar exemplos / esp32h2 (push) Failing after 1h32m45s
Compilar exemplos / esp32p4 (push) Failing after 5m42s
Compilar exemplos / esp32s2 (push) Successful in 1h19m10s
Compilar exemplos / esp32s3 (push) Failing after 3h14m50s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-10 12:32:57 -03:00
1 parent 5f5506c55c
commit f14904feca
2 files changed
+52 -17

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
"""Compila todos os projetos de uma série. Uso: compilar.py <série> [workers]
Cada worker copia o projeto para uma pasta fixa antes de compilar: com o mesmo
caminho, os objetos do framework batem no cache de build compartilhado
(PLATFORMIO_BUILD_CACHE_DIR) e só recompilam quando o sdkconfig muda.
"""
import glob, os, queue, shutil, subprocess, sys, threading, time
serie = sys.argv[1]
n = int(sys.argv[2]) if len(sys.argv) > 2 else os.cpu_count()
pio = os.environ.get("PIO", os.path.expanduser("~/pio-venv/bin/pio"))
projetos = sorted(os.path.dirname(p) for p in glob.glob("capitulo-*/*/platformio.ini")
if f"[env:{serie}]" in open(p).read())
fila = queue.Queue()
for p in projetos:
fila.put(p)
falhas, lock = [], threading.Lock()
def worker(i):
base = f"/tmp/obra/{i}"
while True:
try:
proj = fila.get_nowait()
except queue.Empty:
return
shutil.rmtree(base, ignore_errors=True)
shutil.copytree(proj, base)
t = time.time()
r = subprocess.run([pio, "run", "-s", "-d", base, "-e", serie],
capture_output=True, text=True)
with lock:
print(f"{'OK ' if r.returncode == 0 else 'FALHA'} {proj} ({time.time() - t:.0f} s)", flush=True)
if r.returncode:
falhas.append((proj, (r.stdout + r.stderr)[-4000:]))
ts = [threading.Thread(target=worker, args=(i,)) for i in range(n)]
[t.start() for t in ts]
[t.join() for t in ts]
for proj, log in falhas:
print(f"\n===== {proj} =====\n{log}")
print(f"\n{len(projetos) - len(falhas)}/{len(projetos)} compilações OK em {serie} ({n} workers)")
sys.exit(1 if falhas else 0)
+7 -17
View File
@@ -16,7 +16,7 @@ jobs:
compilar:
name: ${{ matrix.serie }}
runs-on: ubuntu-latest
timeout-minutes: 300
timeout-minutes: 360
strategy:
fail-fast: false
matrix:
@@ -25,26 +25,16 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.platformio
key: pio-${{ runner.arch }}-${{ matrix.serie }}-${{ hashFiles('**/platformio.ini') }}
path: |
~/.platformio
~/pio-cache
key: pio-${{ runner.arch }}-${{ matrix.serie }}-${{ github.sha }}
restore-keys: pio-${{ runner.arch }}-${{ matrix.serie }}-
- name: Instalar o PlatformIO
run: |
python3 -m venv ~/pio-venv
~/pio-venv/bin/pip install -q platformio
- name: Compilar
env:
SERIE: ${{ matrix.serie }}
run: |
falhas=0; total=0
for ini in $(grep -l "^\[env:${SERIE}\]" capitulo-*/*/platformio.ini | sort); do
d=$(dirname "$ini"); total=$((total+1))
if ~/pio-venv/bin/pio run -s -d "$d" -e "$SERIE" > log.txt 2>&1; then
echo "OK $d"
else
echo "FALHA $d"; tail -60 log.txt; falhas=$((falhas+1))
fi
rm -rf "$d/.pio"
done
echo "$((total-falhas))/$total compilações OK em $SERIE"
test "$falhas" -eq 0
echo "CPUs: $(nproc)"
PLATFORMIO_BUILD_CACHE_DIR=$HOME/pio-cache python3 .gitea/scripts/compilar.py ${{ matrix.serie }} $(nproc)