CI : 소나큐브 추가 #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SonarQube Analysis | |
on: | |
push: | |
branches: ["main", "dev"] | |
pull_request: | |
branches: ["main", "dev"] | |
workflow_dispatch: | |
permissions: | |
pull-requests: read # Allows SonarQube to decorate PRs with analysis results | |
jobs: | |
analysis: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. 코드 체크아웃 | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# 2. Node.js 환경 설정 (필요한 경우) | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' # Node.js 버전을 프로젝트에 맞게 변경 | |
# 3. 의존성 설치 | |
- name: Install dependencies | |
run: npm install | |
# 4. 테스트 커버리지 생성 (lcov 파일) | |
- name: Run tests and generate coverage | |
run: npm run test:coverage # 테스트 스크립트는 프로젝트에 따라 다를 수 있음 | |
# 5. SonarQube 분석 실행 | |
- name: Analyze with SonarQube | |
uses: SonarSource/sonarqube-scan-action@7295e71c9583053f5bf40e9d4068a0c974603ec8 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information | |
SONAR_TOKEN: ${{ secrets.GCP_SONAR_USER_TOKEN }} # SonarQube token | |
SONAR_HOST_URL: ${{ secrets.GCP_SONAR_URL }} # SonarQube URL | |
with: | |
args: | | |
-Dsonar.projectKey=bns # 실제 프로젝트 키로 변경 | |
-Dsonar.sources=src | |
-Dsonar.tests=src/tests # 'tests' 디렉터리 위치를 확인하고 수정 | |
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info | |
-Dsonar.projectVersion=1.0 | |
-Dsonar.language=ts | |
-Dsonar.verbose=true |