Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] SonarCloud에서 SonarQube로 전환한다. #505

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 |`,
Expand All @@ -78,7 +82,6 @@ jobs:
`| ${score(summary.seo)} Seo | ${summary.seo} |`,
`| ${score(summary.pwa)} Pwa | ${summary.pwa} |`
].join("\n");

const detail = [
``,
`| Category | Score |`,
Expand Down Expand Up @@ -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/[email protected]
env:
Expand Down
7 changes: 1 addition & 6 deletions frontend/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -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
5 changes: 2 additions & 3 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"paths": {
"@/*": ["src/*"]
},
"types": ["cypress", "node"]
"types": ["node"]
},
"include": ["src", "cypress"],
"exclude": ["**/*.cy.ts"]
"include": ["src"],
}