From bbf092dc2e42db01c0fa9a9db6e263749f4b4727 Mon Sep 17 00:00:00 2001 From: apurv-wednesday Date: Tue, 30 Apr 2024 12:21:56 +0530 Subject: [PATCH] feat: add lighthouse conf --- .github/workflows/ci.yml | 13 ++----------- .github/workflows/lighthouseci.yml | 28 ++++++++++++++++++++++++++++ .gitignore | 1 + lighthouserc.js | 19 +++++++++++++++++++ sonar-project.properties | 3 ++- 5 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/lighthouseci.yml create mode 100644 lighthouserc.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af21df7..85b05ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [18.x] + node-version: [20.x] steps: - uses: actions/checkout@v4 @@ -33,16 +33,7 @@ jobs: - name: Build Project run: yarn build - - # commenting for now to make CI green , will try this - # - name: run Lighthouse CI - # run: | - # yarn global add @lhci/cli@0.8.x - # lhci autorun --collect.staticDistDir - - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + - uses: sonarsource/sonarqube-scan-action@master env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/lighthouseci.yml b/.github/workflows/lighthouseci.yml new file mode 100644 index 0000000..10fc845 --- /dev/null +++ b/.github/workflows/lighthouseci.yml @@ -0,0 +1,28 @@ +name: CI +on: + pull_request: + branches: [main] + push: + branches: [main] +jobs: + lhci: + name: Lighthouse + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Use Node.js 20.x + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: yarn install and build + run: | + yarn install + yarn build + - name: run Lighthouse CI + run: | + yarn global add @lhci/cli + lhci autorun + env: + LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index b2b9417..33075e9 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ yarn-error.log* /public/worker-*.js.map /public/fallback-*.js reports +.lighthouseci/* diff --git a/lighthouserc.js b/lighthouserc.js new file mode 100644 index 0000000..921f16e --- /dev/null +++ b/lighthouserc.js @@ -0,0 +1,19 @@ +module.exports = { + ci: { + collect: { + startServerCommand: "yarn start", + url: ["http://localhost:3000"], + numberOfRuns: 3, + // default value is mobile + // settings: { + // preset: "desktop", + // }, + }, + assert: { + preset: "lighthouse:recommended", + }, + upload: { + target: "temporary-public-storage", + }, + }, +}; diff --git a/sonar-project.properties b/sonar-project.properties index cc27e81..9253996 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -13,7 +13,8 @@ sonar.tests=src # Exclude node_modules # Let's not exclude anything for now, after refractoring changes we can decide what to exclude from the analysis -sonar.exclusions=node_modules/**/* +sonar.exclusions=node_modules/**/*,lighthouserc.js + sonar.test.inclusions=**/*.test.tsx,**/*.test.js,**/*.test.ts sonar.javascript.lcov.reportPaths=./coverage/lcov.info sonar.testExecutionReportPaths=./reports/test-report.xml