Skip to content

Commit

Permalink
adds docker file and change the ci yml
Browse files Browse the repository at this point in the history
  • Loading branch information
vrknetha committed Dec 8, 2024
1 parent 9891955 commit e7e2903
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 28 deletions.
23 changes: 7 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,33 @@ on:

jobs:
test:
container:
image: mcr.microsoft.com/playwright:v1.49.0-jammy
options: --ipc=host
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]


steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Install Playwright browsers
run: npx playwright install --with-deps

- name: Build
run: npm run build

- name: Lint
run: npm run lint

- name: Run tests
run: xvfb-run --auto-servernum -- npm test
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x720x24" npm test
env:
CI: true
DEBUG: pw:webserver
DEBUG: pw:api,pw:webserver

- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: playwright-report
path: playwright-report/
retention-days: 30
retention-days: 30
14 changes: 9 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ on:

jobs:
publish:
container:
image: mcr.microsoft.com/playwright:v1.49.0-jammy
options: --ipc=host
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js
- name: Setup Node.js for NPM
uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'

- name: Install dependencies
run: npm ci
Expand All @@ -27,9 +30,10 @@ jobs:
run: npm run lint

- name: Test
run: |
npx playwright install --with-deps
npm test
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x720x24" npm test
env:
CI: true
DEBUG: pw:api,pw:webserver

- name: Publish
run: npm publish
Expand Down
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM mcr.microsoft.com/playwright:v1.49.0-jammy

# Set working directory
WORKDIR /app

# Copy package files first for better caching
COPY package*.json ./
COPY tsconfig.json ./

# Install dependencies
RUN npm ci

# Copy source files
COPY src ./src
COPY tests ./tests
COPY index.html ./
COPY playwright.config.ts ./

# Build the project
RUN npm run build

# Install only Chromium browser
RUN npx playwright install chromium

# Set environment variables
ENV CI=true
ENV DEBUG=pw:api,pw:webserver

# Command to run tests
CMD xvfb-run --auto-servernum --server-args="-screen 0 1280x720x24" \
npx playwright test \
--project=chromium \
--reporter=list \
--workers=1
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build": "tsc",
"test": "playwright test",
"test:report": "playwright show-report",
"test:docker": "docker build -t playwright-clipboard-tests . && docker run --rm playwright-clipboard-tests",
"prepare": "npm run build",
"lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
"lint:fix": "eslint \"src/**/*.ts\" \"tests/**/*.ts\" --fix",
Expand All @@ -28,7 +29,7 @@
"license": "MIT",
"devDependencies": {
"@eslint/js": "^9.16.0",
"@playwright/test": "^1.40.0",
"@playwright/test": "^1.49.0",
"@types/node": "^20.10.0",
"@typescript-eslint/eslint-plugin": "^6.13.0",
"@typescript-eslint/parser": "^6.13.0",
Expand All @@ -40,7 +41,7 @@
"typescript": "^5.3.3"
},
"peerDependencies": {
"@playwright/test": "^1.40.0"
"@playwright/test": "^1.49.0"
},
"files": [
"dist",
Expand Down
26 changes: 21 additions & 5 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
testDir: './tests',
fullyParallel: true,
fullyParallel: false,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
workers: 1,
reporter: 'html',
timeout: 120000,
expect: {
timeout: 30000,
},
use: {
baseURL: 'http://localhost:8080',
trace: 'on-first-retry',
actionTimeout: 30000,
navigationTimeout: 30000,
headless: true
},
webServer: {
command: 'npm run serve',
Expand All @@ -25,15 +32,24 @@ export default defineConfig({
use: {
...devices['Desktop Chrome'],
permissions: ['clipboard-read', 'clipboard-write'],
viewport: { width: 1280, height: 720 }
},
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
use: {
...devices['Desktop Firefox'],
permissions: ['clipboard-read', 'clipboard-write'],
viewport: { width: 1280, height: 720 }
},
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
use: {
...devices['Desktop Safari'],
permissions: ['clipboard-read', 'clipboard-write'],
viewport: { width: 1280, height: 720 }
},
}
],
});

0 comments on commit e7e2903

Please sign in to comment.