Skip to content

Commit df92bc1

Browse files
author
jyn
committed
Merge branch 'dev'
2 parents 7baa3ca + f29be9f commit df92bc1

File tree

10 files changed

+2187
-12
lines changed

10 files changed

+2187
-12
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Lighthouse CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lighthouse:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '18'
21+
22+
- name: Setup pnpm
23+
uses: pnpm/action-setup@v4
24+
with:
25+
version: 8
26+
27+
- name: Get pnpm store directory
28+
shell: bash
29+
run: |
30+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
31+
32+
- name: Setup pnpm cache
33+
uses: actions/cache@v4
34+
with:
35+
path: ${{ env.STORE_PATH }}
36+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
37+
restore-keys: |
38+
${{ runner.os }}-pnpm-store-
39+
40+
- name: Install dependencies
41+
run: pnpm install --frozen-lockfile
42+
43+
- name: Run Lighthouse CI
44+
run: pnpm lighthouse:ci
45+
46+
- name: Upload Lighthouse results
47+
uses: actions/upload-artifact@v4
48+
if: always()
49+
with:
50+
name: lighthouse-results
51+
path: .lighthouseci/
52+
retention-days: 30
53+
54+
- name: Comment PR with Lighthouse results
55+
if: github.event_name == 'pull_request'
56+
uses: actions/github-script@v7
57+
with:
58+
script: |
59+
const fs = require('fs');
60+
const path = require('path');
61+
62+
try {
63+
const resultsPath = '.lighthouseci/assertion-results.json';
64+
if (fs.existsSync(resultsPath)) {
65+
const results = JSON.parse(fs.readFileSync(resultsPath, 'utf8'));
66+
67+
let comment = '## 🚀 Lighthouse CI Results\n\n';
68+
69+
if (results.length === 0) {
70+
comment += '✅ All Lighthouse checks passed!\n';
71+
} else {
72+
comment += '⚠️ Some Lighthouse checks failed:\n\n';
73+
results.forEach(result => {
74+
const status = result.passed ? '✅' : '❌';
75+
comment += `${status} **${result.auditTitle}**: ${result.actual}ms (기준: ${result.expected}ms)\n`;
76+
});
77+
}
78+
79+
comment += '\n📊 [View detailed report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})';
80+
81+
github.rest.issues.createComment({
82+
issue_number: context.issue.number,
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
body: comment
86+
});
87+
}
88+
} catch (error) {
89+
console.log('Error creating comment:', error);
90+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ yarn-error.log*
3939
# typescript
4040
*.tsbuildinfo
4141
next-env.d.ts
42+
43+
# lighthouse ci
44+
.lighthouseci/

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
# Nomadia
2+
3+
노마디아

lighthouserc.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module.exports = {
2+
ci: {
3+
collect: {
4+
// 실제 배포 URL 사용 (포트 충돌 방지)
5+
url: ['https://nomadia-two.vercel.app/'],
6+
7+
// 또는 다른 포트 사용
8+
// startServerCommand: 'pnpm start --port 3001',
9+
// startServerReadyPattern: 'ready on',
10+
// url: ['http://localhost:3001'],
11+
numberOfRuns: 3,
12+
},
13+
assert: {
14+
// 성능 기준 설정
15+
assertions: {
16+
'categories:performance': ['warn', { minScore: 0.5 }],
17+
'categories:accessibility': ['error', { minScore: 0.5 }],
18+
'categories:best-practices': ['warn', { minScore: 0.5 }],
19+
'categories:seo': ['warn', { minScore: 0.5 }],
20+
// 특정 메트릭 기준 설정
21+
'first-contentful-paint': ['warn', { maxNumericValue: 3000 }],
22+
'largest-contentful-paint': ['warn', { maxNumericValue: 5000 }],
23+
'cumulative-layout-shift': ['warn', { maxNumericValue: 0.1 }],
24+
'total-blocking-time': ['warn', { maxNumericValue: 500 }],
25+
},
26+
},
27+
upload: {
28+
// 업로드 비활성화 (토큰 없이 로컬에서만 실행)
29+
target: 'filesystem',
30+
},
31+
},
32+
};

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
"lint:fix": "next lint --fix",
1111
"format": "prettier --write .",
1212
"format:check": "prettier --check .",
13-
"prepare": "husky"
13+
"prepare": "husky",
14+
"lighthouse": "lhci autorun",
15+
"lighthouse:collect": "lhci collect",
16+
"lighthouse:assert": "lhci assert",
17+
"lighthouse:upload": "lhci upload",
18+
"lighthouse:ci": "pnpm lighthouse",
19+
"lighthouse:open": "open .lighthouseci/lhr-*.html",
20+
"lighthouse:results": "echo 'Lighthouse 결과 파일:' && ls -la .lighthouseci/"
1421
},
1522
"lint-staged": {
1623
"*.{js,jsx,ts,tsx}": [
@@ -44,6 +51,7 @@
4451
},
4552
"devDependencies": {
4653
"@eslint/eslintrc": "^3",
54+
"@lhci/cli": "^0.15.1",
4755
"@next/eslint-plugin-next": "^15.3.5",
4856
"@tailwindcss/postcss": "^4",
4957
"@types/node": "^20",

0 commit comments

Comments
 (0)