From a18da380a10af9a3c1d5ae5411f5ac22a56461eb Mon Sep 17 00:00:00 2001 From: D-Antonelli Date: Mon, 19 Aug 2024 15:18:39 +0100 Subject: [PATCH] updates main.yml --- .github/workflows/main.yml | 90 +++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0adc029..950018e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,14 +4,60 @@ on: [push] jobs: - build_and_test: + # Job for installing dependencies and linting code + Lint: runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 5 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Cache Node.js modules + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install dependencies + run: npm ci + + - name: Code linting + run: npm run lint + + # Job for building and running tests + End-to-end-Tests: + runs-on: ubuntu-latest + timeout-minutes: 10 steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Cache Node.js modules + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies + run: npm ci + + - name: Build the project + run: npm run build + - name: Cypress run uses: cypress-io/github-action@v6 env: @@ -23,10 +69,10 @@ jobs: GOOGLE_CLIENT_ID: ${{secrets.GOOGLE_CLIENT_ID}} GOOGLE_CLIENT_SECRET: ${{secrets.GOOGLE_CLIENT_SECRET}} with: - build: npm run build - start: npm start - spec: | - cypress/e2e/*.cy.ts + build: npm run build + start: npm start + spec: | + cypress/e2e/*.cy.ts - name: Install Playwright Browsers run: npx playwright install --with-deps @@ -34,20 +80,42 @@ jobs: - name: Run Playwright tests run: npx playwright test - - uses: actions/upload-artifact@v4 + - name: Upload Playwright Report if: always() + uses: actions/upload-artifact@v4 with: name: playwright-report path: playwright-report/ retention-days: 30 - - name: Code linting - run: npm run lint + # Job for running unit tests and uploading coverage report + Unit-Tests: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Cache Node.js modules + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies + run: npm ci - - name: Run tests and collect coverage + - name: Run unit tests run: npm run test - name: Upload coverage to Codecov uses: codecov/codecov-action@v4.0.1 with: - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file