From a3358e298359bf7824e313cae819e70366e44fcd Mon Sep 17 00:00:00 2001 From: Zaid-maker Date: Thu, 21 Nov 2024 15:47:08 +0500 Subject: [PATCH] improve workflow --- .github/workflows/auto-test.yml | 93 ++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 31 deletions(-) diff --git a/.github/workflows/auto-test.yml b/.github/workflows/auto-test.yml index bf76d9eb6..403b48866 100644 --- a/.github/workflows/auto-test.yml +++ b/.github/workflows/auto-test.yml @@ -1,6 +1,3 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - name: Auto Test on: @@ -14,7 +11,19 @@ on: - '*.md' jobs: - auto-test: + check-linters: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - run: npm install + - run: npm run lint:prod + + test: needs: [ check-linters ] runs-on: ${{ matrix.os }} timeout-minutes: 15 @@ -23,23 +32,41 @@ jobs: matrix: os: [macos-latest, ubuntu-latest, windows-latest, ARM64] node: [ 18, 20 ] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - run: git config --global core.autocrlf false # Mainly for Windows - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - - run: npm install - - run: npm run build - - run: npm run test-backend + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Build project + run: npm run build + + - name: Run backend tests + run: npm run test-backend env: HEADLESS_TEST: 1 JUST_FOR_TEST: ${{ secrets.JUST_FOR_TEST }} + - name: Run component tests + run: npm run test-component + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v3 + with: + name: test-results-${{ matrix.os }}-node-${{ matrix.node }} + path: | + ./test-results + ./coverage + retention-days: 30 + # As a lot of dev dependencies are not supported on ARMv7, we have to test it separately and just test if `npm ci --production` works armv7-simple-test: needs: [ ] @@ -50,44 +77,48 @@ jobs: matrix: os: [ ARMv7 ] node: [ 18, 20 ] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - run: git config --global core.autocrlf false # Mainly for Windows - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} + cache: 'npm' - run: npm ci --production - check-linters: - runs-on: ubuntu-latest - - steps: - - run: git config --global core.autocrlf false # Mainly for Windows - - uses: actions/checkout@v4 - - - name: Use Node.js 20 - uses: actions/setup-node@v4 - with: - node-version: 20 - - run: npm install - - run: npm run lint:prod - e2e-test: - needs: [ ] + needs: [ check-linters ] runs-on: ARM64 + timeout-minutes: 30 steps: - - run: git config --global core.autocrlf false # Mainly for Windows - uses: actions/checkout@v4 - name: Use Node.js 20 uses: actions/setup-node@v4 with: node-version: 20 - - run: npm install - - run: npx playwright install - - run: npm run build - - run: npm run test-e2e + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Install Playwright browsers + run: npx playwright install --with-deps chromium firefox + + - name: Build project + run: npm run build + + - name: Run E2E tests + run: npm run test-e2e + env: + HEADLESS_TEST: 1 + + - name: Upload Playwright report + if: always() + uses: actions/upload-artifact@v3 + with: + name: playwright-report + path: ./private/playwright-report + retention-days: 30