Skip to content

Commit c7cd709

Browse files
committed
tests workflow implementation
1 parent 4392324 commit c7cd709

File tree

5 files changed

+278
-0
lines changed

5 files changed

+278
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy to Vercel
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch: # Allow manual triggering
7+
8+
jobs:
9+
deploy:
10+
name: Build, Test, and Deploy
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: '20'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Run unit tests
27+
run: npm test
28+
29+
- name: Build app
30+
run: npm run build
31+
32+
- name: Deploy to Vercel
33+
uses: amondnet/vercel-action@v25
34+
with:
35+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
36+
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
37+
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
vercel-args: '--prod'

.github/workflows/e2e-tests.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: End-to-End Tests
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
workflow_dispatch: # Allow manual triggering
7+
8+
jobs:
9+
e2e-tests:
10+
name: Run End-to-End Tests
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: '20'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Install Playwright browsers
27+
run: npx playwright install --with-deps
28+
29+
- name: Run unit tests
30+
run: npm test
31+
32+
- name: Build app
33+
run: npm run build
34+
35+
- name: Start server and run E2E tests
36+
run: |
37+
npx vite preview --port 5173 &
38+
sleep 5
39+
npx playwright test
40+
41+
- name: Upload test results
42+
if: always()
43+
uses: actions/upload-artifact@v3
44+
with:
45+
name: playwright-report
46+
path: playwright-report/
47+
retention-days: 7

.github/workflows/unit-tests.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches: [ main, dev ]
6+
pull_request:
7+
branches: [ main, dev ]
8+
9+
jobs:
10+
test:
11+
name: Run Unit Tests
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: '20'
22+
cache: 'npm'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Run unit tests
28+
run: npm test
29+
30+
- name: Upload test results
31+
if: always()
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: unit-test-results
35+
path: ./coverage
36+
retention-days: 7

CI_CD.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# CI/CD Workflow for Password Generator
2+
3+
This document explains the Continuous Integration and Continuous Deployment (CI/CD) workflows set up for the Password Generator project.
4+
5+
## CI/CD Overview
6+
7+
We've implemented two GitHub Actions workflows for testing:
8+
9+
1. **Unit Tests**: Runs on every push and pull request
10+
2. **End-to-End Tests**: Runs on pull requests to the main branch
11+
12+
Deployment is handled automatically by Vercel.
13+
14+
## Workflow Details
15+
16+
### Unit Tests Workflow
17+
18+
**File**: `.github/workflows/unit-tests.yml`
19+
20+
This workflow runs on every push to main/dev branches and on all pull requests. It:
21+
- Sets up Node.js
22+
- Installs dependencies
23+
- Runs unit tests with Vitest
24+
- Uploads test results as artifacts
25+
26+
### End-to-End Tests Workflow
27+
28+
**File**: `.github/workflows/e2e-tests.yml`
29+
30+
This workflow runs on pull requests to the main branch. It:
31+
- Sets up Node.js
32+
- Installs dependencies and Playwright browsers
33+
- Runs unit tests
34+
- Builds the application
35+
- Starts a server and runs E2E tests with Playwright
36+
- Uploads test results as artifacts
37+
38+
### Deployment
39+
40+
Deployment is handled automatically by Vercel. When changes are pushed to the main branch, Vercel automatically:
41+
- Detects the changes
42+
- Builds the application
43+
- Deploys to production at [passwords.roga.dev](https://passwords.roga.dev)
44+
45+
No additional GitHub Actions workflow is needed for deployment.
46+
47+
## Pull Request Flow
48+
49+
When submitting a pull request to the main branch:
50+
51+
1. The **Unit Tests** workflow runs immediately
52+
2. The **End-to-End Tests** workflow runs to verify all functionality
53+
3. Once merged, Vercel automatically deploys the changes
54+
55+
## Manual Triggering
56+
57+
The E2E Tests workflow can be triggered manually from the GitHub Actions tab if needed.
58+
59+
## Artifacts
60+
61+
Test results and reports are saved as artifacts for each workflow run:
62+
- Unit test results are available for 7 days
63+
- E2E test reports are available for 7 days
64+
65+
These can be accessed from the workflow run page in the GitHub Actions tab.

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,94 @@
11
# RogaDev Password Generator
22

33
A very simple, lightweight password generator that I built in an couple hours. It takes a few parameters that allow you to decide whether you'll have special characters, capital and/or lower case letters, and numbers. Click to save to clipboard.
4+
5+
The live application is available at [passwords.roga.dev](https://passwords.roga.dev).
6+
7+
## Features
8+
9+
- Generate random, secure passwords
10+
- Customize password options (length, character sets)
11+
- Exclude specific characters
12+
- Apply common password rules
13+
- Copy to clipboard with one click
14+
- Network activity monitoring
15+
- Fully client-side (no server requirements)
16+
- URL parameter support for sharing configurations
17+
18+
## Development
19+
20+
### Installation
21+
22+
```bash
23+
# Clone the repository
24+
git clone https://github.com/yourusername/roga-password-generator.git
25+
26+
# Navigate to the project directory
27+
cd roga-password-generator
28+
29+
# Install dependencies
30+
npm install
31+
```
32+
33+
### Running the Application
34+
35+
```bash
36+
# Start the development server
37+
npm run dev
38+
39+
# Build for production
40+
npm run build
41+
42+
# Preview the production build
43+
npm run preview
44+
```
45+
46+
### Testing
47+
48+
This project uses Vitest for unit testing and Playwright for end-to-end testing.
49+
50+
```bash
51+
# Run unit tests
52+
npm test
53+
54+
# Run unit tests in watch mode
55+
npm run test:watch
56+
57+
# Run end-to-end tests
58+
npm run test:e2e
59+
60+
# Run end-to-end tests with UI
61+
npm run test:e2e:ui
62+
```
63+
64+
For more information on testing, see [TESTING.md](TESTING.md).
65+
66+
### CI/CD
67+
68+
This project uses GitHub Actions for continuous integration and Vercel for continuous deployment. The GitHub Actions workflows run tests automatically, and Vercel handles deployment when changes are merged to the main branch.
69+
70+
For more information on the CI/CD workflow, see [CI_CD.md](CI_CD.md).
71+
72+
## URL Parameters
73+
74+
You can configure the password generator via URL parameters:
75+
76+
```
77+
?len=24 # Set password length to 24
78+
?exLower # Exclude lowercase letters
79+
?exNum # Exclude numbers
80+
?exUpper # Exclude uppercase letters
81+
?exSym # Exclude symbols
82+
?exc=abc123 # Exclude specific characters
83+
?ruleNoLead # Disallow leading numbers/symbols
84+
```
85+
86+
Parameters can be combined:
87+
88+
```
89+
?len=18&exUpper&exSym&ruleNoLead&exc=xyz789
90+
```
91+
92+
## License
93+
94+
MIT

0 commit comments

Comments
 (0)