-
Notifications
You must be signed in to change notification settings - Fork 15
50 lines (41 loc) · 1.61 KB
/
sonar.yml
File metadata and controls
50 lines (41 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# SPDX-License-Identifier: MPL-2.0
name: Sonar Cloud
on:
# run pipeline on push event of main branch
push:
branches:
- main
# run pipeline on pull request
pull_request:
# run pipeline on merge queue
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-sonar
cancel-in-progress: true
jobs:
sonar-cloud:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Test and Coverage
run: |
uv sync --no-default-groups --group test
uv run pytest
# Fix relative paths in coverage file
# Known bug: https://community.sonarsource.com/t/sonar-on-github-actions-with-python-coverage-source-issue/36057
sed -i 's@/home/runner/work/power-grid-model-io/power-grid-model-io@/github/workspace@g' python_coverage.xml
- name: SonarQube Scan
if: ${{ (github.event_name == 'push') || (github.event.pull_request.head.repo.owner.login == 'PowerGridModel') }}
uses: SonarSource/sonarqube-scan-action@299e4b793aaa83bf2aba7c9c14bedbb485688ec4 # v7.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}