Skip to content

Commit c397368

Browse files
authored
Merge pull request #810 from simvue-io/kzarebsk/fix-permission-denied-ci
Fix Pytest permission denied in CI
2 parents ff55ff1 + 69e3331 commit c397368

File tree

6 files changed

+51
-22
lines changed

6 files changed

+51
-22
lines changed

.github/workflows/test_client_macos_nightlies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ jobs:
3535
env:
3636
SIMVUE_URL: ${{ secrets.SIMVUE_NIGHTLY_URL }}
3737
SIMVUE_TOKEN: ${{ secrets.SIMVUE_NIGHTLY_TOKEN }}
38-
run: python -m pytest tests/ -m 'not scenario'
38+
run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache

.github/workflows/test_client_ubuntu.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ jobs:
3939
env:
4040
SIMVUE_URL: ${{ secrets.SIMVUE_URL }}
4141
SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }}
42-
run: python -m pytest tests/unit/ -x -m online -c /dev/null -p no:warnings -n 0 -v
42+
run: >-
43+
python -m pytest tests/unit/ -x
44+
-m online -c /dev/null -p no:warnings
45+
-n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache
4346
offline_unit_tests:
4447
runs-on: ubuntu-latest
4548
timeout-minutes: 40
@@ -61,7 +64,10 @@ jobs:
6164
env:
6265
SIMVUE_URL: ${{ secrets.SIMVUE_URL }}
6366
SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }}
64-
run: python -m pytest tests/unit/ -x -m offline -c /dev/null -p no:warnings -n 0 -v
67+
run: >-
68+
python -m pytest tests/unit/ -x
69+
-m offline -c /dev/null -p no:warnings
70+
-n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache
6571
online_functional_tests:
6672
runs-on: ubuntu-latest
6773
timeout-minutes: 40
@@ -83,7 +89,10 @@ jobs:
8389
env:
8490
SIMVUE_URL: ${{ secrets.SIMVUE_URL }}
8591
SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }}
86-
run: python -m pytest tests/functional/ -x -m online -c /dev/null -p no:warnings -n 0 -v
92+
run: >-
93+
python -m pytest tests/functional/ -x
94+
-m online -c /dev/null -p no:warnings
95+
-n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache
8796
offline_functional_tests:
8897
runs-on: ubuntu-latest
8998
timeout-minutes: 40
@@ -105,7 +114,10 @@ jobs:
105114
env:
106115
SIMVUE_URL: ${{ secrets.SIMVUE_URL }}
107116
SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }}
108-
run: python -m pytest tests/functional/ -x -m offline -c /dev/null -p no:warnings -n 0 -v
117+
run: >-
118+
python -m pytest tests/functional/ -x
119+
-m offline -c /dev/null -p no:warnings
120+
-n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache
109121
other_unit_tests:
110122
runs-on: ubuntu-latest
111123
timeout-minutes: 40
@@ -127,7 +139,11 @@ jobs:
127139
env:
128140
SIMVUE_URL: ${{ secrets.SIMVUE_URL }}
129141
SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }}
130-
run: python -m pytest tests/unit/ -x -m 'not offline' -m 'not online' -m 'not scenario' -c /dev/null -p no:warnings -n 0 -v
142+
run: >-
143+
python -m pytest tests/unit/ -x
144+
-m 'not offline' -m 'not online'
145+
-m 'not scenario' -c /dev/null
146+
-p no:warnings -n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache
131147
other_functional_tests:
132148
runs-on: ubuntu-latest
133149
timeout-minutes: 40
@@ -149,4 +165,8 @@ jobs:
149165
env:
150166
SIMVUE_URL: ${{ secrets.SIMVUE_URL }}
151167
SIMVUE_TOKEN: ${{ secrets.SIMVUE_TOKEN }}
152-
run: python -m pytest tests/functional/ -x -m 'not offline' -m 'not online' -m 'not scenario' -c /dev/null -p no:warnings -n 0 -v
168+
run: >-
169+
python -m pytest tests/functional/ -x
170+
-m 'not offline' -m 'not online'
171+
-m 'not scenario' -c /dev/null
172+
-p no:warnings -n 0 -v -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache

.github/workflows/test_client_ubuntu_nightlies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ jobs:
3838
env:
3939
SIMVUE_URL: ${{ secrets.SIMVUE_NIGHTLY_URL }}
4040
SIMVUE_TOKEN: ${{ secrets.SIMVUE_NIGHTLY_TOKEN }}
41-
run: python -m pytest tests/ -m 'not scenario'
41+
run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache

.github/workflows/test_multiple_python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ jobs:
4040
env:
4141
SIMVUE_URL: ${{ secrets.SIMVUE_NIGHTLY_URL }}
4242
SIMVUE_TOKEN: ${{ secrets.SIMVUE_NIGHTLY_TOKEN }}
43-
run: python -m pytest tests/ -m 'not scenario'
43+
run: python -m pytest tests/ -m 'not scenario' -c /dev/null -o cache_dir=${GITHUB_WORKSPACE}/.pytest-cache

simvue/api/request.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,24 @@ def get_paginated(
309309
# else if undefined or greater than the page limit use the limit
310310
_request_count: int = min(count or MAX_ENTRIES_PER_PAGE, MAX_ENTRIES_PER_PAGE)
311311

312-
while (
313-
_response := get(
314-
url=url,
315-
headers=headers,
316-
params=(params or {}) | {"count": _request_count, "start": _offset},
317-
timeout=timeout,
318-
json=json,
312+
try:
313+
while (
314+
_response := get(
315+
url=url,
316+
headers=headers,
317+
params=(params or {}) | {"count": _request_count, "start": _offset},
318+
timeout=timeout,
319+
json=json,
320+
)
321+
).json():
322+
yield _response
323+
_offset += MAX_ENTRIES_PER_PAGE
324+
325+
if (count and _offset > count) or (
326+
_response.json().get("count", 0) < _offset
327+
):
328+
break
329+
except json_module.JSONDecodeError:
330+
raise RuntimeError(
331+
f"[{_response.status_code}] Failed to retrieve content from server: {_response.text}"
319332
)
320-
).json():
321-
yield _response
322-
_offset += MAX_ENTRIES_PER_PAGE
323-
324-
if (count and _offset > count) or (_response.json().get("count", 0) < _offset):
325-
break

tests/functional/test_run_class.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import logging
23
import os
34
import pytest
45
import pytest_mock
@@ -598,6 +599,7 @@ def test_runs_multiple_series(request: pytest.FixtureRequest) -> None:
598599
def test_suppressed_errors(
599600
setup_logging: "CountingLogHandler", post_init: bool, request: pytest.FixtureRequest
600601
) -> None:
602+
logging.getLogger("simvue").setLevel(logging.DEBUG)
601603
setup_logging.captures = ["Skipping call to"]
602604

603605
with sv_run.Run(mode="offline") as run:

0 commit comments

Comments
 (0)