|
| 1 | +name: SonarQube Analysis on Pull Request |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - develop |
| 8 | + - 'feature/**' |
| 9 | + - 'bugfix/**' |
| 10 | + - 'v*' |
| 11 | + types: [opened, synchronize, reopened] |
| 12 | + |
| 13 | +jobs: |
| 14 | + sonarqube: |
| 15 | + name: SonarQube Analysis |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v5 |
| 21 | + with: |
| 22 | + fetch-depth: 0 # Shallow clones should be disabled for better analysis |
| 23 | + |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: '3.12' |
| 28 | + cache: 'pip' |
| 29 | + |
| 30 | + - name: Set up Node.js |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: '20' |
| 34 | + cache: 'npm' |
| 35 | + cache-dependency-path: src/frontend/static/frontend/package-lock.json |
| 36 | + |
| 37 | + - name: Install Python dependencies |
| 38 | + run: | |
| 39 | + python -m pip install --upgrade pip |
| 40 | + pip install -r config/requirements.txt |
| 41 | +
|
| 42 | + - name: Install Node dependencies |
| 43 | + run: npm --prefix src/frontend/static/frontend ci |
| 44 | + |
| 45 | + - name: SonarQube Scan |
| 46 | + uses: sonarsource/sonarqube-scan-action@v6 |
| 47 | + env: |
| 48 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 49 | + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} |
| 50 | + with: |
| 51 | + args: > |
| 52 | + -Dsonar.projectKey=omics-datascience_multiomix |
| 53 | + -Dsonar.organization=omics-datascience |
| 54 | + -Dsonar.projectName=multiomix |
| 55 | + -Dsonar.sources=src |
| 56 | + -Dsonar.exclusions=**/node_modules/**,**/migrations/**,**/__pycache__/**,**/venv/**,**/.venv/**,**/htmlcov/**,**/staticfiles/**,**/*.pyc,**/email/**,**/dist/** |
| 57 | + -Dsonar.python.version=3.12 |
| 58 | + -Dsonar.javascript.node.maxspace=4096 |
| 59 | + -Dsonar.sourceEncoding=UTF-8 |
| 60 | + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} |
| 61 | + -Dsonar.pullrequest.branch=${{ github.head_ref }} |
| 62 | + -Dsonar.pullrequest.base=${{ github.base_ref }} |
| 63 | +
|
| 64 | + - name: Wait for Quality Gate |
| 65 | + uses: sonarsource/sonarqube-quality-gate-action@master |
| 66 | + timeout-minutes: 5 |
| 67 | + env: |
| 68 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 69 | + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} |
0 commit comments