diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index fae0e974fd..93fc97dfaa 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -3,6 +3,8 @@ on: workflow_dispatch: pull_request: branches: [develop] +env: + WAIT_ON_VERSION: '7' jobs: test-e2e: environment: e2e-tests @@ -16,7 +18,7 @@ jobs: - name: Set up node uses: actions/setup-node@v4 with: - node-version: '18.20.x' + node-version-file: '.nvmrc' cache: 'npm' - name: Create .env file @@ -27,7 +29,15 @@ jobs: with: mongodb-version: '6.0' + - name: Cache node_modules + uses: actions/cache@v4 + id: node-modules-cache + with: + path: node_modules + key: node-modules-${{ runner.os }}-node-${{ hashFiles('.nvmrc') }}-${{ hashFiles('package-lock.json') }} + - name: Install dependencies + if: steps.node-modules-cache.outputs.cache-hit != 'true' run: npm ci - name: Cache Playwright browsers @@ -45,13 +55,24 @@ jobs: if: steps.playwright-cache.outputs.cache-hit == 'true' run: npx playwright install-deps chromium + - name: Cache wait-on + uses: actions/cache@v4 + id: wait-on-cache + with: + path: ~/.npm/_npx + key: npx-wait-on-${{ env.WAIT_ON_VERSION }}-${{ runner.os }} + + - name: Install wait-on + if: steps.wait-on-cache.outputs.cache-hit != 'true' + run: npx -y wait-on@$WAIT_ON_VERSION --version + - name: Start app run: npm run start:e2e > app.log 2>&1 & - name: Wait for app to be ready run: | - npx wait-on@7 http://localhost:9000 --timeout 180000 || { - echo "::error::App failed to become ready at http://localhost:9000 within 180s" + npx wait-on@$WAIT_ON_VERSION http://localhost:8000 --timeout 180000 || { + echo "::error::App failed to become ready at http://localhost:8000 within 180s" echo "----- app.log -----" cat app.log exit 1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a39783065..494de973d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,12 +7,29 @@ jobs: name: Test and lint code base runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up node + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Create .env file + run: cp .env.example .env + + - name: Cache node_modules + uses: actions/cache@v4 + id: node-modules-cache with: - node-version: '18.20.x' - - run: npm install + path: node_modules + key: node-modules-${{ runner.os }}-node-${{ hashFiles('.nvmrc') }}-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies + if: steps.node-modules-cache.outputs.cache-hit != 'true' + run: npm ci + - run: npm run test - run: npm run typecheck - run: npm run lint