Skip to content

Commit ca453da

Browse files
authored
MPI-159: Introduce git actions - linting (#52)
* feat: Add TypeScript compilation checks and ESLint to workflows - Introduced TypeScript compilation checks in firebase-deployment.yml, lint.yml, and playwright-tests.yml to ensure type safety. - Added ESLint step to lint.yml and playwright-tests.yml for consistent code quality. - Removed unused imports in BreathingExercise.spec.ts and WidgetConfiguration.spec.ts for cleaner test files. - Cleaned up widgetConfigHelpers.ts by removing unnecessary TestData import. * docs: Update README to include CI/CD pipeline details - Added comprehensive section on CI/CD pipeline utilizing GitHub Actions. - Documented workflows for lint validation, Playwright tests, and Firebase deployments. - Clarified triggers, purposes, and benefits of each workflow. - Included local development instructions to catch issues early.
1 parent 02eef23 commit ca453da

7 files changed

Lines changed: 113 additions & 8 deletions

File tree

.github/workflows/firebase-deployment.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
- name: Run Linting
3333
run: npm run lint
3434

35+
- name: Check TypeScript compilation
36+
run: npx tsc --noEmit
37+
3538
- name: Build Application
3639
run: npm run build
3740
env:

.github/workflows/lint.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Lint Validation
2+
3+
on:
4+
pull_request:
5+
branches: [main, master]
6+
push:
7+
branches: [main, master]
8+
9+
jobs:
10+
lint:
11+
name: Run ESLint
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: "18"
22+
cache: "npm"
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Run ESLint
28+
run: npm run lint
29+
30+
- name: Check TypeScript compilation
31+
run: npx tsc --noEmit

.github/workflows/playwright-tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ jobs:
2626
- name: Install dependencies
2727
run: npm ci
2828

29+
- name: Run ESLint
30+
run: npm run lint
31+
32+
- name: Check TypeScript compilation
33+
run: npx tsc --noEmit
34+
2935
- name: Install Playwright Browsers
3036
run: npx playwright install chromium
3137

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,77 @@ Deploys when pushing a tag with the `prod-` prefix.
9191
2. View deployment: https://rainbowrelax.web.app
9292
3. Monitor status: **Actions > Deploy to Firebase PROD**
9393

94+
---
95+
# CI/CD Pipeline
96+
97+
This project uses GitHub Actions for automated testing, linting, and deployment. All workflows run on pull requests and pushes to ensure code quality.
98+
99+
## Workflows
100+
101+
### 1. Lint Validation (`lint.yml`)
102+
- **Triggers**: Pull requests and pushes to `main`
103+
- **Purpose**: Validates code quality before merge
104+
- **Runs**: ESLint and TypeScript compilation checks
105+
- **Duration**: ~2-3 minutes
106+
- **Benefit**: Prevents linting errors from reaching main branch, avoiding deployment failures
107+
108+
### 2. Playwright Tests (`playwright-tests.yml`)
109+
- **Triggers**: Pull requests and pushes to `main`
110+
- **Purpose**: Run end-to-end tests to ensure functionality
111+
- **Runs**:
112+
- ESLint validation
113+
- TypeScript compilation
114+
- Build application
115+
- Run all 84+ E2E tests (using 4 parallel workers)
116+
- **Duration**: ~5-7 minutes
117+
- **Benefit**: Comprehensive validation before merge and deployment
118+
119+
### 3. Firebase Deployment Workflows
120+
121+
All deployment workflows use the reusable `firebase-deployment.yml` workflow which ensures:
122+
1. ✅ ESLint validation passes
123+
2. ✅ TypeScript compilation succeeds
124+
3. ✅ Application builds successfully
125+
4. ✅ Only validated code reaches production
126+
127+
#### Development Deployment (`firebase-dev.yml`)
128+
- **Triggers**: Push to `main` branch
129+
- **Includes**: Full validation (linting, TypeScript, build)
130+
- **Deploy**: Automatically to `rainbowrelax-dev` site
131+
- **URL**: https://rainbowrelax-dev.web.app
132+
133+
#### QA Deployment (`firebase-qa.yml`)
134+
- **Triggers**: Push tag matching `qa-*` pattern
135+
- **Includes**: Full validation before deployment
136+
- **Deploy**: To `rainbowrelax-qa` site
137+
- **URL**: https://rainbowrelax-qa.web.app
138+
139+
#### Production Deployment (`firebase-prod.yml`)
140+
- **Triggers**: Push tag matching `prod-*` pattern
141+
- **Includes**: Full validation before deployment
142+
- **Deploy**: To `rainbowrelax` site
143+
- **URL**: https://rainbowrelax.web.app
144+
145+
## Workflow Integration
146+
147+
The CI/CD pipeline ensures that:
148+
- **Pull Requests**: Lint validation and tests run automatically
149+
- **Main Branch**: All validations pass before any deployment
150+
- **Deployments**: Only validated code reaches DEV, QA, and PROD environments
151+
152+
This prevents duplicate PRs caused by linting failures and ensures only tested, validated code is deployed.
153+
154+
## Local Development
155+
156+
Before pushing, run locally to catch issues early:
157+
158+
```bash
159+
npm run lint # Check for linting errors
160+
npx tsc --noEmit # Verify TypeScript compilation
161+
npm run build # Verify build works
162+
npm run test:e2e # Run all tests
163+
```
164+
94165
---
95166
# Audio Credits
96167

tests/e2e/BreathingExercise.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, test } from '@playwright/test';
22
import TestData from '../fixtures/testData';
3-
import { waitForBreathingExerciseToStart, waitForBreathingInstructions } from '../fixtures/testHelpers';
3+
import { waitForBreathingExerciseToStart } from '../fixtures/testHelpers';
44

55
test.describe('Breathing Exercise', () => {
66
test.beforeEach(async ({ page }) => {

tests/e2e/WidgetConfiguration.spec.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ import { WidgetConfigPage } from '../page-objects';
33
import TestData from '../fixtures/testData';
44
import {
55
verifyCustomLogo,
6-
verifyDefaultLogo,
7-
verifyButtonHidden,
8-
verifyButtonLink,
9-
verifyButtonVisible,
10-
verifyAssetRequest,
11-
verifyAssetRequestFailed
6+
verifyDefaultLogo
127
} from '../fixtures/widgetConfigHelpers';
138
import { closeQuickEscapeModal } from '../fixtures/testHelpers';
149

tests/fixtures/widgetConfigHelpers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Page, expect } from '@playwright/test';
2-
import TestData from './testData';
32

43
/**
54
* Widget Configuration Helper Functions

0 commit comments

Comments
 (0)