diff --git a/.gitea/workflows/sonarqube.yml b/.gitea/workflows/sonarqube.yml new file mode 100644 index 0000000..28c794a --- /dev/null +++ b/.gitea/workflows/sonarqube.yml @@ -0,0 +1,41 @@ +name: SonarQube Analysis + +on: + push: + branches: [ main, master, develop ] + pull_request: + branches: [ main, master ] + +jobs: + sonarqube: + name: SonarQube Scan + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Full history for better analysis + + - name: Test SonarQube connection + run: | + echo "Testing connection to SonarQube..." + curl -f http://192.168.1.100:9000/api/system/ping || echo "External connection failed" + + - name: Run SonarQube scan + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + run: | + # Docker 네트워크 확인 + docker network ls + + # SonarScanner 실행 + docker run \ + --rm \ + --network gitea_default \ + -e SONAR_HOST_URL="${SONAR_HOST_URL}" \ + -e SONAR_SCANNER_OPTS="-Dsonar.projectKey=TK-BOM-Project" \ + -e SONAR_TOKEN="${SONAR_TOKEN}" \ + -v "${{ github.workspace }}:/usr/src" \ + sonarsource/sonar-scanner-cli \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..c755362 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,19 @@ +# 프로젝트 식별 정보 +sonar.projectKey=my-project # SonarQube에서 만든 프로젝트 키와 동일하게! +sonar.projectName=My Project +sonar.projectVersion=1.0 + +# 소스 코드 위치 +sonar.sources=. +sonar.exclusions=**/*.test.js,**/node_modules/**,**/.gitea/** + +# 언어별 설정 (프로젝트에 맞게 수정) +# JavaScript/TypeScript +sonar.javascript.file.suffixes=.js,.jsx,.ts,.tsx +sonar.typescript.file.suffixes=.ts,.tsx + +# Python +# sonar.python.file.suffixes=.py + +# Java +# sonar.java.binaries=target/classes \ No newline at end of file