-
-
Notifications
You must be signed in to change notification settings - Fork 532
150 lines (129 loc) · 4.17 KB
/
test-e2e.yaml
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Medusa NextJS Template Tests
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
env:
PGHOST: localhost
PGPORT: 5432
PGUSER: postgres
PGPASSWORD: password
PGDATABASE: postgres
TEST_POSTGRES_USER: test_medusa_user
TEST_POSTGRES_PASSWORD: password
TEST_POSTGRES_DATABASE: test_medusa_db
TEST_POSTGRES_DATABASE_TEMPLATE: test_medusa_db_template
TEST_POSTGRES_HOST: localhost
TEST_POSTGREST_PORT: 5432
PRODUCTION_POSTGRES_DATABASE: medusa_db
CLIENT_SERVER: http://localhost:9000
JWT_SECRET: something
COOKIE_SECRET: something
DATABASE_TYPE: "postgres"
REDIS_URL: redis://localhost:6379
DATABASE_URL: postgres://test_medusa_user:password@localhost/test_medusa_db
MEILISEARCH_HOST: http://localhost:7700
MEILISEARCH_API_KEY: meili_api_key
NEXT_PUBLIC_BASE_URL: http://localhost:8000
NEXT_PUBLIC_DEFAULT_REGION: us
NEXT_PUBLIC_MEDUSA_BACKEND_URL: http://localhost:9000
NEXT_PUBLIC_INDEX_NAME: products
NEXT_PUBLIC_SEARCH_ENDPOINT: http://127.0.0.1:7700
NEXT_PUBLIC_SEARCH_API_KEY: meili_api_key
REVALIDATE_SECRET: supersecret
jobs:
e2e-test-runner:
timeout-minutes: 20
runs-on:
- ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
meilisearch:
image: getmeili/meilisearch:v1.7
env:
MEILI_MASTER_KEY: meili_api_key
MEILI_ENV: development
ports:
- 7700:7700
options: >-
--health-cmd "curl --fail http://localhost:7700/health"
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:latest
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Initialize PostgreSQL
run: |
echo "Initializing Databases"
psql -h localhost -U postgres -d test -c "CREATE USER ${{ env.TEST_POSTGRES_USER }} WITH PASSWORD '${{ env.TEST_POSTGRES_PASSWORD }}';"
psql -h localhost -U postgres -d test -c "CREATE DATABASE ${{ env.TEST_POSTGRES_DATABASE }} OWNER ${{ env.TEST_POSTGRES_USER }};"
- name: Install Medusa CLI
run: npm install @medusajs/medusa-cli@preview -g
- name: Setup medusa backend server
working-directory: ../
# https://docs.medusajs.com/cli/reference#options
run: |
medusa new backend \
-y \
--v2 \
--branch feat/v2 \
--skip-db \
--skip-migrations \
--skip-env \
--db-user ${{ env.TEST_POSTGRES_USER }} \
--db-pass ${{ env.TEST_POSTGRES_PASSWORD }} \
--db-database ${{ env.TEST_POSTGRES_DATABASE }} \
--db-host ${{ env.TEST_POSTGRES_HOST }} \
--db-port ${{ env.TEST_POSTGREST_PORT }}
- name: Setup search in the backend
working-directory: ../backend
run: yarn add medusa-plugin-meilisearch
- name: Move custom medusa config to the backend
run: cp .github/scripts/medusa-config.js ../backend/medusa-config.js
- name: Seed data from default seed file
working-directory: ../backend
run: medusa seed --seed-file=data/seed.json
- name: Run backend server
working-directory: ../backend
run: medusa develop
- name: Install packages
run: yarn install -y
- name: Install playwright
run: yarn playwright install --with-deps
- name: Setup frontend
run: yarn build
- name: Run Tests
run: yarn test-e2e
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: test-results
retention-days: 30