Skip to content

Commit 032fb55

Browse files
joke1196guillaume-dequenne
authored andcommitted
PYSCAN-33: Setup SonarCloud analysis
1 parent 98bb670 commit 032fb55

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

.github/workflows/build-pr.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jobs:
1010
build:
1111

1212
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write # required by SonarSource/vault-action-wrapper
15+
contents: read # required by actions/checkout
16+
pull-requests: read # required by SonarSource/sonarcloud-github-action
1317
strategy:
1418
fail-fast: false
1519

@@ -37,7 +41,13 @@ jobs:
3741
- name: Check licensing
3842
run: |
3943
hatch run tool:license_check
40-
# - name: SonarCloud Scan
41-
# uses: SonarSource/sonarcloud-github-action@master
42-
# env:
43-
# SONAR_TOKEN: FIXME PYSCAN-33: Enable SonarCloud analysis
44+
- id: secrets
45+
uses: SonarSource/vault-action-wrapper@v2
46+
with:
47+
secrets: |
48+
development/kv/data/sonarcloud token | sonarcloud_token;
49+
- name: SonarCloud Scan
50+
uses: SonarSource/sonarcloud-github-action@master
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
SONAR_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).sonarcloud_token }}

pyproject.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ dependencies = [
5050

5151
[tool.hatch.envs.test.scripts]
5252
test = "pytest tests/"
53-
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=src/py_sonar_scanner --cov-branch tests"
54-
cov_xml = "pytest --cov-report=xml:coverage.xml --cov-config=pyproject.toml --cov=src/py_sonar_scanner --cov-branch tests"
53+
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=src --cov-branch tests"
54+
cov_xml = "pytest --cov-report=xml:coverage.xml --cov-config=pyproject.toml --cov=src --cov-branch tests"
5555

5656
[[tool.hatch.envs.test.matrix]]
5757
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
@@ -82,3 +82,8 @@ addopts = [
8282
[tool.black]
8383
line-length = 120
8484
target-version = ["py38", "py39", "py310", "py311", "py312"]
85+
86+
87+
[tool.coverage.run]
88+
branch = true
89+
relative_files = true

0 commit comments

Comments
 (0)