Skip to content

Commit

Permalink
feat: e2e support (#94)
Browse files Browse the repository at this point in the history
Co-authored-by: murashkin.i <[email protected]>
  • Loading branch information
lotyp and murashkin.i authored Mar 4, 2023
1 parent 2b9b0aa commit 67318e6
Show file tree
Hide file tree
Showing 24 changed files with 566 additions and 1,789 deletions.
55 changes: 55 additions & 0 deletions .github/actions/playwright-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: 🎭 Playwright install
description: 'Installs the playwright with deps'
inputs:
playwright-cache-folder:
description: 'Set playwright cache folder'
required: false
default: '~/.cache/ms-playwright'
cache-prefix:
description: 'Used to invalidate cache in case of issue'
required: false
default: '2023.03'
browsers:
description: 'Set browsers to install (ie: "chromium webkit")'
required: false
default: 'chromium webkit'

runs:
using: 'composite'
steps:
- name: 📜 Expose playwright config
id: playwright-config
shell: bash
run: |
echo "CURRENT_VERSION=$(npm info @playwright/test version)" >> $GITHUB_OUTPUT
echo "CACHE_KEY=$(npm info @playwright/test version)" >> $GITHUB_OUTPUT
- name: 🤖 Compute cache config
id: playwright-cache-config
shell: bash
run: |
echo "CACHE_KEY=${{ runner.os }}-playwright-cache-${{ inputs.cache-prefix }}-${{ steps.playwright-config.outputs.CURRENT_VERSION }}" >> $GITHUB_OUTPUT
- name: 📥 Restore playwright install
uses: actions/cache@v3
id: playwright-cache
with:
path: |
${{ inputs.playwright-cache-folder }}
key: ${{ steps.playwright-cache-config.outputs.CACHE_KEY }}

- name: 🚀 Playwright debug
shell: bash
run: |
echo "OS: ${{ matrix.os }}"
echo "Playwright version: ${{ steps.playwright-version.outputs.version }}"
echo "Playwright cache folder: ${{ inputs.playwright-cache-folder }}"
echo "Browsers: ${{ inputs.browsers }}"
echo "Cache key: ${{ steps.playwright-cache-config.outputs.CACHE_KEY }}"
echo "Cache hit: ${{ steps.playwright-cache.outputs.cache-hit == 'true' }}"
- name: 📦 Install playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash
run: npx playwright install chromium webkit
2 changes: 1 addition & 1 deletion .github/actions/pnpm-install/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: 'Monorepo install (pnpm)'
name: Monorepo install (pnpm)
description: 'Run pnpm install'

runs:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci-apps-docs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: CI for Docs App
name: CI for docs app

on: # yamllint disable-line rule:truthy
push:
Expand Down Expand Up @@ -40,12 +40,12 @@ jobs:
node: ['18']

steps:
- name: Check out the codebase
- name: 📦 Check out the codebase
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup node ${{ matrix.node }}
- name: ⚙️ Setup node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
Expand All @@ -55,7 +55,7 @@ jobs:
uses: ./.github/actions/pnpm-install

# see https://github.com/vercel/next.js/pull/27362
- name: Restore "web" app build from cache
- name: ♻️ Restore "docs" app build from cache
uses: actions/cache@v3
with:
path: |
Expand All @@ -66,17 +66,17 @@ jobs:
restore-keys: |
${{ runner.os }}-web-${{ hashFiles('pnpm*.yaml') }}-
- name: Typecheck
- name: 📝 Typecheck
working-directory: apps/web
run: |
pnpm lint:types
- name: Linter
- name: 🚨 Linter
working-directory: apps/web
run: |
pnpm lint
- name: Build docs-app
- name: 🏗 Build docs-app
working-directory: apps/web
run: |
pnpm --filter=docs build
18 changes: 9 additions & 9 deletions .github/workflows/ci-apps-web.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: CI for Web App
name: CI for web app

on: # yamllint disable-line rule:truthy
push:
Expand Down Expand Up @@ -40,12 +40,12 @@ jobs:
node: ['18']

steps:
- name: Check out the codebase
- name: 📦 Check out the codebase
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup node ${{ matrix.node }}
- name: ⚙️ Setup node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
Expand All @@ -55,7 +55,7 @@ jobs:
uses: ./.github/actions/pnpm-install

# see https://github.com/vercel/next.js/pull/27362
- name: Restore "web" app build from cache
- name: ♻️ Restore "web" app build from cache
uses: actions/cache@v3
with:
path: |
Expand All @@ -66,22 +66,22 @@ jobs:
restore-keys: |
${{ runner.os }}-web-${{ hashFiles('pnpm*.yaml') }}-
- name: Typecheck
- name: 📝 Typecheck
working-directory: apps/web
run: |
pnpm lint:types
- name: Linter
- name: 🚨 Linter
working-directory: apps/web
run: |
pnpm lint
- name: Unit tests
- name: 🧪 Unit tests
working-directory: apps/web
run: |
pnpm test
- name: Build web-app
- name: 🏗 Build web-app
working-directory: apps/web
run: |
pnpm --filter=web build
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
run: |
pnpm --filter=web lint:dist
- name: Upload coverage report to Codecov
- name: 📤 Upload coverage report to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci-packages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: CI for Packages
name: CI for packages

on: # yamllint disable-line rule:truthy
push:
Expand Down Expand Up @@ -38,12 +38,12 @@ jobs:
node: ['18']

steps:
- name: Check out the codebase
- name: 📦 Check out the codebase
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup node ${{ matrix.node }}
- name: ⚙️ Setup node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
Expand All @@ -52,7 +52,7 @@ jobs:
- name: 📥 Monorepo install
uses: ./.github/actions/pnpm-install

- name: Restore packages cache
- name: ♻️ Restore packages cache
uses: actions/cache@v3
with:
path: |
Expand All @@ -65,11 +65,11 @@ jobs:
# Typecheck packages that have changed + packages and apps that depends on them (--from & --since)
# That allows to see if we're introducing "surface" regressions (just the types)
- name: Typecheck
- name: 📝 Typecheck
run: |
pnpm --filter "...[origin/master]" --changed-files-ignore-pattern="apps/*" run lint:types
# Lint packages that have changed (--include & --since)
- name: Linter
- name: 🚨 Linter
run: |
pnpm --filter "...[origin/master]" --changed-files-ignore-pattern="apps/*" run lint
2 changes: 2 additions & 0 deletions .github/workflows/codeql-analysis.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ jobs:

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

...
Empty file.
106 changes: 106 additions & 0 deletions .github/workflows/e2e-apps-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
name: E2E CI for web app

on: # yamllint disable-line rule:truthy
push:
branches:
- master
- develop
# Only consider those paths to trigger the action
paths:
- 'apps/web/**'
- 'packages/**'
- 'package.json'
- 'pnpm*'
- '.github/**'

pull_request:
types:
- opened
- synchronize
- reopened
# Only consider those paths to trigger the action
paths:
- 'apps/web/**'
- 'packages/**'
- 'package.json'
- 'pnpm*'
- '.github/**'

env:
NEXT_DISABLE_SENTRY: false
SENTRY_LOG_LEVEL: debug
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_URL: ${{ secrets.SENTRY_URL }}
NEXT_SENTRY_UPLOAD_DRY_RUN: true
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
NEXTAUTH_URL: 'http://localhost:3000'

jobs:
e2e:
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os:
- 'ubuntu-22.04'
node:
- '18'
include:
- os: 'ubuntu-22.04'
playwright_binary_path: ~/.cache/ms-playwright

steps:
- name: 📦 Check out the codebase
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: ⚙️ Setup node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: 📥 Monorepo install
uses: ./.github/actions/pnpm-install

# see https://github.com/vercel/next.js/pull/27362
- name: ♻️ Restore "web" app build from cache
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/apps/web/.next/cache
${{ github.workspace }}/.cache
${{ github.workspace }}/**/tsconfig.tsbuildinfo
key: ${{ runner.os }}-web-${{ hashFiles('pnpm*.yaml') }}-${{ hashFiles('apps/web/src/**.[jt]sx?', 'apps/web/src/**.json') }}
restore-keys: |
${{ runner.os }}-web-${{ hashFiles('pnpm*.yaml') }}-
- name: 🏗 Build web-app
working-directory: apps/web
run: |
pnpm --filter=web build
env:
NEXT_IGNORE_ESLINT: true
NEXT_IGNORE_TYPE_CHECK: true
NEXT_DISABLE_SOURCEMAPS: true
NEXT_TELEMETRY_DISABLED: true

- name: 📥 Install playwright
uses: ./.github/actions/playwright-install

- name: 🧪 Run E2E playwright tests on web app
working-directory: apps/web
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- pnpm test:e2e
env:
CI: 1

- name: 📤 Upload testing artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: web-app-playwright-test-results-${{ runner.os }}
path: apps/web/e2e/.out
Empty file.
2 changes: 1 addition & 1 deletion .github/workflows/sync-from-tpl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
token: ${{ secrets.WORKFLOW_TOKEN }}

- name: Sync changes from upstream template
uses: AndreasAugustin/actions-template-sync@v0.6.0-draft
uses: AndreasAugustin/actions-template-sync@v0.7.3
with:
github_token: ${{ secrets.WORKFLOW_TOKEN }}
source_repo_path: wayofdev/next-starter-tpl
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ test: ## Run unit tests
$(NPM_RUNNER) test:unit
.PHONY: test

test-e2e: ## Run e2e tests
npx playwright install
pnpm --filter=web test:e2e
.PHONY: test-e2e

format: ## Run prettier formatting
$(NPM_RUNNER) format
.PHONY: format
Expand All @@ -262,7 +267,7 @@ sort: ## Sort package.json across project
.PHONY: sort

analyze: ## Run bundle-analyzer
$(NPM_RUNNER) analyze
pnpm --filter=web analyze
.PHONY: analyze


Expand Down
2 changes: 0 additions & 2 deletions apps/storybook/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ module.exports = {
'@wayofdev/eslint-config-bases/react',
'@wayofdev/eslint-config-bases/tailwind',
'@wayofdev/eslint-config-bases/mdx',
// Add specific rules for nextjs
'plugin:@next/next/core-web-vitals',
// Apply prettier and disable incompatible rules
'@wayofdev/eslint-config-bases/prettier-plugin',
],
Expand Down
Loading

3 comments on commit 67318e6

@vercel
Copy link

@vercel vercel bot commented on 67318e6 Mar 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

next-starter-tpl-storybook – ./apps/storybook

next-starter-tpl-storybook.vercel.app
next-starter-tpl-storybook-git-master-wayofdev.vercel.app
next-starter-tpl-storybook-wayofdev.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 67318e6 Mar 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 67318e6 Mar 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.