Skip to content

Commit

Permalink
update gh action to run tests on Vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
jackiequach committed Dec 18, 2024
1 parent cf9a9f9 commit d9fbc3b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
32 changes: 24 additions & 8 deletions .github/workflows/Playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,38 @@ jobs:
- name: Install Playwright
run: npx playwright install --with-deps

- name: Build app
run: NODE_ENV=test npm run build
# Step 1: Retrieve the Vercel Preview URL
- name: vercel-preview-url
uses: zentered/[email protected]
id: vercel_preview_url
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
GITHUB_REF: "main"
GITHUB_REPOSITORY: "your-repo/your-project"
with:
vercel_project_id: ${{ secrets.VERCEL_PROJECT_ID }}

- name: Start the app
run: |
NODE_ENV=test npm start &
sleep 5
shell: bash
# Step 2: Wait for the Vercel deployment to be ready
- uses: UnlyEd/github-action-await-vercel@v1
id: await-vercel
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
with:
deployment-url: ${{ steps.vercel_preview_url.outputs.preview_url }}
timeout: 420
poll-interval: 15

- name: Run your tests
env:
BASE_URL: ${{ steps.vercel_preview_url.outputs.preview_url }}
run: npm run playwright

- name: Set the world parameters as an env var
env:
BASE_URL: ${{ steps.vercel_preview_url.outputs.preview_url }}
# WORLD_PARAMETERS set here will override anything set in cucumber.json
run: |
echo "WORLD_PARAMETERS={\"headless\": true}" >> $GITHUB_ENV
echo "WORLD_PARAMETERS={\"appUrl\": \"$BASE_URL\", \"headless\": true}" >> $GITHUB_ENV
- name: Run Cucumber tests
run: npm run cucumber -- playwright/features --world-parameters '${{ env.WORLD_PARAMETERS }}'
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Remove Kristo, Jiayong, and Olivia and add Kyle as codeowners
- Deploy to new Terraform ECS cluster in production
- Deploy only to the new Terraform ECS clusters
- Update GH action to run playwright and cucumber tests on Vercel deployment

## [0.18.9]

Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const config: PlaywrightTestConfig = {
use: {
headless: true,
// Base URL to use in actions like `await page.goto('/')`.
baseURL: "http://localhost:3000",
baseURL: process.env.BASE_URL,

/* When running tests locally, record a trace for each test, but remove it from successful runs.
* On CI, turn this feature off. See https://playwright.dev/docs/trace-viewer */
Expand Down

0 comments on commit d9fbc3b

Please sign in to comment.