From 2c77d3b835c1aec651d0599fe6bbe7505d0c431c Mon Sep 17 00:00:00 2001 From: Aaron Shafovaloff Date: Sat, 16 Nov 2024 11:00:14 -0700 Subject: [PATCH] playwright ci --- .github/workflows/playwright.yml | 85 +++++++++++++++++++++++++++++ packages/idb-cache-app/package.json | 4 +- packages/idb-cache/package.json | 4 +- pnpm-lock.yaml | 13 +++-- 4 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/playwright.yml diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..e259496 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,85 @@ +name: "Run Playwright tests" + +on: + pull_request: + push: + branches: + - main + - 'releases/*' + workflow_dispatch: + +jobs: + test-linux: + name: Playwright tests on ${{ matrix.os }} (headless=${{ matrix.headless }}) + runs-on: ubuntu-20.04 # Specify the Ubuntu version you prefer + + strategy: + fail-fast: false + matrix: + headless: [true] + + steps: + # 1. Checkout the repository + - uses: actions/checkout@v3 + + # 2. Setup Node.js + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + # 3. Setup pnpm + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 7.x + + # 4. Cache pnpm dependencies + - name: Cache pnpm dependencies + uses: actions/cache@v3 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + # 5. Install dependencies + - name: Install dependencies + run: pnpm install + + # 6. Build the @instructure/idb-cache package + - name: Build idb-cache package + run: pnpm --filter @instructure/idb-cache build + + # 7. Build the idb-cache-app + - name: Build idb-cache-app + run: pnpm --filter idb-cache-app build + + # 8. Serve the idb-cache-app + - name: Serve idb-cache-app + run: pnpm --filter idb-cache-app preview -- --port 3000 & + # The '&' runs the serve command in the background + + # 9. Wait for the server to be ready + - name: Wait for idb-cache-app to be ready + run: | + for i in {1..60}; do + if curl -s http://localhost:3000 > /dev/null; then + echo "Server is ready!" + break + fi + echo "Waiting for server to be ready... ($i/60)" + sleep 1 + done + + # 10. Run Playwright tests in headless mode + - name: Run Playwright tests (Headless) + if: ${{ matrix.headless == true }} + run: pnpm --filter idb-cache-app playwright test + + # 11. Run Playwright tests in headful mode on Linux + - name: Run Playwright tests (Headful) + if: ${{ matrix.headless == false }} + run: | + export HEADFUL=true + xvfb-run --auto-servernum -- pnpm --filter idb-cache-app playwright test diff --git a/packages/idb-cache-app/package.json b/packages/idb-cache-app/package.json index 70e2a9b..10832fb 100644 --- a/packages/idb-cache-app/package.json +++ b/packages/idb-cache-app/package.json @@ -14,7 +14,6 @@ "react-dom": "^18.3.1" }, "devDependencies": { - "@playwright/test": "^1.48.2", "@instructure/ui": "^9.9.0", "@instructure/ui-buttons": "^9.9.0", "@instructure/ui-flex": "^9.9.0", @@ -23,12 +22,15 @@ "@instructure/ui-number-input": "^9.9.0", "@instructure/ui-text-input": "^9.9.0", "@instructure/ui-view": "^9.9.0", + "@playwright/test": "^1.48.2", "@rsbuild/core": "^1.0.19", "@rsbuild/plugin-react": "^1.0.6", "@types/random-seed": "^0.3.5", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "daisyui": "^4.12.14", + "idb": "^8.0.0", + "playwright": "^1.48.2", "tailwindcss": "^3.4.15", "typescript": "^5.6.3" } diff --git a/packages/idb-cache/package.json b/packages/idb-cache/package.json index a5f2d39..442b56c 100644 --- a/packages/idb-cache/package.json +++ b/packages/idb-cache/package.json @@ -26,12 +26,12 @@ "biome:check": "biome check . --write" }, "peerDependencies": { - "@rslib/core": "^0.0.15", - "idb": "^8.0.0" + "@rslib/core": "^0.0.15" }, "devDependencies": { "@rslib/core": "^0.0.15", "@types/node": "^22.9.0", + "idb": "^8.0.0", "typescript": "^5.6.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 11c5d0d..96375e0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,10 +13,6 @@ importers: version: 1.9.4 packages/idb-cache: - dependencies: - idb: - specifier: ^8.0.0 - version: 8.0.0 devDependencies: '@rslib/core': specifier: ^0.0.15 @@ -24,6 +20,9 @@ importers: '@types/node': specifier: ^22.9.0 version: 22.9.0 + idb: + specifier: ^8.0.0 + version: 8.0.0 typescript: specifier: ^5.6.3 version: 5.6.3 @@ -88,6 +87,12 @@ importers: daisyui: specifier: ^4.12.14 version: 4.12.14(postcss@8.4.49) + idb: + specifier: ^8.0.0 + version: 8.0.0 + playwright: + specifier: ^1.48.2 + version: 1.48.2 tailwindcss: specifier: ^3.4.15 version: 3.4.15