Skip to content

Commit

Permalink
add .env file and test stripe webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
vincanger committed Mar 4, 2024
1 parent 61bd73c commit 73f0c4c
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 48 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: e2e tests

on:
push:
branches:
- main
- playwright-tests
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3

- name: Install Wasp
run: curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s

- name: Docker setup
uses: docker/setup-buildx-action@v1

- name: Cache Node Modules
uses: actions/cache@v3
with:
path: ~/.npm
key: node-modules-${{ hashFiles('app/package-lock.json') }}

- name: Install Node.js dependencies
run: |
cd app
npm ci
- name: Install Stripe CLI
run: |
curl -o- https://raw.githubusercontent.com/stripe/stripe-cli/master/install.sh | bash
- name: Start Stripe webhook listener
env:
STRIPE_KEY: ${{ secrets.STRIPE_KEY }}
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}
HOBBY_SUBSCRIPTION_PRICE_ID: ${{ secrets.HOBBY_SUBSCRIPTION_PRICE_ID }}
PRO_SUBSCRIPTION_PRICE_ID: ${{ secrets.PRO_SUBSCRIPTION_PRICE_ID }}
run: |
stripe listen --forward-to localhost:3001/stripe-webook &
- name: Test Stripe webhook listener
run: |
RESPONSE=$(curl -so -w "%{http_code}" -X POST http://localhost:3000/webhook-path)
if [ $RESPONSE -ne 200 ]; then
echo "Webhook listener is not active"
exit 1
fi
- name: Setup other Env Vars
run: |
cd app
cp .env.server.example .env.server
- name: Commit and push if it's not up-to-date
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add -f .env.server
git commit -m "Add .env.server file" -a || echo "No changes to commit"
git push
- name: Set up Playwright
run: |
cd app
npx playwright install --with-deps
- name: Run Playwright tests
env:
run: |
cd app
DEBUG=pw:webserver npx playwright test tests/whatever.spec.ts
44 changes: 0 additions & 44 deletions .github/workflows/opensaas-ci.yml

This file was deleted.

3 changes: 1 addition & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"scripts": {
"example-app:start": "node ci-start-app.js",
"example-app:start-db": "npm run example-app:cleanup-db && wasp start db",
"example-app:start-app": "npm run example-app:wait-for-db && npm run example-app:prepare-env && wasp db migrate-dev && wasp start",
"example-app:start-app": "npm run example-app:wait-for-db && wasp db migrate-dev && wasp start",
"example-app:wait-for-db": "sleep 5 && ./node_modules/.bin/wait-port 5432",
"example-app:prepare-env": "cp .env.server.example .env.server",
"example-app:cleanup-db": "(docker container rm $(docker container ls -f name=^wasp-dev-db-OpenSaaS- -q) -f || true) && docker volume rm $(docker volume ls -f name=^wasp-dev-db-OpenSaaS- -q) -f || true"
},
"dependencies": {
Expand Down
2 changes: 0 additions & 2 deletions app/playwright/tests/whatever.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,3 @@ test('demo-app', async ({ page }) => {
// expect to find text "turtle" in a span element
expect(page.getByText('turtle')).toBeTruthy();
});

//

0 comments on commit 73f0c4c

Please sign in to comment.