From 81a9eb068a3e0c907392dff406ec25a626d17c5c Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Tue, 29 Jul 2025 21:03:14 +0300 Subject: [PATCH] ops(tests workflow): Cache browsers on GitHub --- .github/workflows/tests.yml | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index eaf3144..88737fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,16 +46,43 @@ jobs: pyproject.toml tox.ini - # Install browsers ONCE at the workflow level - - name: Install browser dependencies + - name: Install all browsers dependencies run: | python3 -m pip install --upgrade pip python3 -m pip install playwright==1.52.0 rebrowser-playwright==1.52.0 camoufox - - name: Install browsers + - name: Retrieve Playwright browsers from cache if any + id: playwright-cache + uses: actions/cache@v4 + with: + path: | + ~/.cache/ms-playwright + ~/Library/Caches/ms-playwright + ~/.ms-playwright + key: ${{ runner.os }}-playwright-${{ hashFiles('pyproject.toml') }} + restore-keys: | + ${{ runner.os }}-playwright- + + - name: Install Playwright browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' run: | python3 -m playwright install chromium python3 -m playwright install-deps chromium firefox + + - name: Retrieve Camoufox browser from cache if any + id: camoufox-cache + uses: actions/cache@v4 + with: + path: | + ~/.cache/camoufox + ~/Library/Caches/camoufox + key: ${{ runner.os }}-camoufox-${{ hashFiles('pyproject.toml') }} + restore-keys: | + ${{ runner.os }}-camoufox- + + - name: Install Camoufox browser + if: steps.camoufox-cache.outputs.cache-hit != 'true' + run: | python3 -m camoufox fetch --browserforge # Cache tox environments