diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml deleted file mode 100644 index 893c6a8..0000000 --- a/.github/workflows/performance.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: Run lighthouse CI When Push -on: [pull_request] - -jobs: - lhci: - name: Lighthouse CI - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '18' - - - name: Install packages - run: | - yarn install - - - name: Build - run: CI=false yarn build - - - name: Run Lighthouse CI - env: - LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} - run: | - npm install -g @lhci/cli - lhci autorun || true - - - name: Format lighthouse score - id: format_lighthouse_score - uses: actions/github-script@v3 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const fs = require('fs'); - const results = JSON.parse(fs.readFileSync('./lhci_reports/manifest.json')); - let comments = ""; - - results.forEach((result) => { - const { - summary, - jsonPath - } = result; - const details = JSON.parse(fs.readFileSync(jsonPath)); - const { - audits - } = details; - const formatResult = (res) => Math.round(res * 100); - - Object.keys(summary).forEach( - (key) => (summary[key] = formatResult(summary[key])) - ); - - const score = (res) => (res >= 90 ? "๐ŸŸข" : res >= 50 ? "๐ŸŸ " : "๐Ÿ”ด"); - - const comment = [ - `โšก๏ธ Lighthouse report!`, - `| Category | Score |`, - `| --- | --- |`, - `| ${score(summary.performance)} Performance | ${summary.performance} |`, - `| ${score(summary.accessibility)} Accessibility | ${summary.accessibility} |`, - `| ${score(summary["best-practices"])} Best Practices | ${summary["best-practices"]} |`, - `| ${score(summary.seo)} SEO | ${summary.seo} |`, - `| ${score(summary.pwa)} PWA | ${summary.pwa} |`, - ].join("\n"); - - const detail = [ - `| Category | Score |`, - `| --- | --- |`, - `| ${score( - audits["first-contentful-paint"].score * 100 - )} First Contentful Paint | ${ - audits["first-contentful-paint"].displayValue - } |`, - `| ${score( - audits["largest-contentful-paint"].score * 100 - )} Largest Contentful Paint | ${ - audits["largest-contentful-paint"].displayValue - } |`, - ].join("\n"); - comments += comment + "\n" + detail + "\n"; - }); - core.setOutput('comments', comments) - - - name: comment PR - uses: unsplash/comment-on-pr@v1.3.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - msg: ${{ steps.format_lighthouse_score.outputs.comments}} \ No newline at end of file diff --git a/.lighthouserc.json b/.lighthouserc.json index f2e5b5d..58ea837 100644 --- a/.lighthouserc.json +++ b/.lighthouserc.json @@ -1,35 +1,35 @@ { - "ci": { - "collect": { - "startServerCommand": "yarn start", - "startServerReadyPattern": "ready on", - "url": [ - "http://localhost:3000", - "http://localhost:3000/profile", - "http://localhost:3000/detail" - ], - "numberOfRuns": 1, - "settings": { - "preset": "desktop", - "chromeFlags": "--no-sandbox" - } - }, - "assert": { - "preset": "lighthouse:recommended", - "assert": { - "assertions": { - "categories:performance": ["warn", { "minScore": 0.8 }], - "categories:accessibility": ["warn", { "minScore": 0.8 }], - "categories:best-practices": ["warn", { "minScore": 0.8 }], - "categories:seo": ["warn", { "minScore": 0.8 }] - } - } - }, - "server": {}, - "upload": { - "target": "filesystem", - "outputDir": "./lhci_reports", - "reportFilenamePattern": "%%PATHNAME%%-%%DATETIME%%-report.%%EXTENSION%%" + "ci": { + "collect": { + "staticDistDir": "./build", + "startServerReadyPattern": "ready on", + "url": [ + "http://localhost:3000", + "http://localhost:3000/profile", + "http://localhost:3000/detail" + ], + "numberOfRuns": 1, + "settings": { + "preset": "desktop", + "chromeFlags": "--no-sandbox" + } + }, + "assert": { + "preset": "lighthouse:recommended", + "assert": { + "assertions": { + "categories:performance": ["warn", { "minScore": 0.8 }], + "categories:accessibility": ["warn", { "minScore": 0.8 }], + "categories:best-practices": ["warn", { "minScore": 0.8 }], + "categories:seo": ["warn", { "minScore": 0.8 }] } + } + }, + "server": {}, + "upload": { + "target": "filesystem", + "outputDir": "./lhci_reports", + "reportFilenamePattern": "%%PATHNAME%%-%%DATETIME%%-report.%%EXTENSION%%" } + } } diff --git a/package.json b/package.json index 2bb3a90..9feca3d 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@babel/preset-react": "^7.23.3", "babel-jest": "^29.7.0", "jest": "^29.7.0", - "jest-environment-jsdom": "^29.7.0" + "jest-environment-jsdom": "^29.7.0", + "postcss": "^8.4.33" } } diff --git a/public/index.html b/public/index.html index d30f405..a1b1e67 100644 --- a/public/index.html +++ b/public/index.html @@ -15,9 +15,9 @@ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ --> - +