From 480d8277cc13219a570e71c2134cf19b4ef98eb4 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Fri, 29 Mar 2024 17:30:55 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F(CI)=20persist=20the=20fronte?= =?UTF-8?q?nd=20between=20jobs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To improve the speed of the CI, we cache the frontend install. It will even be reused between pull request until the yarn.lock has a change. We cache as well the desk build app, in another cache, this cache persist only per workflow. It will increase the speed if we have e2e flaky tests and that we have to relaunch the e2e job. --- .github/workflows/people.yml | 105 +++++++++++++++++++++++------------ 1 file changed, 71 insertions(+), 34 deletions(-) diff --git a/.github/workflows/people.yml b/.github/workflows/people.yml index 6fbf244..47bd8d7 100644 --- a/.github/workflows/people.yml +++ b/.github/workflows/people.yml @@ -58,11 +58,9 @@ jobs: exit 1 fi - test-front: + install-front: runs-on: ubuntu-latest - defaults: - run: - working-directory: src/frontend/ + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -71,40 +69,85 @@ jobs: uses: actions/setup-node@v4 with: node-version: '18.x' - cache: 'yarn' - cache-dependency-path: src/frontend/yarn.lock + + - name: Restore the frontend cache + uses: actions/cache@v3 + id: cache-install + with: + path: src/frontend/ + key: install-front-${{ hashFiles('src/frontend/**/yarn.lock') }} - name: Install dependencies - run: yarn install --frozen-lockfile + if: steps.cache-install.outputs.cache-hit != 'true' + run: cd src/frontend/ && yarn install --frozen-lockfile + + - name: Cache install frontend + if: steps.cache-install.outputs.cache-hit != 'true' + uses: actions/cache@v3 + with: + path: src/frontend/ + key: install-front-${{ hashFiles('src/frontend/**/yarn.lock') }} + + build-front: + runs-on: ubuntu-latest + needs: install-front + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Restore the frontend cache + uses: actions/cache@v3 + id: cache-install + with: + path: src/frontend/ + key: install-front-${{ hashFiles('src/frontend/**/yarn.lock') }} + + - name: Build CI App + run: cd src/frontend/ && yarn ci:build + + - name: Cache build frontend + uses: actions/cache@v3 + with: + path: src/frontend/ + key: build-front-${{ github.run_id }} + + test-front: + runs-on: ubuntu-latest + needs: install-front + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Restore the frontend cache + uses: actions/cache@v3 + id: cache-install + with: + path: src/frontend/ + key: install-front-${{ hashFiles('src/frontend/**/yarn.lock') }} - name: Test App - run: yarn app:test + run: cd src/frontend/ && yarn app:test lint-front: runs-on: ubuntu-latest - defaults: - run: - working-directory: src/frontend/ + needs: install-front steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: Restore the frontend cache + uses: actions/cache@v3 + id: cache-install with: - node-version: '18.x' - cache: 'yarn' - cache-dependency-path: src/frontend/yarn.lock - - - name: Install dependencies - run: yarn install --frozen-lockfile + path: src/frontend/ + key: install-front-${{ hashFiles('src/frontend/**/yarn.lock') }} - name: Check linting - run: yarn lint + run: cd src/frontend/ && yarn lint test-e2e: runs-on: ubuntu-latest - needs: build-mails + needs: [build-mails, build-front] timeout-minutes: 10 steps: - name: Checkout repository @@ -120,6 +163,13 @@ jobs: with: name: mails-templates path: src/backend/core/templates/mail + + - name: Restore the build cache + uses: actions/cache@v3 + id: cache-build + with: + path: src/frontend/ + key: build-front-${{ github.run_id }} - name: Build and Start Docker Servers env: @@ -137,22 +187,9 @@ jobs: run: | make demo FLUSH_ARGS='--no-input' - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '18.x' - cache: 'yarn' - cache-dependency-path: src/frontend/yarn.lock - - - name: Install dependencies - run: cd src/frontend/ && yarn install --frozen-lockfile - - name: Install Playwright Browsers run: cd src/frontend/apps/e2e && yarn install - - name: Build CI App - run: cd src/frontend/ && yarn ci:build - - name: Run e2e tests run: cd src/frontend/ && yarn e2e:test