Skip to content

Commit 26a0f2a

Browse files
committed
add main ci/cd
1 parent d50bdef commit 26a0f2a

2 files changed

Lines changed: 151 additions & 5 deletions

File tree

.cursor/rules/github-actions.mdc

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,35 @@ alwaysApply: false
44

55
## Github Action Rules
66

7-
### Version Verification
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:
815

9-
1. Identify public actions used within the workflow
10-
2. For each action always check what is the most up-to-date version with the following command:
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):
1117

1218
```bash
1319
curl -s https://api.github.com/repos/{owner}/{repo}/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([0-9]+).*/\1/'
1420
```
1521

16-
### Setup Node
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:
1723

18-
Always check the version of `.nvmrc` in the project to make sure Node is correct (hardcoded LTS or version from file - if it exists).
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+
```

.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: ✅

0 commit comments

Comments
 (0)