Skip to content

Commit 3e17052

Browse files
Merge pull request #3 from ramjangatisetty/feature/githubworkflowwithdocker
New Features are added to the framework
2 parents ef694c6 + 43635a6 commit 3e17052

25 files changed

+870
-71
lines changed

.github/workflows/playwright.yml

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,82 @@
1-
name: Playwright Tests
1+
name: Playwright Tests in Docker
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: [main, qa, dev, feature/*]
76
pull_request:
8-
branches:
9-
- main
10-
workflow_dispatch: {}
7+
branches: [main, qa, dev, feature/*]
8+
workflow_dispatch:
9+
inputs:
10+
tag:
11+
description: 'Test tag to filter by (e.g., @smoke)'
12+
required: false
13+
default: '@smoke'
14+
browser:
15+
description: 'Browser to run tests on'
16+
required: true
17+
default: 'chromium'
18+
workers:
19+
description: 'Number of parallel workers'
20+
required: false
21+
default: '2'
22+
retries:
23+
description: 'Retry count'
24+
required: false
25+
default: '1'
26+
test_env:
27+
description: 'Test environment (qa1, dev, etc.)'
28+
required: true
29+
default: 'qa1'
1130

1231
jobs:
1332
test:
1433
runs-on: ubuntu-latest
34+
env:
35+
TAG: ${{ github.event.inputs.tag }}
36+
TEST_ENV: ${{ github.event.inputs.test_env }}
37+
BROWSER: ${{ github.event.inputs.browser }}
38+
WORKERS: ${{ github.event.inputs.workers }}
39+
RETRIES: ${{ github.event.inputs.retries }}
1540

1641
steps:
1742
- name: Checkout repo
1843
uses: actions/checkout@v3
1944

20-
- name: Set up Node.js
21-
uses: actions/setup-node@v4
22-
with:
23-
node-version: 20
24-
25-
- name: Install dependencies
26-
run: npm ci
27-
28-
- name: Install Playwright browsers
29-
run: npx playwright install --with-deps
45+
- name: Build Docker Image
46+
run: docker build -t my-playwright-runner -f Dockerfile.playwright .
3047

31-
- name: Run Playwright tests
32-
run: npx playwright test
48+
- name: Run Playwright Tests in Docker
49+
run: |
50+
docker run --name temp-runner \
51+
-e TAG="--grep ${{ env.TAG }}" \
52+
-e TEST_ENV=${{ env.TEST_ENV }} \
53+
-e BROWSER=${{ env.BROWSER }} \
54+
-e WORKERS=${{ env.WORKERS }} \
55+
-e RETRIES=${{ env.RETRIES }} \
56+
my-playwright-runner \
57+
/bin/bash -c "chmod +x ./run-with-params.sh && npm run test:allure"
3358
34-
- name: Install Allure CLI
35-
run: npm install -g allure-commandline --save-dev
59+
- name: Copy Allure report
60+
run: |
61+
docker cp temp-runner:/app/allure-report ./allure-report || echo "No allure-report found"
62+
docker cp temp-runner:/app/playwright-report/enriched-test-results.json ./playwright-report/enriched-test-results.json || echo "No enriched result found"
63+
docker rm temp-runner
3664
37-
- name: Generate Allure report
38-
run: npm run allure:generate
39-
40-
- name: Upload Allure Report as an Artifact
65+
- name: Upload Allure report
4166
uses: actions/upload-artifact@v4
42-
with:
67+
with:
4368
name: allure-report
44-
path: ./allure-report
69+
path: ./allure-report
70+
71+
- name: Upload Enriched Test Result
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: enriched-test-result
75+
path: ./playwright-report/enriched-test-results.json
76+
77+
- name: Deploy Allure report to GitHub Pages
78+
uses: peaceiris/actions-gh-pages@v3
79+
with:
80+
github_token: ${{ secrets.GITHUB_TOKEN }}
81+
publish_dir: ./allure-report
82+
publish_branch: gh-pages

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ yarn-error.log*
1616
.DS_Store
1717
Thumbs.db
1818

19-
# Environment files
20-
.env
21-
.env.*
2219

2320
# Playwright specific
2421
test-results/

Dockerfile.playwright

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM mcr.microsoft.com/playwright:v1.53.1-jammy
2+
3+
# Install Java 11 (required for Allure)
4+
RUN apt-get update && apt-get install -y wget gnupg2 && \
5+
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor -o /usr/share/keyrings/adoptium.gpg && \
6+
echo "deb [signed-by=/usr/share/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb focal main" | tee /etc/apt/sources.list.d/adoptium.list && \
7+
apt-get update && apt-get install -y temurin-11-jdk && \
8+
rm -rf /var/lib/apt/lists/*
9+
10+
# Install Allure CLI globally
11+
RUN npm install -g allure-commandline --force
12+
13+
# Set JAVA_HOME for Allure
14+
ENV JAVA_HOME=/usr/lib/jvm/temurin-11-jdk-amd64
15+
ENV PATH=$JAVA_HOME/bin:$PATH
16+
17+
# Set working directory
18+
WORKDIR /app
19+
20+
# Copy only package files first to cache layer
21+
COPY package*.json ./
22+
23+
# Install Node dependencies
24+
RUN npm ci
25+
26+
# Copy the rest of the application
27+
COPY . .
28+
29+
# Default CMD is overridden by GitHub Action's docker run step
30+
CMD ["npm", "run", "test:allure"]

README.md

Lines changed: 60 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
21
# 🎭 Playwright Test Automation Framework (TypeScript)
32

4-
This is a robust end-to-end Test Automation Framework built using **Playwright** and **TypeScript**. It supports cross-browser testing, rich reporting using **Allure**, and integrates seamlessly with **GitHub Actions CI/CD pipelines**.
3+
A robust end-to-end Test Automation Framework built with **Playwright** and **TypeScript**.
4+
Supports cross-browser testing, rich reporting with **Allure**, Dockerized execution, and seamless CI/CD via **GitHub Actions** with Allure report publishing to GitHub Pages.
55

66
---
77

@@ -13,15 +13,20 @@ This is a robust end-to-end Test Automation Framework built using **Playwright**
1313
- [Logger Utility](docs/logger.md)
1414
- [Allure Helper](docs/allureHelper.md)
1515
- [Playwright Config](docs/playwright-config.md)
16+
- [CICD](docs/CICD.md)
17+
18+
---
1619

1720
## 🚀 Features
1821

1922
- ✅ TypeScript-based Playwright tests
20-
- ✅ Page Object Model (POM)
23+
- ✅ Page Object Model (POM) for maintainability
2124
- ✅ Parallel execution
2225
- ✅ Cross-browser support (Chromium, Firefox, WebKit)
23-
- ✅ Allure reporting
24-
- ✅ CI/CD via GitHub Actions
26+
- ✅ Allure reporting (HTML, CI artifacts, and GitHub Pages)
27+
- ✅ Docker support for consistent CI/CD runs
28+
- ✅ CI/CD via GitHub Actions (with Docker)
29+
- ✅ GitHub Pages publishing for Allure reports
2530

2631
---
2732

@@ -31,23 +36,48 @@ This is a robust end-to-end Test Automation Framework built using **Playwright**
3136
# Install dependencies
3237
npm ci
3338

34-
# Run all Playwright tests
35-
npx playwright test
39+
# Install Playwright browsers
40+
npx playwright install
41+
42+
# Run all Playwright tests (headless)
43+
npm test
3644

3745
# Run in headed mode
38-
npx playwright test --headed
46+
npm run test:headed
3947

4048
# Generate Allure report
4149
npm run allure:generate
4250

4351
# Open Allure report in browser
4452
npm run allure:open
45-
````
53+
```
54+
55+
---
4656

47-
> Make sure Playwright browsers are installed:
57+
## 🐳 Running Tests in Docker
58+
59+
Build and run tests in a Docker container (as in CI):
4860

4961
```bash
50-
npx playwright install
62+
# Build Docker image
63+
docker build -t my-playwright-runner -f DockerFile.playwright .
64+
65+
# Run tests (Allure report will be generated inside the container)
66+
docker run --rm -v $(pwd)/allure-report:/app/allure-report my-playwright-runner npm run test:allure
67+
```
68+
69+
---
70+
71+
## 📦 NPM Scripts
72+
73+
```json
74+
"scripts": {
75+
"test": "npx playwright test",
76+
"test:headed": "npx playwright test --headed",
77+
"test:allure": "npx playwright test && npm run allure:generate",
78+
"allure:generate": "allure generate --clean allure-results -o allure-report",
79+
"allure:open": "allure open allure-report"
80+
}
5181
```
5282

5383
---
@@ -58,58 +88,55 @@ npx playwright install
5888
e2e-playwright-framework/
5989
├── tests/ # Test specs
6090
├── pages/ # Page Object Models
61-
├── fixtures/ # Shared test fixtures
6291
├── utils/ # Custom utilities
6392
├── storage/ # Session files
6493
├── allure-results/ # Allure raw data
6594
├── allure-report/ # Allure HTML reports
6695
├── playwright.config.ts # Playwright test config
96+
├── DockerFile.playwright # Dockerfile for CI/CD
6797
├── .github/workflows/ # GitHub Actions workflows
6898
```
6999

70100
---
71101

72102
## ✅ GitHub Actions CI/CD
73103

74-
This project uses **GitHub Actions** to automate test execution on each commit or pull request.
104+
This project uses **GitHub Actions** to automate test execution and reporting.
75105

76106
### 📍 When it Runs
77107

78-
* On every push to the `main` branch
79-
* On every pull request
108+
- On every push to `main`, `qa`, `dev`, or any `feature/*` branch
109+
- On every pull request to those branches
110+
- Manually via workflow dispatch
80111

81112
### 📁 Workflow Location
82113

83114
```
84115
.github/workflows/playwright.yml
85116
```
86117

87-
### 📜 Manual Trigger
118+
### 🐳 Docker in CI
88119

89-
1. Go to the **Actions** tab in GitHub.
90-
2. Select the **"Playwright Tests"** workflow.
91-
3. Click **"Run workflow"** (top-right dropdown).
120+
- Builds and runs tests inside a Docker container for consistency
121+
- Generates and uploads Allure reports as CI artifacts
92122

93123
### 📂 CI Artifacts
94124

95-
* 🧪 `playwright-report/` — HTML report of test run
96-
* 📊 `allure-results/` — Raw Allure results
97-
* 📁 `allure-report/` — Rich HTML Allure report (on demand)
125+
- 🧪 `playwright-report/` — HTML report of test run
126+
- 📊 `allure-results/` — Raw Allure results
127+
- 📁 `allure-report/` — Rich HTML Allure report (on demand)
98128

99129
---
100130

101-
## 📦 NPM Scripts
131+
## 🌐 GitHub Pages
102132

103-
Add these to your `package.json`:
133+
![Playwright Tests](https://github.com/ramjangatisetty/e2e-playwright-typescript-framework-template/actions/workflows/playwright.yml/badge.svg)
134+
[![Allure Report](https://img.shields.io/badge/Allure-Report-blue)](https://ramjangatisetty.github.io/e2e-playwright-typescript-framework-template/)
104135

105-
```json
106-
"scripts": {
107-
"test": "npx playwright test",
108-
"test:headed": "npx playwright test --headed",
109-
"allure:generate": "allure generate --clean allure-results",
110-
"allure:open": "allure open allure-report"
111-
}
112-
```
136+
> 🚀 Automated Playwright tests with integrated Allure reporting and GitHub Pages hosting.
137+
138+
- Allure HTML reports are published to GitHub Pages after each CI run.
139+
- Access the latest report [here](https://ramjangatisetty.github.io/e2e-playwright-typescript-framework-template/).
113140

114141
---
115142

@@ -123,4 +150,4 @@ Add these to your `package.json`:
123150

124151
## 📄 License
125152

126-
MIT © 2025 Ramakrishna Jangatisetty
153+
MIT © 2025 Ramakrishna Jangatisetty

0 commit comments

Comments
 (0)