From 5ae3ebeceed7bb3b3fa0185c01f724e674027e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoni=20Nu=C3=B1ez=20Romeu?= Date: Mon, 13 Jul 2026 21:16:46 +0200 Subject: [PATCH] ci: consolidate test jobs into single workflow with npm caching - Merge 3 parallel test jobs (backend/frontend/mobile) into one sequential job - Remove dependency on dorny/paths-filter@v3 (replaced with git diff script) - Add npm cache via setup-node to speed up dependency installation - Downgrade Node.js from 24 to 22 LTS for stability - Reduce checkout fetch-depth from full history to 2 commits --- .gitea/workflows/docker.yaml | 4 +- .gitea/workflows/test-branches.yaml | 80 +++++++---------------------- 2 files changed, 20 insertions(+), 64 deletions(-) diff --git a/.gitea/workflows/docker.yaml b/.gitea/workflows/docker.yaml index 1897f53..92670ae 100644 --- a/.gitea/workflows/docker.yaml +++ b/.gitea/workflows/docker.yaml @@ -36,7 +36,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '24' + node-version: '22' cache: 'npm' - name: Install dependencies run: npm ci @@ -53,7 +53,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '24' + node-version: '22' cache: 'npm' - name: Install dependencies run: npm ci diff --git a/.gitea/workflows/test-branches.yaml b/.gitea/workflows/test-branches.yaml index 3076f30..9bfbf3f 100644 --- a/.gitea/workflows/test-branches.yaml +++ b/.gitea/workflows/test-branches.yaml @@ -6,86 +6,42 @@ on: - 'main' jobs: - detect-changes: - name: Detect Changes - runs-on: ubuntu-latest - outputs: - backend: ${{ steps.filter.outputs.backend }} - frontend: ${{ steps.filter.outputs.frontend }} - frontend-mobile: ${{ steps.filter.outputs.frontend-mobile }} - steps: - - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: filter - with: - filters: | - backend: - - 'apps/backend/**' - - 'packages/**' - frontend: - - 'apps/frontend/**' - - 'packages/**' - frontend-mobile: - - 'apps/frontend-mobile/**' - - 'packages/**' - - test-backend: - name: Backend Tests - needs: detect-changes - if: needs.detect-changes.outputs.backend == 'true' + test: + name: Run Tests runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Detect Changes + id: changes + run: | + BASE=${{ github.event.before }} + [ -z "$BASE" ] || [ "$BASE" = "0000000000000000000000000000000000000000" ] && BASE=$(git rev-parse HEAD~1) + echo "backend=$(git diff --name-only "$BASE"...HEAD | grep -qE '^(apps/backend/|packages/)' && echo true || echo false)" >> "$GITHUB_OUTPUT" + echo "frontend=$(git diff --name-only "$BASE"...HEAD | grep -qE '^(apps/frontend/|packages/)' && echo true || echo false)" >> "$GITHUB_OUTPUT" + echo "frontend-mobile=$(git diff --name-only "$BASE"...HEAD | grep -qE '^(apps/frontend-mobile/|packages/)' && echo true || echo false)" >> "$GITHUB_OUTPUT" - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '24' + node-version: '22' + cache: 'npm' - name: Install Dependencies run: npm ci - name: Run Backend Tests + if: steps.changes.outputs.backend == 'true' run: npm test --workspace=farma-clic-backend -- --ci - test-frontend: - name: Frontend Tests - needs: detect-changes - if: needs.detect-changes.outputs.frontend == 'true' - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '24' - - - name: Install Dependencies - run: npm ci - - name: Run Frontend Tests + if: steps.changes.outputs.frontend == 'true' run: npm test --workspace=farma-clic-frontend -- --run --reporter=basic - test-frontend-mobile: - name: Frontend Mobile Tests - needs: detect-changes - if: needs.detect-changes.outputs.frontend-mobile == 'true' - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '24' - - - name: Install Dependencies - run: npm ci - - name: Run Frontend Mobile Tests + if: steps.changes.outputs.frontend-mobile == 'true' run: npm test --workspace=frontend-mobile -- --ci continue-on-error: true