From e755f440ae2bf47a16d6b487730519ca6c4db00c Mon Sep 17 00:00:00 2001 From: Lucas Rayan Date: Fri, 23 Oct 2026 09:40:11 -0300 Subject: [PATCH] =?UTF-8?q?CI:=20depend=C3=AAncias=20do=20Tauri=20com=20ca?= =?UTF-8?q?che=20de=20.deb,=20tempo=20limite=20e=20nova=20tentativa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit O passo do apt levou 22 e 28 minutos em duas execuções de um dia de espelho lento (o normal é uns 35 s). O script usa os .deb em cache sem nem atualizar o índice e, sem cache, tenta até 3 vezes com tempo limite por tentativa. Vale para o CI e para o job do app desktop da release. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/ci.yml | 10 +++++++--- .github/workflows/release.yml | 11 ++++++++--- scripts/install-tauri-deps.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 6 deletions(-) create mode 100755 scripts/install-tauri-deps.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 132fac5..1531db2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,10 +85,14 @@ jobs: - uses: actions/setup-node@v7 with: node-version: 22 + - name: Cache dos pacotes do Tauri (.deb) + uses: actions/cache@v6 + with: + path: ~/apt-cache + key: apt-tauri-${{ runner.os }}-${{ runner.arch }}-${{ env.ImageVersion }}-${{ hashFiles('scripts/install-tauri-deps.sh') }} - name: Dependências do Tauri - run: | - sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf + timeout-minutes: 25 + run: scripts/install-tauri-deps.sh - name: Gera os ícones run: npx --yes @tauri-apps/cli@2 icon apps/gui/src-tauri/icons/source.png -o apps/gui/src-tauri/icons - run: cargo check --manifest-path apps/gui/src-tauri/Cargo.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fc62acd..50637c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -106,11 +106,16 @@ jobs: - uses: actions/setup-node@v7 with: node-version: 22 + - name: Cache dos pacotes do Tauri (.deb) + if: runner.os == 'Linux' + uses: actions/cache@v6 + with: + path: ~/apt-cache + key: apt-tauri-${{ runner.os }}-${{ runner.arch }}-${{ env.ImageVersion }}-${{ hashFiles('scripts/install-tauri-deps.sh') }} - name: Dependências do Tauri (Linux) if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf + timeout-minutes: 25 + run: scripts/install-tauri-deps.sh - name: Gera os ícones run: npx --yes @tauri-apps/cli@2 icon apps/gui/src-tauri/icons/source.png -o apps/gui/src-tauri/icons - uses: tauri-apps/tauri-action@v1 diff --git a/scripts/install-tauri-deps.sh b/scripts/install-tauri-deps.sh new file mode 100755 index 0000000..de865d7 --- /dev/null +++ b/scripts/install-tauri-deps.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Instala as bibliotecas do Tauri no Linux do CI (WebKitGTK e afins) sem depender do espelho do +# apt estar rápido: usa os .deb em cache quando existem e, se o apt travar ou falhar, tenta de novo. +# +# O passo "Dependências do Tauri" já levou de 22 a 28 minutos num dia de espelho lento, contra +# uns 35 s no normal. Aqui cada tentativa tem tempo limite e o cache evita o download. +# +# Uso: scripts/install-tauri-deps.sh [pasta-do-cache] (padrão: ~/apt-cache) +set -euo pipefail +cache="${1:-$HOME/apt-cache}" +pkgs=(libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf) +mkdir -p "$cache/partial" + +# 1) tudo em cache: instala direto, sem nem atualizar o índice do apt +if ls "$cache"/*.deb >/dev/null 2>&1 && timeout 300 sudo apt-get -o "Dir::Cache::archives=$cache" -y install "${pkgs[@]}"; then + echo "instalado a partir do cache" + exit 0 +fi + +# 2) sem cache (ou incompleto): atualiza e instala, até 3 tentativas com tempo limite +for tentativa in 1 2 3; do + if timeout 240 sudo apt-get update && timeout 600 sudo apt-get -o "Dir::Cache::archives=$cache" -y install "${pkgs[@]}"; then + echo "instalado (tentativa $tentativa)" + exit 0 + fi + echo "apt falhou ou passou do tempo (tentativa $tentativa de 3)" >&2 + sleep $((tentativa * 10)) +done +echo "não foi possível instalar as dependências do Tauri" >&2 +exit 1