diff --git a/.github/actions/get-score-comments/action.js b/.github/actions/get-score-comments/action.js deleted file mode 100644 index 36e10203..00000000 --- a/.github/actions/get-score-comments/action.js +++ /dev/null @@ -1,101 +0,0 @@ -const core = require('@actions/core'); - -try { - // 점수 지표 파일 정보 - const fs = require('fs'); - const results = JSON.parse(fs.readFileSync('./lhci_reports/manifest.json')); - const totalReports = results.length; - - // LightHouse 점수 지표 - const averageScores = { - performance: 0, - accessibility: 0, - 'best-practices': 0, - seo: 0, - pwa: 0, - }; - const auditSummaries = { - 'first-contentful-paint': 0, - 'largest-contentful-paint': 0, - interactive: 0, - 'total-blocking-time': 0, - 'cumulative-layout-shift': 0, - }; - - // 점수 평균 - results.forEach(result => { - const { summary } = result; - - for (const key in averageScores) { - averageScores[key] += summary[key]; - } - - const details = JSON.parse(fs.readFileSync(result.jsonPath)); - [ - 'first-contentful-paint', - 'largest-contentful-paint', - 'interactive', - 'total-blocking-time', - 'cumulative-layout-shift', - ].forEach(auditName => { - if (details.audits[auditName]) { - const auditDetails = details.audits[auditName]; - auditSummaries[auditName] += parseFloat(auditDetails.displayValue) || 0; - } - }); - }); - - // 점수 색상 표시 - const formatScore = res => (res >= 90 ? '🟢' : res >= 70 ? '🟠' : '🔴'); - - // 상세 지표 점수 색상 표시 - const detailScore = (value, metric) => { - switch (metric) { - case 'first-contentful-paint': - return value <= 1.8 ? '🟢' : value <= 3 ? '🟠' : '🔴'; - case 'largest-contentful-paint': - return value <= 2.5 ? '🟢' : value <= 4 ? '🟠' : '🔴'; - case 'interactive': - return value <= 3.8 ? '🟢' : value <= 7.3 ? '🟠' : '🔴'; - case 'total-blocking-time': - return value <= 300 ? '🟢' : value <= 600 ? '🟠' : '🔴'; - case 'cumulative-layout-shift': - return value <= 0.1 ? '🟢' : value <= 0.25 ? '🟠' : '🔴'; - default: - return '🔴'; // Default to red if metric is unknown - } - }; - - // comments 파싱 - let comments = - '⚡️ Lighthouse Average Scores Across Reports:\n| Category | Score |\n| --- | --- |\n'; - Object.keys(averageScores).forEach(key => { - const avgScore = Math.round((averageScores[key] / totalReports) * 100); - comments += `| ${formatScore(avgScore)} ${key.replace( - /-/g, - ' ' - )} | ${avgScore} |\n`; - }); - - comments += - '\n⚡️ Average Details Across All Reports:\n| Category | Score |\n| --- | --- |\n'; - Object.keys(auditSummaries).forEach(auditName => { - const average = auditSummaries[auditName] / totalReports; - const formattedName = auditName.replace(/-/g, ' '); - const colorCode = detailScore(average, auditName); - const unit = - auditName === 'total-blocking-time' - ? 'ms' - : auditName === 'cumulative-layout-shift' - ? '' - : 's'; - comments += `| ${colorCode} ${formattedName} | ${average.toFixed( - 1 - )}${unit} |\n`; - }); - - // comments 내보내기 - core.setOutput('comments', comments); -} catch (error) { - console.error(error); -} diff --git a/.github/actions/get-score-comments/action.yml b/.github/actions/get-score-comments/action.yml deleted file mode 100644 index ca1bb5e7..00000000 --- a/.github/actions/get-score-comments/action.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: 'get-score-comments' -description: 'Get Score Comments' - -outputs: - comments: - description: 'Comments that Parsed Scores' - -runs: - using: 'node16' - main: 'action.js' diff --git a/.github/workflows/lighthouse.yml b/.github/workflows/lighthouse.yml deleted file mode 100644 index 2bbe185a..00000000 --- a/.github/workflows/lighthouse.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: LightHouse CI - -on: - pull_request: - branches: - - main - -jobs: - lhci: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Use Node.js 18 - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'yarn' - - - name: Install packages - run: yarn install && yarn global add @lhci/cli@0.13.x && yarn add @actions/core - - - name: Set .env - run: echo "${{ vars.DEVELOPMENT_ENV }}" > .env.local - - - name: Build - run: yarn build - - - name: Run Lighthouse CI - run: lhci autorun - env: - LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} - - - name: Get Score Comments - id: get-score-comments - uses: ./.github/actions/get-score-comments - - - name: Find Comment - if: github.event_name == 'pull_request' - uses: peter-evans/find-comment@v2 - id: find_comment - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: ⚡️ Lighthouse Average Scores Across Reports - - - name: Create or update comment - if: github.event_name == 'pull_request' - uses: peter-evans/create-or-update-comment@v2 - with: - comment-id: ${{ steps.find_comment.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: ${{ steps.get-score-comments.outputs.comments }} - edit-mode: replace diff --git a/lighthouserc.js b/lighthouserc.js deleted file mode 100644 index d4ff0899..00000000 --- a/lighthouserc.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - ci: { - collect: { - startServerCommand: 'yarn next start', - startServerReadyPattern: 'ready on', - url: [ - 'http://localhost:3000/bookarchive', - 'http://localhost:3000/book/search', - 'http://localhost:3000/group', - 'http://localhost:3000/profile/me', - ], - numberOfRuns: 2, - }, - upload: { - target: 'filesystem', - outputDir: './lhci_reports', - reportFilenamePattern: '%%PATHNAME%%-%%DATETIME%%-report.%%EXTENSION%%', - }, - }, -}; diff --git a/package.json b/package.json index 7ad013b0..3ff3268b 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "postinstall": "patch-package" }, "dependencies": { - "@actions/core": "^1.10.1", "@chakra-ui/icons": "^2.0.17", "@chakra-ui/react": "^2.4.9", "@emotion/react": "^11.10.5", diff --git a/yarn.lock b/yarn.lock index 7fa1e964..bfab78ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,22 +2,6 @@ # yarn lockfile v1 -"@actions/core@^1.10.1": - version "1.10.1" - resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.1.tgz#61108e7ac40acae95ee36da074fa5850ca4ced8a" - integrity sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g== - dependencies: - "@actions/http-client" "^2.0.1" - uuid "^8.3.2" - -"@actions/http-client@^2.0.1": - version "2.2.1" - resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.2.1.tgz#ed3fe7a5a6d317ac1d39886b0bb999ded229bb38" - integrity sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw== - dependencies: - tunnel "^0.0.6" - undici "^5.25.4" - "@alloc/quick-lru@^5.2.0": version "5.2.0" resolved "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz" @@ -3014,11 +2998,6 @@ resolved "https://registry.npmjs.org/@fal-works/esbuild-plugin-global-externals/-/esbuild-plugin-global-externals-2.1.2.tgz" integrity sha512-cEee/Z+I12mZcFJshKcCqC8tuX5hG3s+d+9nZ3LabqKF1vKdF41B92pJVCBggjAGORAeOzyyDDKrZwIkLffeOQ== -"@fastify/busboy@^2.0.0": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d" - integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA== - "@headlessui/react@^1.7.15": version "1.7.15" resolved "https://registry.npmjs.org/@headlessui/react/-/react-1.7.15.tgz" @@ -12194,11 +12173,6 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" -tunnel@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" - integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg== - tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz" @@ -12283,13 +12257,6 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" -undici@^5.25.4: - version "5.28.4" - resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.4.tgz#6b280408edb6a1a604a9b20340f45b422e373068" - integrity sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g== - dependencies: - "@fastify/busboy" "^2.0.0" - unfetch@^4.2.0: version "4.2.0" resolved "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz" @@ -12466,11 +12433,6 @@ uuid@^3.3.2: resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== -uuid@^8.3.2: - version "8.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" - integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== - uuid@^9.0.0: version "9.0.0" resolved "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz"