diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index a3068e34..df21c4b4 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -10,13 +10,26 @@ defaults: working-directory: frontend jobs: - sonarcloud: - name: sonar frontend + sonarqube: + name: sonarqube frontend runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Use Node.js 12 + uses: actions/setup-node@v1 + with: + node-version: 12 - run: npm ci - run: npm run build + - run: npm install -g sonarqube-scanner + + - name: sonar-scanner + - uses: sonarsource/sonarqube-scan-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST_URL }} + run: sonar-scanner lhci: name: Lighthouse CI @@ -33,18 +46,15 @@ jobs: - name: NPM CI run: | npm ci - - name: Build run: | npm run build - - name: Lighthouse Run env: LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} run: | npm install -g @lhci/cli lhci autorun || echo "LHCI failed!" - - name: Format lighthouse score id: format_lighthouse_score uses: actions/github-script@v3 @@ -54,20 +64,14 @@ jobs: const fs = require('fs'); const results = JSON.parse(fs.readFileSync('${{ github.workspace }}/frontend/lhci_reports/manifest.json')); let comments = ""; - const { summary, jsonPath } = results[0]; - 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 |`, @@ -78,7 +82,6 @@ jobs: `| ${score(summary.seo)} Seo | ${summary.seo} |`, `| ${score(summary.pwa)} Pwa | ${summary.pwa} |` ].join("\n"); - const detail = [ ``, `| Category | Score |`, @@ -109,11 +112,8 @@ jobs: audits[`cumulative-layout-shift`].displayValue } |` ].join("\n"); - comments += comment + "\n" + detail + "\n"; - core.setOutput('comments', comments); - - name: Comment PR uses: unsplash/comment-on-pr@v1.3.0 env: diff --git a/frontend/sonar-project.properties b/frontend/sonar-project.properties index ce412431..004a2fa4 100644 --- a/frontend/sonar-project.properties +++ b/frontend/sonar-project.properties @@ -1,12 +1,7 @@ -sonar.projectName=2022-gong-check-front -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -sonar.sources=./src - -# Sonar to analysis language sonar.language=js,jsx,ts,tsx sonar.javascript.file.suffixes=.js,.jsx sonar.typescript.file.suffixes=.ts,.tsx -# Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8 +sonar.projectKey=woowacourse-teams_2022-gong-check_AYKm4KvOS_3Pe1LEsoLu diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index a12e0411..27e24239 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -26,8 +26,7 @@ "paths": { "@/*": ["src/*"] }, - "types": ["cypress", "node"] + "types": ["node"] }, - "include": ["src", "cypress"], - "exclude": ["**/*.cy.ts"] + "include": ["src"], }