Skip to content

Commit f6e1d19

Browse files
authored
Dev ci/cd (#7)
1 parent 6f5728e commit f6e1d19

20 files changed

Lines changed: 503 additions & 139 deletions

.cursor/rules/github-actions.mdc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
alwaysApply: false
3+
---
4+
5+
## Github Action Rules
6+
7+
- Check if `package.json` exists in project root and summarize key scripts
8+
- Check if `.nvmrc` exists in project root
9+
- Check if `.env.example` exists in project root to identify key `env:` variables
10+
- Always use `git branch -a | cat` to verify whether we use `main` or `master` branch
11+
- Always use `env:` variables and secrets attached to jobs instead of global workflows
12+
- Always use `npm ci` for Node-based dependency setup
13+
- Extract common steps into composite actions in separate files
14+
- Once you're done, as a final step conduct the following:
15+
16+
1. For each public action always use <tool>"Run Terminal"</tool> to see what is the most up-to-date version (use only major version):
17+
18+
```bash
19+
curl -s https://api.github.com/repos/{owner}/{repo}/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([0-9]+).*/\1/'
20+
```
21+
22+
2. (Ask if needed) Use <tool>"Run Terminal"</tool> to fetch README.md and see if we're not using any deprecated actions by mistake:
23+
24+
```bash
25+
curl -s https://raw.githubusercontent.com/{owner}/{repo}/refs/tags/v{TAG_VERSION}/README.md
26+
```
27+
28+
3. (Ask if needed) Use <tool>"Run Terminal"</tool> to fetch repo metadata and see if we're not using any deprecated actions by mistake:
29+
30+
```bash
31+
curl -s https://api.github.com/repos/{owner}/{repo} | grep '"archived":'
32+
```
33+
34+
4. (Ask if needed) In case of linter issues related to action parameters, try to fetch action description directly from GitHub and use the following command:
35+
36+
```bash
37+
curl -s https://raw.githubusercontent.com/{owner}/{repo}/refs/heads/{main/master}/action.yml
38+
```

.env.test.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ NEXT_PUBLIC_SUPABASE_ANON_KEY=
33
SUPABASE_ACCESS_TOKEN=
44
E2E_USERNAME_ID=
55
E2E_USERNAME=
6-
E2E_PASSWORD=
6+
E2E_PASSWORD=

.github/workflows/pull-request.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Pull Request
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- ready_for_review
10+
11+
env:
12+
CI: "true"
13+
14+
jobs:
15+
lint:
16+
name: Lintowanie
17+
runs-on: ubuntu-latest
18+
environment: Integration
19+
env:
20+
NODE_ENV: development
21+
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
22+
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
23+
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
24+
steps:
25+
- name: Checkout repo
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v5
30+
with:
31+
node-version-file: .nvmrc
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Run lint
37+
run: npm run lint
38+
39+
unit-test:
40+
name: Unit tests (coverage)
41+
runs-on: ubuntu-latest
42+
needs: lint
43+
environment: Integration
44+
env:
45+
NODE_ENV: development
46+
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
47+
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
48+
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
49+
steps:
50+
- name: Checkout repo
51+
uses: actions/checkout@v4
52+
53+
- name: Setup Node.js
54+
uses: actions/setup-node@v5
55+
with:
56+
node-version-file: .nvmrc
57+
58+
- name: Install dependencies
59+
run: npm ci
60+
61+
- name: Run unit tests with coverage
62+
run: npm run test:coverage
63+
64+
- name: Upload unit test coverage
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: vitest-coverage
68+
path: coverage
69+
70+
e2e-test:
71+
name: Playwright E2E tests
72+
runs-on: ubuntu-latest
73+
needs: lint
74+
environment: Tests
75+
env:
76+
NODE_ENV: development
77+
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
78+
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
79+
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
80+
E2E_USERNAME_ID: ${{ secrets.E2E_USERNAME_ID }}
81+
E2E_USERNAME: ${{ secrets.E2E_USERNAME }}
82+
E2E_PASSWORD: ${{ secrets.E2E_PASSWORD }}
83+
steps:
84+
- name: Checkout repo
85+
uses: actions/checkout@v4
86+
87+
- name: Setup Node.js
88+
uses: actions/setup-node@v5
89+
with:
90+
node-version-file: .nvmrc
91+
92+
- name: Install dependencies
93+
run: npm ci
94+
95+
- name: Install Playwright browsers
96+
run: npx playwright install chromium
97+
98+
- name: Run Playwright tests
99+
run: npm run test:e2e
100+
101+
- name: Upload Playwright report
102+
uses: actions/upload-artifact@v4
103+
with:
104+
name: playwright-report
105+
path: playwright-report
106+
107+
status-comment:
108+
name: Status PR
109+
runs-on: ubuntu-latest
110+
needs:
111+
- lint
112+
- unit-test
113+
- e2e-test
114+
permissions:
115+
contents: write
116+
pull-requests: write
117+
steps:
118+
- name: Comment PR status
119+
uses: peter-evans/create-or-update-comment@v5
120+
with:
121+
issue-number: ${{ github.event.pull_request.number }}
122+
body: |
123+
✅ Wszystkie kontrole zakończone pomyślnie.
124+
- Lintowanie: ✅
125+
- Testy jednostkowe (z coverage): ✅
126+
- Testy end-to-end: ✅

PLAYWRIGHT_CONFIG_EXPLAINED.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,54 @@
33
## 🎯 Kluczowe ustawienia
44

55
### `fullyParallel: false`
6+
67
**Co to robi:** Testy uruchamiają się jeden po drugim
78
**Dlaczego:** Łatwiej debugować na początku. Zmień na `true` gdy będziesz mieć dużo stabilnych testów.
89

910
### `workers: 1`
11+
1012
**Co to robi:** Tylko jedna przeglądarka w tym samym czasie
1113
**Dlaczego:** Stabilniejsze, łatwiej śledzić co się dzieje
1214

1315
### `trace: "on"`
16+
1417
**Co to robi:** Zapisuje każdy krok testu (kliknięcia, nawigacja, itp.)
1518
**Jak zobaczyć:** `npx playwright show-trace playwright-report/trace.zip`
1619
**Kiedy:** Zawsze - zobaczysz dokładnie co poszło nie tak
1720

1821
### `screenshot: "only-on-failure"`
22+
1923
**Co to robi:** Robi zdjęcie ekranu gdy test failuje
2024
**Gdzie:** `playwright-report/` folder
2125

2226
### `video: "off"`
27+
2328
**Co to robi:** Nie nagrywa wideo
2429
**Dlaczego:** Trace + screenshoty wystarczą, wideo zajmuje dużo miejsca
2530
**Kiedy włączyć:** Jak będziesz mieć bardzo trudny do zreprodukowania bug
2631

2732
### `baseURL: "http://localhost:3000"`
33+
2834
**Co to robi:** Możesz pisać `page.goto('/')` zamiast `page.goto('http://localhost:3000/')`
2935
**Przykład:**
36+
3037
```typescript
3138
// Zamiast tego:
32-
await page.goto('http://localhost:3000/dashboard');
39+
await page.goto("http://localhost:3000/dashboard");
3340

3441
// Piszesz:
35-
await page.goto('/dashboard');
42+
await page.goto("/dashboard");
3643
```
3744

3845
### `webServer`
46+
3947
**Co to robi:** Automatycznie uruchamia `npm run dev` przed testami
4048
**Bonus:** `reuseExistingServer: true` - jeśli masz już uruchomiony dev server, użyje go (szybciej)
4149

4250
## 🚀 Jak używać
4351

4452
### Pierwszy test
53+
4554
```bash
4655
# Uruchom testy E2E
4756
npm run test:e2e
@@ -52,6 +61,7 @@ npm run test:e2e
5261
```
5362

5463
### Gdy test failuje
64+
5565
```bash
5666
# Playwright automatycznie:
5767
# 1. Zrobi screenshot → playwright-report/
@@ -68,6 +78,7 @@ npm run test:e2e:report
6878
```
6979

7080
### Debugowanie
81+
7182
```bash
7283
# Tryb debug - zatrzymuje test i pokazuje przeglądarkę
7384
npm run test:e2e:debug
@@ -83,26 +94,32 @@ npm run test:e2e:ui
8394
## 💡 Tipsy
8495

8596
### 1. Zacznij od prostych testów
97+
8698
```typescript
87-
test('should load homepage', async ({ page }) => {
88-
await page.goto('/');
99+
test("should load homepage", async ({ page }) => {
100+
await page.goto("/");
89101
await expect(page).toHaveTitle(/Pathly/);
90102
});
91103
```
92104

93105
### 2. Używaj UI mode podczas pisania testów
106+
94107
```bash
95108
npm run test:e2e:ui
96109
```
110+
97111
Zobaczysz na żywo co robi Twój test!
98112

99113
### 3. Trace to Twój najlepszy przyjaciel
114+
100115
Gdy test failuje:
116+
101117
1. Otwórz `npm run test:e2e:report`
102118
2. Kliknij na failed test
103119
3. Zobacz trace - zobaczysz DOKŁADNIE co się stało, krok po kroku
104120

105121
### 4. Nie martw się o wydajność na początku
122+
106123
- `workers: 1` jest OK
107124
- `fullyParallel: false` jest OK
108125
- `trace: "on"` jest OK
@@ -112,18 +129,21 @@ Optymalizujesz później, gdy będziesz mieć dużo testów.
112129
## 🎨 Kiedy zmienić ustawienia
113130

114131
### Masz już 10+ stabilnych testów?
132+
115133
```typescript
116134
fullyParallel: true, // Szybsze testy
117135
workers: 4, // 4 przeglądarki naraz
118136
trace: "retain-on-failure", // Trace tylko przy failach
119137
```
120138

121139
### Potrzebujesz wideo?
140+
122141
```typescript
123142
video: "retain-on-failure", // Tylko przy failach
124143
```
125144

126145
### Testujesz mobile?
146+
127147
```typescript
128148
projects: [
129149
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
@@ -147,4 +167,3 @@ A: To "nagranie" testu - każdy klik, nawigacja, assertion. Bezcenne przy debugo
147167

148168
**Q: Muszę testować na Firefox/Safari?**
149169
A: Na początku nie. Chromium wystarczy. Dodasz później jeśli będzie potrzeba.
150-

0 commit comments

Comments
 (0)