Skip to content

Commit 240ab76

Browse files
Seppli11sonartech
authored andcommitted
SONARPY-3440 Install tox using mise (#574)
GitOrigin-RevId: 774ed83d9ce3aec68b3c744e428e6633f50ca289
1 parent 2822dfa commit 240ab76

5 files changed

Lines changed: 16 additions & 24 deletions

File tree

.github/workflows/build.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ jobs:
6565
with:
6666
version: 2025.7.12
6767

68-
- name: Install tox
69-
run: |
70-
uv python install ${{ env.PYTHON_VERSION }} --default --preview
71-
uv venv
72-
uv pip install tox
73-
source .venv/bin/activate
74-
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
75-
7668
- name: Remove private directory
7769
run: rm -rf private
7870

mise.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
java = "17.0"
33
maven = "3.9"
44
python = "3.9"
5-
uv = "latest"
5+
"pipx:tox" = "latest"

python-frontend/typeshed_serializer/docker/cmd.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ protoc -I=. --python_out=../../../typeshed_serializer/serializer/proto_out ./sym
88

99
cd /sonar-python/python-frontend/typeshed_serializer
1010
# Recreate the env to make sure that latest dependencies will be downloaded
11-
python -m tox --recreate --notest
11+
tox --recreate --notest
1212
python runners/tox_runner.py --skip_tests=false

python-frontend/typeshed_serializer/runners/tox_runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,12 @@ def get_serialize_command_to_run(previous_source_checksum: Optional[str], curren
252252
if previous_source_checksum != current_sources_checksum:
253253
# Serializer code has changed - run full serialization
254254
logger.info('SERIALIZER CODE HAS CHANGED - STARTING FULL TYPESHED SERIALIZATION')
255-
return ['python', '-m', 'tox', '-e', 'serialize']
255+
return ['tox', '-e', 'serialize']
256256
elif changed_serializers:
257257
logger.info(f"STARTING SELECTIVE TYPESHED SERIALIZATION FOR: {','.join(changed_serializers)}")
258258
# Run selective serialization through tox environment
259259
serializers_arg = ','.join(changed_serializers)
260-
return ['python', '-m', 'tox', '-e', 'selective-serialize', '--', serializers_arg]
260+
return ['tox', '-e', 'selective-serialize', '--', serializers_arg]
261261
else:
262262
logger.info('SKIPPING TYPESHED SERIALIZATION')
263263
return None
@@ -302,7 +302,7 @@ def main(skip_tests=False, fail_fast=False, dry_run=False):
302302
if dry_run:
303303
logger.info('DRY RUN: Would run test')
304304
else:
305-
_ = subprocess.run(['python', '-m', 'tox', '-e', 'py39'], check=True)
305+
_ = subprocess.run(['tox', '-e', 'py39'], check=True)
306306

307307

308308
if __name__ == '__main__':

python-frontend/typeshed_serializer/tests/runners/test_tox_runner.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def test_tox_runner_unchanged_checksums(self):
208208
mocks.prev_checksum.assert_any_call(tox_runner.SERIALIZER_SOURCE_CHECKSUM_FILE)
209209
mocks.checksum.assert_any_call(self.FILE_NAMES, tox_runner.normalize_text_files)
210210
mocks.subprocess.run.assert_called_with(
211-
["python", "-m", "tox", "-e", "py39"], check=True
211+
["tox", "-e", "py39"], check=True
212212
)
213213

214214
def test_tox_runner_modified_checksum(self):
@@ -224,8 +224,8 @@ def test_tox_runner_modified_checksum(self):
224224
mocks.prev_checksum.assert_called_with(tox_runner.SERIALIZER_SOURCE_CHECKSUM_FILE)
225225
mocks.checksum.assert_called_with(self.FILE_NAMES, tox_runner.normalize_text_files)
226226
expected_calls = [
227-
mock.call(['python', '-m', 'tox', '-e', 'serialize'], check=True),
228-
mock.call(['python', '-m', 'tox', '-e', 'py39'], check=True)
227+
mock.call(['tox', '-e', 'serialize'], check=True),
228+
mock.call(['tox', '-e', 'py39'], check=True)
229229
]
230230
mocks.subprocess.run.assert_has_calls(expected_calls)
231231

@@ -392,7 +392,7 @@ def test_all_checksums_match_only_tests_launched(self):
392392

393393
# Should only run tests
394394
mocks.subprocess.run.assert_called_with(
395-
["python", "-m", "tox", "-e", "py39"], check=True
395+
["tox", "-e", "py39"], check=True
396396
)
397397

398398
# Should not update any checksums
@@ -750,8 +750,8 @@ def test_selective_serialization_when_one_serializer_changed(self):
750750
tox_runner.main()
751751

752752
expected_calls = [
753-
mock.call(['python', '-m', 'tox', '-e', 'selective-serialize', '--', 'custom'], check=True),
754-
mock.call(['python', '-m', 'tox', '-e', 'py39'], check=True)
753+
mock.call(['tox', '-e', 'selective-serialize', '--', 'custom'], check=True),
754+
mock.call(['tox', '-e', 'py39'], check=True)
755755
]
756756
mocks.subprocess.run.assert_has_calls(expected_calls)
757757
mocks.update_folder_checksums_for_changed_serializers.assert_any_call(["custom"])
@@ -768,8 +768,8 @@ def test_selective_serialization_when_two_serializer_changed(self):
768768
tox_runner.main()
769769

770770
expected_calls = [
771-
mock.call(['python', '-m', 'tox', '-e', 'selective-serialize', '--', 'custom,import'], check=True),
772-
mock.call(['python', '-m', 'tox', '-e', 'py39'], check=True)
771+
mock.call(['tox', '-e', 'selective-serialize', '--', 'custom,import'], check=True),
772+
mock.call(['tox', '-e', 'py39'], check=True)
773773
]
774774
mocks.subprocess.run.assert_has_calls(expected_calls)
775775
mocks.update_folder_checksums_for_changed_serializers.assert_any_call(["custom", "import"])
@@ -816,13 +816,13 @@ def test_update_folder_checksums_for_changed_serializers(self):
816816
def test_get_serialize_command_to_run_source_changed(self):
817817
# Test when source checksum has changed
818818
command = tox_runner.get_serialize_command_to_run("old_checksum", "new_checksum", [])
819-
expected = ['python', '-m', 'tox', '-e', 'serialize']
819+
expected = ['tox', '-e', 'serialize']
820820
self.assertEqual(command, expected)
821821

822822
def test_get_serialize_command_to_run_serializers_changed(self):
823823
# Test when serializers have changed but source is the same
824824
command = tox_runner.get_serialize_command_to_run("same_checksum", "same_checksum", ["custom", "stdlib"])
825-
expected = ['python', '-m', 'tox', '-e', 'selective-serialize', '--', 'custom,stdlib']
825+
expected = ['tox', '-e', 'selective-serialize', '--', 'custom,stdlib']
826826
self.assertEqual(command, expected)
827827

828828
def test_get_serialize_command_to_run_no_changes(self):
@@ -833,7 +833,7 @@ def test_get_serialize_command_to_run_no_changes(self):
833833
def test_get_serialize_command_to_run_source_priority(self):
834834
# Test that source changes take priority over serializer changes
835835
command = tox_runner.get_serialize_command_to_run("old_checksum", "new_checksum", ["custom"])
836-
expected = ['python', '-m', 'tox', '-e', 'serialize']
836+
expected = ['tox', '-e', 'serialize']
837837
self.assertEqual(command, expected)
838838

839839
def test_fetch_resources_subfolder_files(self):

0 commit comments

Comments
 (0)