diff --git a/.github/lighthouse/budget.json b/.github/lighthouse/budget.json new file mode 100644 index 000000000..55c155772 --- /dev/null +++ b/.github/lighthouse/budget.json @@ -0,0 +1,27 @@ +[ + { + "path": "/*", + "timings": [ + { + "metric": "interactive", + "budget": 3000 + }, + { + "metric": "first-contentful-paint", + "budget": 1800 + } + ], + "resourceSizes": [ + { + "resourceType": "script", + "budget": 100 + } + ], + "resourceCounts": [ + { + "resourceType": "third-party", + "budget": 4 + } + ] + } +] \ No newline at end of file diff --git a/.github/workflows/lighthouse.yml b/.github/workflows/lighthouse.yml new file mode 100644 index 000000000..0c5617595 --- /dev/null +++ b/.github/workflows/lighthouse.yml @@ -0,0 +1,84 @@ +name: Vercel Preview URL Lighthouse Audit + +on: + pull_request + +jobs: + generate_lighthouse_audit: + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + # - name: Add comment to PR + # id: loading_comment_to_pr + # uses: marocchino/sticky-pull-request-comment@v2.9.0 + # with: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # number: ${{ github.event.issue.number }} + # header: lighthouse + # message: | + # Running Lighthouse audit... + - name: Wait for 2 minutes + run: sleep 120 + - name: Capture Vercel preview URL + id: vercel_preview_url + uses: zentered/vercel-preview-url@v1.1.9 + env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + with: + vercel_project_id: prj_k5bYwz7n5hAUFdrWE986D91RiMbW + vercel_team_id: team_7PAgeqjbXkY6qdxNIEKLbVSC + - name: Get URL + run: echo "https://${{ steps.vercel_preview_url.outputs.preview_url }}" + - uses: actions/checkout@v4 + - name: Audit preview URL with Lighthouse + id: lighthouse_audit + uses: treosh/lighthouse-ci-action@11.4.0 + with: + urls: | + "https://${{ steps.vercel_preview_url.outputs.preview_url }}" + "https://${{ steps.vercel_preview_url.outputs.preview_url }}/how-it-works" + "https://${{ steps.vercel_preview_url.outputs.preview_url }}/security" + "https://${{ steps.vercel_preview_url.outputs.preview_url }}/bitcash-bitlauncher" + "https://${{ steps.vercel_preview_url.outputs.preview_url }}/bitcash-bitlauncher/auction" + # budgetPath: '.github/lighthouse/budget.json' + uploadArtifacts: true + temporaryPublicStorage: true + - name: Format lighthouse score + id: format_lighthouse_score + uses: actions/github-script@v7.0.1 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const manifest = ${{ steps.lighthouse_audit.outputs.manifest }}; + const links = ${{ steps.lighthouse_audit.outputs.links }}; + + const formatResult = (res) => Math.round((res * 100)); + const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'; + + let comment = '⚡️ Lighthouse report\n' + + manifest.forEach(result => { + const pageLink = result.url; + comment += `\nPage: ${pageLink}\n`; + comment += `Report ${links[pageLink]}\n`; + comment += '| Category | Score |\n'; + comment += '| --- | --- |\n'; + + Object.keys(result.summary).forEach(key => result.summary[key] = formatResult(result.summary[key])); + comment += `| ${score(result.summary.performance)} Performance | ${result.summary.performance} |\n`; + comment += `| ${score(result.summary.accessibility)} Accessibility | ${result.summary.accessibility} |\n`; + comment += `| ${score(result.summary['best-practices'])} Best practices | ${result.summary['best-practices']} |\n`; + comment += `| ${score(result.summary.seo)} SEO | ${result.summary.seo} |\n`; + comment += `| ${score(result.summary.pwa)} PWA | ${result.summary.pwa} |\n`; + }); + + core.setOutput("comment", comment); + - name: Add comment to PR + id: comment_to_pr + uses: marocchino/sticky-pull-request-comment@v2.9.0 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + number: ${{ github.event.issue.number }} + header: lighthouse + message: | + ${{ steps.format_lighthouse_score.outputs.comment }} \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..f6789213c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,18 @@ +# name: Lint + +# on: +# pull_request: +# push: +# branches: +# - master + +# jobs: +# eslint: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: oven-sh/setup-bun@v1 + +# # run any `bun` or `bunx` command +# - run: bun install +# - run: bun run lint diff --git a/bun.lockb b/bun.lockb index 9204df835..57b614de7 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/packages/smartsale-db/src/client.ts b/packages/smartsale-db/src/client.ts index 12d1d94e6..2c9f1df03 100644 --- a/packages/smartsale-db/src/client.ts +++ b/packages/smartsale-db/src/client.ts @@ -2,4 +2,4 @@ import { PrismaClient } from "../prisma/client"; export const db = new PrismaClient({}); -// 209 +// 220