This repository was archived by the owner on Jan 5, 2024. It is now read-only.
forked from belgattitude/nextjs-monorepo-example
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (99 loc) · 3.33 KB
/
ci-e2e-nextjs-app.yml
File metadata and controls
113 lines (99 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: CI-e2e-nextjs-app
on:
push:
branches:
- dev
- main
# Only consider those paths to trigger the action
paths:
- 'apps/nextjs-app/**'
- 'packages/**'
- 'package.json'
- '*.lock'
- '.yarnrc.yml'
- '.github/**'
pull_request:
types:
- opened
- synchronize
- reopened
# Only consider those paths to trigger the action
paths:
- 'apps/nextjs-app/**'
- 'packages/**'
- 'package.json'
- '*.lock'
- '.yarnrc.yml'
- '.github/**'
jobs:
e2e:
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
node-version:
- 16
database:
- e2e-postgres
os:
- ubuntu-latest
include:
- os: ubuntu-latest
playwright_binary_path: ~/.cache/ms-playwright
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: 📥 Monorepo install
uses: ./.github/actions/yarn-nm-install
# see https://github.com/vercel/next.js/pull/27362
- name: Restore nextjs build nextjs-app from cache
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/apps/nextjs-app/.next/cache
${{ github.workspace }}/.cache
${{ github.workspace }}/**/tsconfig.tsbuildinfo
key: ${{ runner.os }}-nextjs-app-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('apps/nextjs-app/src/**.[jt]sx?', 'apps/nextjs-app/src/**.json') }}
restore-keys: |
${{ runner.os }}-nextjs-app-${{ hashFiles('**/yarn.lock') }}-
- name: Start database
working-directory: packages/db-main-prisma
run: docker-compose -f docker-compose.e2e.yml up --detach ${{ matrix.database }}
- name: Create and seed test database
working-directory: packages/db-main-prisma
run: |
yarn prisma db push
yarn prisma db seed
env:
PRISMA_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/webapp-e2e?schema=public
- name: Build nextjs-app
working-directory: apps/nextjs-app
run: |
yarn build
env:
PRISMA_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/webapp-e2e?schema=public
# Don't need to lint / typecheck for e2e, they're done in another workflow
NEXTJS_IGNORE_ESLINT: true
NEXTJS_IGNORE_TYPECHECK: true
NEXT_DISABLE_SOURCEMAPS: true
NEXT_TELEMETRY_DISABLED: true
NEXTJS_SENTRY_UPLOAD_DRY_RUN: true
- name: 📥 Playwright install
uses: ./.github/actions/playwright-install
- name: E2E run nextjs-app playwright tests
working-directory: apps/nextjs-app
run: |
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test-e2e
env:
E2E_WEBSERVER_MODE: BUILD_AND_START
CI: 1
PRISMA_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/webapp-e2e?schema=public
- uses: actions/upload-artifact@v3
if: always()
with:
name: nextjs-app-playwright-test-results-${{ runner.os }}
path: apps/nextjs-app/e2e/.out