Playwright tests & CI #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: e2e tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
WASP_TELEMETRY_DISABLE: 1 | |
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: Install Wasp | |
run: curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v 0.13.0 | |
- name: Docker setup | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Node Modules | |
uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node${{ steps.setup-node.outputs.node-version }}-node-modules-${{ hashFiles('app/package-lock.json') }} | |
# In order for the app to run we need to set env vars even if they aren't used | |
# this step sets mock env vars to pass the validation steps so the app can run | |
# in the CI environment. For vars that are actually used in tests, we set them in | |
# the GitHub secrets settings and access them in a step below. | |
- name: Setup Dummy Env Vars | |
run: | | |
cd app | |
cp .env.server.example .env.server | |
- name: Install Node.js dependencies for Playwright tests | |
run: | | |
cd e2e-tests | |
npm ci | |
- name: Set up Playwright | |
run: | | |
cd e2e-tests | |
npx playwright install --with-deps | |
- name: 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 | |
- name: Run Stripe CLI to listen for webhooks | |
env: | |
STRIPE_DEVICE_NAME: ${{ secrets.STRIPE_DEVICE_NAME }} | |
run: | | |
nohup $HOME/.stripe/stripe listen --api-key ${{ secrets.STRIPE_KEY }} --forward-to localhost:3001/stripe-webhook > /dev/null 2>&1 & | |
- name: Run Playwright tests | |
env: | |
# The e2e tests are testing parts of the app that need OPENAI_API_KEY, so we need to set it here. | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
STRIPE_KEY: ${{ secrets.STRIPE_KEY }} | |
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }} | |
run: | | |
cd e2e-tests | |
npm run e2e:playwright:debug |