Skip to content

Commit

Permalink
Fix tox coverage workflow and run in windows (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
mauvilsa authored Oct 16, 2024
1 parent 53bc986 commit 3f62519
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ name: manual

on:
workflow_dispatch:
inputs:
OS:
description: Operating System
required: true
type: choice
options:
- windows-2019
- macOS-12
- ubuntu-22.04

jobs:

tox-coverage-windows:
runs-on: windows-2019
tox-coverage:
runs-on: ${{ inputs.OS }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -17,9 +25,11 @@ jobs:
3.10
3.11
3.12
- run: pip install -e ".[dev,all]"
- run: pip install -e ".[dev]"
- run: tox -- --cov=../jsonargparse --cov-append
- uses: actions/upload-artifact@v4
with:
name: coverage
path: jsonargparse_tests/.coverage
include-hidden-files: true
if-no-files-found: error
19 changes: 10 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,22 @@ extras = coverage
commands =
# Test with pydantic<2
python -c "\
from shutil import copy;\
copy('conftest.py', '{envtmpdir}/conftest.py');\
copy('test_dataclass_like.py', '{envtmpdir}/test_dataclass_like.py')\
from pathlib import Path; \
from shutil import copy; \
copy('conftest.py', Path(r'{envtmpdir}', 'conftest.py')); \
copy('test_dataclass_like.py', Path(r'{envtmpdir}', 'test_dataclass_like.py'))\
"
pip install "pydantic<2"
python -m pytest {posargs} {envtmpdir}/test_dataclass_like.py
# Test with pydantic>=2 importing from pydantic.v1
python -c "\
import re, pathlib;\
path = pathlib.Path('{envtmpdir}/test_dataclass_like.py');\
content = path.read_text();\
content = re.sub(r'import pydantic', 'import pydantic.v1 as pydantic', content);\
content = re.sub(r'test_pydantic_types', '_test_pydantic_types', content);\
content = re.sub(r'^annotated = [^\\n]*', 'annotated = False', content, flags=re.MULTILINE);\
import re, pathlib; \
path = pathlib.Path(r'{envtmpdir}', 'test_dataclass_like.py'); \
content = path.read_text(); \
content = re.sub(r'import pydantic', 'import pydantic.v1 as pydantic', content); \
content = re.sub(r'test_pydantic_types', '_test_pydantic_types', content); \
content = re.sub(r'^annotated = [^\\n]*', 'annotated = False', content, flags=re.MULTILINE); \
path.write_text(content)\
"
pip install "pydantic>=2"
Expand Down

0 comments on commit 3f62519

Please sign in to comment.