-
-
Notifications
You must be signed in to change notification settings - Fork 830
121 lines (104 loc) · 4.9 KB
/
e2e-tests.yml
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
name: e2e tests
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
WASP_TELEMETRY_DISABLE: 1
WASP_VERSION: 0.15.0
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Docker setup
uses: docker/setup-buildx-action@v3
- name: Install Wasp
run: curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v ${{ env.WASP_VERSION }}
- name: Cache global node modules
uses: actions/cache@v4
with:
path: ~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('template/app/package-lock.json') }}-${{ hashFiles('template/e2e-tests/package-lock.json') }}-wasp${{ env.WASP_VERSION }}-node${{ steps.setup-node.outputs.node-version }}
restore-keys: |
node-modules-${{ runner.os }}-
# In order for the app to run in the dev mode we need to set the required env vars even if
# they aren't actually used by the app. This step sets mock env vars in order to pass the
# validation steps so the app can run in the CI environment. For env vars that are actually
# used in tests and therefore need real values, we set them in the GitHub secrets settings and
# access them in a step below.
- name: Set required wasp app env vars to mock values
working-directory: ./template
run: |
cd app
cp .env.server.example .env.server && cp .env.client.example .env.client
- name: Check that patching demo app (opensaas-sh) works
working-directory: ./opensaas-sh
run: |
./tools/patch.sh
- name: '[e2e-tests] Install Node.js dependencies for Playwright tests'
if: steps.cache-e2e-tests.outputs.cache-hit != 'true'
working-directory: ./template
run: |
cd e2e-tests
npm ci
- name: "[e2e-tests] Store Playwright's Version"
working-directory: ./template
run: |
cd e2e-tests
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: "[e2e-tests] Cache Playwright Browsers for Playwright's Version"
id: cache-playwright-browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}-${{ runner.os }}
- name: '[e2e-tests] Set up Playwright'
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
working-directory: ./template
run: |
cd e2e-tests
npx playwright install --with-deps
- name: '[e2e-tests] Install Stripe CLI'
run: |
curl -s https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/public | gpg --dearmor | sudo tee /usr/share/keyrings/stripe.gpg
echo "deb [signed-by=/usr/share/keyrings/stripe.gpg] https://packages.stripe.dev/stripe-cli-debian-local stable main" | sudo tee -a /etc/apt/sources.list.d/stripe.list
sudo apt update
sudo apt install stripe
# For Stripe webhooks to work in development, we need to run the Stripe CLI to listen for webhook events.
# The Stripe CLI will receive the webhook events from Stripe test payments and
# forward them to our local server so that we can test the payment flow in our e2e tests.
- name: '[e2e-tests] Run Stripe CLI to listen for webhooks'
env:
STRIPE_DEVICE_NAME: ${{ secrets.STRIPE_DEVICE_NAME }}
run: |
stripe listen --api-key ${{ secrets.STRIPE_KEY }} --forward-to localhost:3001/payments-webhook &
- name: '[e2e-tests] Run Playwright tests'
env:
# The e2e tests are testing parts of the app that need certain env vars, so we need to access them here.
# These secretes can be set in your GitHub repo settings, e.g. https://github.com/<account>/<repo>/settings/secrets/actions
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
STRIPE_API_KEY: ${{ secrets.STRIPE_KEY }}
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}
STRIPE_CUSTOMER_PORTAL_URL: https://billing.stripe.com/p/login/test_8wM8x17JN7DT4zC000
PAYMENTS_HOBBY_SUBSCRIPTION_PLAN_ID: ${{ secrets.STRIPE_HOBBY_SUBSCRIPTION_PRICE_ID }}
PAYMENTS_PRO_SUBSCRIPTION_PLAN_ID: ${{ secrets.STRIPE_PRO_SUBSCRIPTION_PRICE_ID }}
PAYMENTS_CREDITS_10_PLAN_ID: ${{ secrets.STRIPE_CREDITS_PRICE_ID }}
SKIP_EMAIL_VERIFICATION_IN_DEV: true
# Client-side env vars
REACT_APP_GOOGLE_ANALYTICS_ID: G-H3LSJCK95H
working-directory: ./template
run: |
cd e2e-tests
npm run e2e:playwright