Skip to content

Commit 31600d1

Browse files
authored
SCANPY-122 Create IT which scans a project (#161)
1 parent 7d1360e commit 31600d1

34 files changed

+611
-811
lines changed

.cirrus.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ env:
1010
DEPLOY_PULL_REQUEST: 'true'
1111
POETRY_VIRTUALENVS_PATH: "~/.cache/poetry/venvs"
1212
POETRY_CACHE_DIR: "~/.cache/poetry/pypoetry"
13+
SONARQUBE_VERSION: 25.3.0.104237
1314

1415
only_if: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_TAG == "" && ($CIRRUS_PR != "" || $CIRRUS_BRANCH == 'master' || $CIRRUS_BRANCH =~ "branch-.*")
1516
container_definition: &CONTAINER_DEFINITION
@@ -29,7 +30,7 @@ container_definition: &CONTAINER_DEFINITION
2930
poetry_cache_template: &POETRY_CACHE
3031
poetry_cache:
3132
folder: ~/.cache/poetry/
32-
fingerprint_script: cat poetry.lock its/poetry.lock
33+
fingerprint_script: cat poetry.lock
3334

3435
.poetry_template: &POETRY_TEMPLATE
3536
eks_container:
@@ -73,8 +74,7 @@ formatting_task:
7374
- poetry run black src/ tests/ --check
7475
- poetry run licenseheaders -t license_header.tmpl -o "SonarSource SA" -y 2011-2024 -n "Sonar Scanner Python" -E .py -d src/
7576
- poetry run licenseheaders -t license_header.tmpl -o "SonarSource SA" -y 2011-2024 -n "Sonar Scanner Python" -E .py -d tests/
76-
- poetry run licenseheaders -t license_header.tmpl -o "SonarSource SA" -y 2011-2024 -n "Sonar Scanner Python" -E .py -d its/ -x its/sources/**.py
77-
- git diff --name-only --exit-code ./src ./tests ./its
77+
- git diff --name-only --exit-code ./src ./tests
7878

7979
analysis_task:
8080
<<: *POETRY_TEMPLATE
@@ -130,20 +130,19 @@ its_task:
130130
alias: its
131131
sonarqube_cache:
132132
folder: sonarqube_cache/
133-
populate_script: mkdir -p sonarqube_cache && wget -q https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.5.1.90531.zip -O sonarqube_cache/sonarqube.zip
134-
fingerprint_key: sonarqube-10.5.1.90531
133+
populate_script: mkdir -p sonarqube_cache && wget -q https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONARQUBE_VERSION.zip -O sonarqube_cache/sonarqube.zip
134+
fingerprint_script: echo "sonarqube-$SONARQUBE_VERSION"
135135
<<: *POETRY_TEMPLATE
136136
its_script:
137137
- unzip -q sonarqube_cache/sonarqube.zip -d sonarqube
138138
- cd $(ls -d sonarqube/*/)
139139
- ./bin/linux-x86-64/sonar.sh start
140140
- cd -
141-
- cd its/
142141
- jfrog poetry-config --server-id-resolve repox --repo-resolve sonarsource-pypi
143142
- jfrog poetry install
144143
- unset SONAR_TOKEN
145144
- unset SONAR_HOST_URL
146-
- poetry run pytest
145+
- poetry run pytest --its tests/its
147146

148147
promote_task:
149148
depends_on:

CONTRIBUTING.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ url = 'https://repox.jfrog.io/artifactory/api/pypi/sonarsource-pypi/simple'
3232

3333
## Run the tests only
3434

35-
Run `poetry run pytest test/`
35+
Run `poetry run pytest tests/`
3636

3737
## Run the tests with coverage and results displayed in the terminal
3838

@@ -42,6 +42,39 @@ Run `poetry run pytest --cov-report=term-missing --cov-config=pyproject.toml --c
4242

4343
Run `poetry run pytest --cov-report=xml:coverage.xml --cov-config=pyproject.toml --cov=src --cov-branch tests`
4444

45+
## Run the ITs
46+
47+
Run `poetry run pytest tests/its --its` to run the its.
48+
49+
To see the ITs in the VSCode test explorer, add the `--its` argument to the `python.testing.pytestArgs` setting in `.vscode/settings.json`.
50+
51+
The the following keys should be present:
52+
```json
53+
"python.testing.unittestArgs": ["-v", "-s", "tests", "-p", "test_*.py"],
54+
"python.testing.pytestEnabled": true,
55+
"python.testing.unittestEnabled": false,
56+
"python.testing.pytestArgs": ["--its", "tests"],
57+
```
58+
59+
### Debugging the ITs
60+
61+
To debug the sonar-scanner being run in the its, the ITs have to be run with `poetry run pytest tests/its --its --debug-its`
62+
63+
The `pysonar-scanner` process will wait until VSCode or any other debug adapter protocol client connects on the port `5678`.
64+
65+
For VSCode, add the following launch configuration in the `configurations` array:
66+
```json
67+
{
68+
"name": "Python Debugger: Remote Attach",
69+
"type": "debugpy",
70+
"request": "attach",
71+
"connect": {
72+
"host": "localhost",
73+
"port": 5678
74+
},
75+
}
76+
```
77+
4578
# Build the package
4679

4780
Run `poetry build` to create the package.

its/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

its/README.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

its/compose.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)