From 1bcedb04836e04788ee9e9dd4230da577601d97f Mon Sep 17 00:00:00 2001 From: copilotcoder Date: Tue, 26 May 2026 21:19:55 -0400 Subject: [PATCH] Attempting performance improvements for the CICD. Signed-off-by: copilotcoder --- .gitea/workflows/cicd.yml | 81 ++++++++++++++++++++++----------------- Dockerfile.cicd-base | 9 ++--- 2 files changed, 49 insertions(+), 41 deletions(-) diff --git a/.gitea/workflows/cicd.yml b/.gitea/workflows/cicd.yml index e920c8f..c0bf116 100644 --- a/.gitea/workflows/cicd.yml +++ b/.gitea/workflows/cicd.yml @@ -349,9 +349,17 @@ jobs: - &login_registry_step name: Login to Gitea Container Registry run: echo "${{ secrets.PACKAGE_ACCESS_TOKEN }}" | docker login "http://${GITEA_REGISTRY}" -u ${{ github.actor }} --password-stdin + - &ensure_cicd_image_step + name: Ensure CICD image is available + run: | + IMAGE="${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" + if docker image inspect "${IMAGE}" >/dev/null 2>&1; then + echo "Using cached CICD image: ${IMAGE}" + else + docker pull "${IMAGE}" + fi - name: Check trailing whitespace with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run trailing-whitespace --all-files --show-diff-on-failure @@ -364,9 +372,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Check end of file with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run end-of-file-fixer --all-files --show-diff-on-failure @@ -379,9 +387,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Check YAML files with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run check-yaml --all-files --show-diff-on-failure @@ -394,9 +402,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Check TOML files with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run check-toml --all-files --show-diff-on-failure @@ -409,9 +417,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Check line endings with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run mixed-line-ending --all-files --show-diff-on-failure @@ -444,22 +452,27 @@ jobs: - name: Check TOML formatting with pre-commit run: | echo "=== Network-Resilient Docker Operations ===" + IMAGE="${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" - # Resilient docker pull with retries - for i in 1 2 3; do - echo "Docker pull attempt $i/3..." - if timeout 300 docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}"; then - echo "✓ Docker pull successful" - break - else - if [ $i -eq 3 ]; then - echo "❌ All docker pull attempts failed" - exit 1 + if docker image inspect "${IMAGE}" >/dev/null 2>&1; then + echo "Using cached CICD image: ${IMAGE}" + else + # Resilient docker pull with retries + for i in 1 2 3; do + echo "Docker pull attempt $i/3..." + if timeout 300 docker pull "${IMAGE}"; then + echo "✓ Docker pull successful" + break + else + if [ $i -eq 3 ]; then + echo "❌ All docker pull attempts failed" + exit 1 + fi + echo "⚠ Docker pull attempt $i failed, waiting 20s before retry..." + sleep 20 fi - echo "⚠ Docker pull attempt $i failed, waiting 20s before retry..." - sleep 20 - fi - done + done + fi # Run the actual test docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " @@ -475,9 +488,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Run ruff linting with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run ruff --all-files --show-diff-on-failure @@ -490,9 +503,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Check ruff formatting with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run ruff-format --all-files --show-diff-on-failure @@ -505,9 +518,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Run pyright type checking with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run pyright --all-files --show-diff-on-failure @@ -520,9 +533,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Run darglint docstring linting with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run darglint --all-files --show-diff-on-failure @@ -535,9 +548,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Run no docstring types check with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run no-docstring-types --all-files --show-diff-on-failure @@ -551,9 +564,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Run ESLint with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run eslint --all-files --show-diff-on-failure @@ -566,9 +579,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Check Prettier formatting with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run prettier --all-files --show-diff-on-failure @@ -581,9 +594,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Run TypeScript type checking with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run typescript-check --all-files --show-diff-on-failure @@ -596,9 +609,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Run TSDoc linting with pre-commit run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace && pre-commit run tsdoc-lint --all-files --show-diff-on-failure @@ -612,9 +625,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Run backend tests with coverage run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace/backend && source .venv/bin/activate && @@ -628,9 +641,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Run frontend tests with coverage run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace/frontend && yarn test:coverage --run --reporter=verbose --coverage.reporter=text --coverage.reporter=text-summary --coverage.thresholds.lines=85 --coverage.thresholds.functions=85 --coverage.thresholds.branches=85 --coverage.thresholds.statements=85 @@ -644,9 +657,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Run backend doctests run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace/backend && source .venv/bin/activate && @@ -670,9 +683,9 @@ jobs: steps: - *configure_registry_host_step - *login_registry_step + - *ensure_cicd_image_step - name: Run integration tests run: | - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace/backend && source .venv/bin/activate && @@ -690,13 +703,11 @@ jobs: steps: - *configure_registry_host_step - *resilient_login_registry_step + - *ensure_cicd_image_step - name: Run E2E tests run: | echo "=== Network-Resilient E2E Test Execution ===" - # Use the same simple approach as all other successful tests - docker pull "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" - # Run E2E tests with network resilience docker run --rm -e CI=true "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${GITHUB_SHA:-latest}" bash -c " cd /workspace/frontend && diff --git a/Dockerfile.cicd-base b/Dockerfile.cicd-base index f9fa669..c240f45 100644 --- a/Dockerfile.cicd-base +++ b/Dockerfile.cicd-base @@ -114,7 +114,7 @@ RUN set -eu && \ RUN echo "=== Installing Global Development Tools ===" && \ # Use npm for global installations (works better than yarn global in Berry) npm install -g \ - @playwright/test@1.40.0 \ + @playwright/test@1.56.1 \ typescript@5.3.3 \ eslint@9.33.0 \ prettier@3.3.3 \ @@ -132,11 +132,8 @@ RUN echo "=== Installing Global Development Tools ===" && \ RUN echo "=== Installing Playwright Browsers ===" && \ # Verify Playwright CLI is available playwright --version && \ - # Install browsers with system dependencies (non-interactive) - export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=0 && \ - playwright install --with-deps chromium firefox webkit && \ - # Install system dependencies for browsers - playwright install-deps && \ + # Only install chromium — CI playwright.config.ts only uses chromium + playwright install --with-deps chromium && \ echo "✓ Playwright browsers installed and cached in base image" # Pre-install common Python development dependencies globally