Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playwright tests & CI #69

Merged
merged 112 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 101 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
875b08b
get tests started
vincanger Mar 1, 2024
235dd95
Create opensaas-ci.yml
vincanger Mar 4, 2024
93d85e0
move github workflows
vincanger Mar 4, 2024
5cc3400
modify ci scripts
vincanger Mar 4, 2024
ef2303d
install linebyline
vincanger Mar 4, 2024
fe8dc36
Update package.json
vincanger Mar 4, 2024
bec5403
install wait-port
vincanger Mar 4, 2024
8d715e8
Update package.json
vincanger Mar 4, 2024
7f29638
add conditional webserver when in CI env
vincanger Mar 4, 2024
332a03d
test tagging action
vincanger Mar 4, 2024
17a681d
Update retag-commit.yml
vincanger Mar 4, 2024
61bd73c
remove unused workflow
vincanger Mar 4, 2024
73f0c4c
add .env file and test stripe webhook
vincanger Mar 4, 2024
59694d6
Update e2e-tests.yml
vincanger Mar 4, 2024
13d31fe
Update e2e-tests.yml
vincanger Mar 4, 2024
7fa2bb9
Update e2e-tests.yml
vincanger Mar 4, 2024
0fd85ae
Update e2e-tests.yml
vincanger Mar 4, 2024
ce38902
test demo app
vincanger Mar 5, 2024
373b0e9
Update e2e-tests.yml
vincanger Mar 5, 2024
a01da1b
update github action versions
vincanger Mar 5, 2024
c9b4309
disable wasp telemetry
vincanger Mar 6, 2024
0c277e5
Cleanup running (#72)
Zeko369 Mar 7, 2024
bbbbcbd
improve tests
vincanger Mar 7, 2024
c301d1f
Update ci-start-app.js
vincanger Mar 7, 2024
9daf3ee
remove npm scripts
vincanger Mar 8, 2024
c3ce85d
Update e2e-tests.yml
vincanger Mar 8, 2024
a34b2fd
Update ci-start-app-with-scripts.js
vincanger Mar 8, 2024
558cc30
Update ci-start-app-with-scripts.js
vincanger Mar 8, 2024
4aecd93
rename test folder
vincanger Mar 12, 2024
9eed9b5
Update e2e-tests.yml
vincanger Mar 18, 2024
e8115ec
Update e2e-tests.yml
vincanger Mar 18, 2024
5544f2a
export prisma client from server
vincanger Mar 18, 2024
1ca0cf1
Update e2e-tests.yml
vincanger Mar 18, 2024
361dd9c
Update e2e-tests.yml
vincanger Mar 18, 2024
9c1fc69
Update e2e-tests.yml
vincanger Mar 18, 2024
a7df079
Update e2e-tests.yml
vincanger Mar 18, 2024
e63ab54
Update package-lock.json
vincanger Mar 18, 2024
b5a0c77
install linebyline
vincanger Mar 18, 2024
249546e
add npm scripts
vincanger Mar 18, 2024
149b60f
Update package.json
vincanger Mar 18, 2024
afe6332
Update paidUserTests.spec.ts
vincanger Mar 18, 2024
ad1e949
update flaky test
vincanger Mar 18, 2024
bb7e4d9
update tsconfig
vincanger Mar 18, 2024
2a9634b
Update e2e-tests.yml
vincanger Mar 18, 2024
31e0efb
Update e2e-tests.yml
vincanger Mar 18, 2024
a5c11a5
pin node version to github action
vincanger Mar 18, 2024
e624d57
Update e2e-tests.yml
vincanger Mar 18, 2024
3f49cbb
fix retag and clean up
vincanger Mar 18, 2024
bac080d
add notes on tag action
vincanger Mar 18, 2024
4f9555c
Update retag-commit.yml
vincanger Mar 20, 2024
80c7bd7
pr changes part 1
vincanger Mar 22, 2024
7db13e0
pr changes part 2
vincanger Mar 22, 2024
96f47e8
Setup tests with local Prisma (#86)
infomiho Mar 25, 2024
fa64db7
pr changes part 3
vincanger Mar 25, 2024
8ed10d8
add db naming script
vincanger Mar 25, 2024
87f9dce
Update package.json
vincanger Mar 25, 2024
5baf8e6
Update package.json
vincanger Mar 25, 2024
03de857
Update package.json
vincanger Mar 25, 2024
50f8f0c
spawn prisma process
vincanger Mar 25, 2024
a0e8fbe
Update package.json
vincanger Mar 25, 2024
9478c2b
move db setup
vincanger Mar 25, 2024
9ce19af
Update package.json
vincanger Mar 25, 2024
18c4620
Update package.json
vincanger Mar 25, 2024
ef66678
Update package.json
vincanger Mar 25, 2024
15670c1
Update setupDatabaseName.sh
vincanger Mar 25, 2024
316c648
Update package.json
vincanger Mar 25, 2024
4607c20
use same process for local and CI testing
vincanger Apr 3, 2024
285342f
Update package.json
vincanger Apr 3, 2024
faa05a0
Merge branch 'main' into playwright-tests
vincanger Apr 4, 2024
452b354
wait for app for prisma setup
vincanger Apr 4, 2024
4ea6652
Merge branch 'playwright-tests' of https://github.com/wasp-lang/open-…
vincanger Apr 4, 2024
3810b9b
Update package.json
vincanger Apr 4, 2024
62f82c8
changes made with martin
vincanger Apr 5, 2024
bd37741
stripe clie
vincanger Apr 5, 2024
765cbbf
Update e2e-tests.yml
vincanger Apr 5, 2024
91181d2
Update e2e-tests.yml
vincanger Apr 5, 2024
ba6e82b
update start stripe cli
vincanger Apr 5, 2024
70f9831
try again
vincanger Apr 5, 2024
671dabd
start testing stripe payments
vincanger Apr 8, 2024
80cae74
Merge branch 'main' into playwright-tests
vincanger Apr 8, 2024
a106ea9
stripe payment works
vincanger Apr 11, 2024
d68f147
fix base url issue & cleanup
vincanger Apr 12, 2024
eab3e6d
Update playwright.config.ts
vincanger Apr 12, 2024
0786df0
Update package.json
vincanger Apr 12, 2024
1c78b03
Update package-lock.json
vincanger Apr 12, 2024
256147a
Update main.wasp
vincanger Apr 12, 2024
bd9089b
Update utils.ts
vincanger Apr 12, 2024
fa9c809
Update e2e-tests.yml
vincanger Apr 12, 2024
99b17cf
Update utils.ts
vincanger Apr 12, 2024
23a6117
Update utils.ts
vincanger Apr 12, 2024
ff3650d
Update e2e-tests.yml
vincanger Apr 12, 2024
73dfda9
Update actions.ts
vincanger Apr 12, 2024
0631f9c
Update actions.ts
vincanger Apr 12, 2024
ed0b701
Update actions.ts
vincanger Apr 12, 2024
6d82d10
Update actions.ts
vincanger Apr 12, 2024
2654200
Update stripeUtils.ts
vincanger Apr 12, 2024
2d73f2f
Update e2e-tests.yml
vincanger Apr 12, 2024
8c24e13
catch stripe checkout error
vincanger Apr 12, 2024
11bc2c6
remove console.logs
vincanger Apr 12, 2024
392e9fa
fix comments, add err catches
vincanger Apr 12, 2024
be70d70
fix cache and cache keys
vincanger Apr 12, 2024
9c22fa9
Update .github/workflows/e2e-tests.yml
vincanger Apr 17, 2024
f2de9b4
Update .github/workflows/e2e-tests.yml
vincanger Apr 17, 2024
1a3f357
Update .github/workflows/e2e-tests.yml
vincanger Apr 17, 2024
15749c5
Update .github/workflows/e2e-tests.yml
vincanger Apr 17, 2024
5e60999
Update e2e-tests/playwright.config.ts
vincanger Apr 17, 2024
157352d
Improve CI caching and other stuff
vincanger Apr 17, 2024
8f48df7
Merge branch 'playwright-tests' of https://github.com/wasp-lang/open-…
vincanger Apr 17, 2024
f081173
fix cache key, npm scripts, error handling
vincanger Apr 18, 2024
82e3288
Update e2e-tests.yml
vincanger Apr 18, 2024
7a00395
Update README.md
vincanger Apr 19, 2024
dd8e223
add template versioning info
vincanger Apr 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: e2e tests

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
WASP_TELEMETRY_DISABLE: 1
WASP_VERSION: 0.13.2

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 ${{ env.WASP_VERSION }}

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

Martinsos marked this conversation as resolved.
Show resolved Hide resolved
# In order for the app to run we need to set env vars even if they aren't used
vincanger marked this conversation as resolved.
Show resolved Hide resolved
# this step sets mock env vars to pass the validation steps so the app can run
vincanger marked this conversation as resolved.
Show resolved Hide resolved
# in the CI environment. For vars that are actually used in tests, we set them in
vincanger marked this conversation as resolved.
Show resolved Hide resolved
# the GitHub secrets settings and access them in a step below.
- name: Setup Dummy Env Vars
vincanger marked this conversation as resolved.
Show resolved Hide resolved
run: |
cd app
cp .env.server.example .env.server

- name: Cache App Node Modules
Martinsos marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-wasp${{ env.WASP_VERSION }}-node${{ steps.setup-node.outputs.node-version }}-node-modules-${{ hashFiles('app/package-lock.json') }}
Martinsos marked this conversation as resolved.
Show resolved Hide resolved

- name: Cache E2E Tests Node Modules
id: cache-e2e-tests
uses: actions/cache@v4
with:
path: ~/.cache/e2e-tests
Martinsos marked this conversation as resolved.
Show resolved Hide resolved
key: ${{ runner.os }}-node${{ steps.setup-node.outputs.node-version }}-e2e-tests-${{ hashFiles('e2e-tests/package-lock.json') }}

- name: Install Node.js dependencies for Playwright tests
if: steps.cache-e2e-tests.outputs.cache-hit != 'true'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha so you do this only if cache is missing. Although it probably wouldn't be terrible if we did it again when cache already exists, would probably be a no-op, in the sense that it would go like "... all installed already, nothing to do.", right? @infomiho .

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure TBH, some extra work would be performed to ensure that what is installed is okay. It would be less, but still some work would be done. If that work is minimal, we can remove the if statement. You'd have to check that by running the CI with and without the if part.

run: |
cd e2e-tests
npm ci

- name: Store Playwright's Version
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: 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 }}
Martinsos marked this conversation as resolved.
Show resolved Hide resolved

- name: Set up Playwright
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
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
Martinsos marked this conversation as resolved.
Show resolved Hide resolved

- name: Run Stripe CLI to listen for webhooks
Martinsos marked this conversation as resolved.
Show resolved Hide resolved
env:
STRIPE_DEVICE_NAME: ${{ secrets.STRIPE_DEVICE_NAME }}
run: |
stripe listen --api-key ${{ secrets.STRIPE_KEY }} --forward-to localhost:3001/stripe-webhook &

- name: Run Playwright tests
env:
Martinsos marked this conversation as resolved.
Show resolved Hide resolved
# 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_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 }}
CREDITS_PRICE_ID: ${{ secrets.CREDITS_PRICE_ID }}
SKIP_EMAIL_VERIFICATION_IN_DEV: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set this env var in .env.server.example as well, FYI

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave it there in case the user changes their local env so that CI tests don't fail

run: |
cd e2e-tests
npm run e2e:playwright:debug
Martinsos marked this conversation as resolved.
Show resolved Hide resolved
30 changes: 30 additions & 0 deletions .github/workflows/retag-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Retag Commit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what is our reasoning behind this Action -> it keeps assigning this tag to the last commit on main, right?

I guess that makes sense! It means people doing wasp new and just copying this template are getting the same version.

WHat happens when we want to update to new Wasp version -> we update the version here in this action, and push it to main together with the rest of the changes that update open-saas to this new version, right? Ok yeah, sounds good!

Let's add to README something about this, that explains that this is happening and what we have to do to get open-saas to use new Wasp version.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this change makes more sense a separate PR? 🤷 But a cool change!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make separate PRs for stuff like this nexttime :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vincanger you never added anything about this to some top level README, right?
I would certainly do it, as it can be quite surprising that anything that goes to main is basically instantly published, that should be explicitly stated.


on:
push:
branches:
- main

jobs:
retag:
runs-on: ubuntu-latest
env:
TAG_NAME: wasp-v0.13-template
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Configure Git
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"

- name: Delete Old Tag
run: |
git tag -d ${{ env.TAG_NAME }} || true
git push origin :refs/tags/${{ env.TAG_NAME }} || true

- name: Add New Tag
run: |
git tag ${{ env.TAG_NAME }}
git push origin ${{ env.TAG_NAME }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*/.wasp/
*/.env.server
*/.env.client
*/.DS_Store
*/node_modules
*/migrations
*/.DS_Store
.DS_Store
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ Contributing is simple:
3. Create a new feature branch for your work. See [above](#the-default-template-vs-the-deployed-site--docs) for which branch to base your feature branch off of.
4. Create a pull request.
5. Make a "Da Boi" meme while you wait for us to review your PR.
6. If you don't know who "Da Boi" is, head back to the [Wasp Discord](https://discord.gg/aCamt5wCpS) and find out :)
6. If you don't know who "Da Boi" is, head back to the [Wasp Discord](https://discord.gg/aCamt5wCpS) and find out :)
2 changes: 1 addition & 1 deletion app/main.wasp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
app OpenSaaS {
wasp: {
version: "^0.13.0"
version: "^0.13.2"
},
title: "My Open SaaS App",
head: [
Expand Down
Loading