Skip to content

feature flag cache (#1176) #452

feature flag cache (#1176)

feature flag cache (#1176) #452

Workflow file for this run

# Workflow for running E2E tests for PRs and pushes to the main branch for
# napari hub frontend code.
name: E2E Tests
on:
push:
branches:
- main
paths:
- 'frontend/**'
pull_request:
branches:
- '**'
paths:
- 'frontend/**'
defaults:
run:
working-directory: frontend/
jobs:
e2e-setup:
name: E2E Setup
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
# cache both yarn-lock and node_modules
- name: Setup Yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: |
**/node_modules
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# --prefer-offline forces yarn to use cache if available
- name: Install dependencies with yarn
# if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --prefer-offline --frozen-lockfile
- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: playwright-${{ hashFiles('**/yarn.lock') }}
- name: Install playwright
# if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Cache prod build
uses: actions/cache@v3
id: prod-build-cache
with:
path: frontend/.next
key: prod-build-${{ hashFiles('**/next.config.js') }}-${{ hashFiles('frontend/src') }}-${{ hashFiles('**/yarn.lock') }}
- name: Build for production
# if: steps.prod-build-cache.outputs.cache-hit != 'true'
run: yarn build
e2e:
# name: E2E tests ${{ matrix.browser }}
name: E2E tests ${{ matrix.browser }} ${{ matrix.shardCurrent }} / ${{ matrix.shardTotal }}
runs-on: ubuntu-latest
needs: e2e-setup
concurrency:
group: ${{ github.ref }}-${{ matrix.browser }}-${{ matrix.shardCurrent }}-${{ matrix.shardTotal }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
# browser: [chrome, firefox, safari]
browser: [chrome]
shardCurrent: [1, 2, 3, 4, 5]
shardTotal: [5]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
# cache both yarn-lock and node_modules
- name: Load yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: |
**/node_modules
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Load cached playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: playwright-${{ hashFiles('**/yarn.lock') }}
- name: Load cached prod build
uses: actions/cache@v3
id: prod-build-cache
with:
path: frontend/.next
key: prod-build-${{ hashFiles('**/next.config.js') }}-${{ hashFiles('frontend/src') }}-${{ hashFiles('**/yarn.lock') }}
- name: Start mock server on port 8081
run: yarn dev:api &
- name: Start server on port 8080
run: yarn start &
env:
E2E: true
- name: Run E2E Tests
env:
CI: true
BROWSER: ${{ matrix.browser }}
run: yarn e2e:ci --shard ${{ matrix.shardCurrent }}/${{ matrix.shardTotal }}
- name: Upload artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v3.1.1
with:
name: e2e-artifacts
path: frontend/e2e/report
retention-days: 1