|
| 1 | +name: e2e tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +env: |
| 12 | + WASP_TELEMETRY_DISABLE: 1 |
| 13 | + WASP_VERSION: 0.13.2 |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout the repo |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Setup Node.js |
| 24 | + id: setup-node |
| 25 | + uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: '20' |
| 28 | + |
| 29 | + - name: Install Wasp |
| 30 | + run: curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v ${{ env.WASP_VERSION }} |
| 31 | + |
| 32 | + - name: Docker setup |
| 33 | + uses: docker/setup-buildx-action@v3 |
| 34 | + |
| 35 | + # 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. |
| 36 | + # This step sets mock env vars in order to pass the validation steps so the app can run |
| 37 | + # in the CI environment. For env vars that are actually used in tests and therefore need real values, we set them in |
| 38 | + # the GitHub secrets settings and access them in a step below. |
| 39 | + - name: Set required wasp app env vars to mock values |
| 40 | + run: | |
| 41 | + cd app |
| 42 | + cp .env.server.example .env.server |
| 43 | +
|
| 44 | + - name: Cache global node modules |
| 45 | + uses: actions/cache@v4 |
| 46 | + with: |
| 47 | + path: ~/.npm |
| 48 | + key: node-modules-${{ runner.os }}-${{ hashFiles('app/package-lock.json') }}-${{ hashFiles('e2e-tests/package-lock.json') }}-wasp${{ env.WASP_VERSION }}-node${{ steps.setup-node.outputs.node-version }} |
| 49 | + restore-keys: | |
| 50 | + node-modules-${{ runner.os }}- |
| 51 | + |
| 52 | + - name: Install Node.js dependencies for Playwright tests |
| 53 | + if: steps.cache-e2e-tests.outputs.cache-hit != 'true' |
| 54 | + run: | |
| 55 | + cd e2e-tests |
| 56 | + npm ci |
| 57 | +
|
| 58 | + - name: Store Playwright's Version |
| 59 | + run: | |
| 60 | + cd e2e-tests |
| 61 | + PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//') |
| 62 | + echo "Playwright's Version: $PLAYWRIGHT_VERSION" |
| 63 | + echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV |
| 64 | +
|
| 65 | + - name: Cache Playwright Browsers for Playwright's Version |
| 66 | + id: cache-playwright-browsers |
| 67 | + uses: actions/cache@v4 |
| 68 | + with: |
| 69 | + path: ~/.cache/ms-playwright |
| 70 | + key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}-${{ runner.os }} |
| 71 | + |
| 72 | + - name: Set up Playwright |
| 73 | + if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' |
| 74 | + run: | |
| 75 | + cd e2e-tests |
| 76 | + npx playwright install --with-deps |
| 77 | +
|
| 78 | + - name: Install Stripe CLI |
| 79 | + run: | |
| 80 | + curl -s https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/public | gpg --dearmor | sudo tee /usr/share/keyrings/stripe.gpg |
| 81 | + 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 |
| 82 | + sudo apt update |
| 83 | + sudo apt install stripe |
| 84 | +
|
| 85 | + # For Stripe webhooks to work in development, we need to run the Stripe CLI to listen for webhook events. |
| 86 | + # The Stripe CLI will receive the webhook events from Stripe test payments and |
| 87 | + # forward them to our local server so that we can test the payment flow in our e2e tests. |
| 88 | + - name: Run Stripe CLI to listen for webhooks |
| 89 | + env: |
| 90 | + STRIPE_DEVICE_NAME: ${{ secrets.STRIPE_DEVICE_NAME }} |
| 91 | + run: | |
| 92 | + stripe listen --api-key ${{ secrets.STRIPE_KEY }} --forward-to localhost:3001/stripe-webhook & |
| 93 | +
|
| 94 | + - name: Run Playwright tests |
| 95 | + env: |
| 96 | + # The e2e tests are testing parts of the app that need certain env vars, so we need to access them here. |
| 97 | + # These secretes can be set in your GitHub repo settings, e.g. https://github.com/<account>/<repo>/settings/secrets/actions |
| 98 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 99 | + STRIPE_KEY: ${{ secrets.STRIPE_KEY }} |
| 100 | + STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }} |
| 101 | + HOBBY_SUBSCRIPTION_PRICE_ID: ${{ secrets.HOBBY_SUBSCRIPTION_PRICE_ID }} |
| 102 | + PRO_SUBSCRIPTION_PRICE_ID: ${{ secrets.PRO_SUBSCRIPTION_PRICE_ID }} |
| 103 | + CREDITS_PRICE_ID: ${{ secrets.CREDITS_PRICE_ID }} |
| 104 | + SKIP_EMAIL_VERIFICATION_IN_DEV: true |
| 105 | + run: | |
| 106 | + cd e2e-tests |
| 107 | + npm run e2e:playwright |
0 commit comments