Skip to content

Commit 2e487ff

Browse files
authored
[Bug] Make the ruamel integeration compatiable with legacy versions (#925)
* Rearrange tests Signed-off-by: Ching Yi, Chan <[email protected]> * Remove type hints Signed-off-by: Ching Yi, Chan <[email protected]> * minify test matrix Signed-off-by: Ching Yi, Chan <[email protected]> --------- Signed-off-by: Ching Yi, Chan <[email protected]>
1 parent 02b474b commit 2e487ff

File tree

7 files changed

+94
-49
lines changed

7 files changed

+94
-49
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,15 @@ on:
1515
jobs:
1616
build:
1717
runs-on: ubuntu-latest
18-
strategy:
19-
fail-fast: false
20-
matrix:
21-
version: [ '3.9', '3.10', '3.11' ]
22-
sqlalchemy: [ "sqlalchemy>=1.4,<2.0", "sqlalchemy>=2.0" ]
23-
2418
steps:
2519
- uses: actions/checkout@v3
2620
- name: Set up Python
2721
uses: actions/setup-python@v2
2822
with:
29-
python-version: ${{ matrix.version }}
23+
python-version: 3.11
3024
- name: Install dependencies
3125
run: |
3226
python -m pip install --upgrade pip
33-
pip install "${{ matrix.sqlalchemy }}"
3427
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3528
pip install -e '.[duckdb]'
3629
- name: Run tests

.github/workflows/tox.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Run tox tests
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
13+
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Set up Python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: "3.10"
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28+
pip install -e '.[duckdb]'
29+
pip install tox
30+
- name: Run tox-sqlalchemy
31+
run: tox -c tox-sqlalchemy.ini
32+
- name: Run tox-ruamel
33+
run: tox -c tox-ruamel.ini
34+
- name: Upload coverage reports to Codecov
35+
uses: codecov/codecov-action@v3
36+
env:
37+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

piperider_cli/yaml/__init__.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
from pathlib import Path
2-
from typing import Any, Callable, Optional, Union
1+
from typing import Any, Callable
32

43
from ruamel import yaml
5-
from ruamel.yaml import StreamTextType, StreamType, VersionType
64
from ruamel.yaml import CommentedMap as _cm, CommentedSeq as _cs
75

86
_yaml = yaml.YAML()
@@ -12,7 +10,7 @@
1210
YAMLError = yaml.YAMLError
1311

1412

15-
def load(stream: Union[Path, StreamTextType]) -> Any:
13+
def load(stream) -> Any:
1614
return _yaml.load(stream)
1715

1816

@@ -22,12 +20,12 @@ def allow_duplicate_keys_loader() -> Callable:
2220
return yml.load
2321

2422

25-
def safe_load(stream: StreamTextType, version: Optional[VersionType] = None) -> Any:
23+
def safe_load(stream, version=None) -> Any:
2624
return yaml.safe_load(stream, version)
2725

2826

2927
def dump(
30-
data: Union[Path, StreamType], stream: Any = None, *, transform: Any = None
28+
data, stream: Any = None, *, transform: Any = None
3129
) -> Any:
3230
return _yaml.dump(data, stream, transform=transform)
3331

@@ -56,5 +54,5 @@ def round_trip_load_yaml(file_path):
5654

5755
def round_trip_dump(
5856
data: Any,
59-
stream: Optional[StreamType] = None):
57+
stream=None):
6058
return yaml.round_trip_dump(data, stream)

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def _get_version():
7676
'csv': duckdb_require_packages,
7777
'parquet': duckdb_require_packages,
7878
'dev': [
79+
'tox',
7980
'pytest>=4.6',
8081
'pytest-flake8',
8182
'flake8==3.9.2',

tox-ruamel.ini

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[tox]
2+
env_list = ruamel-{0.17.21,0.17.22}
3+
minversion = 4.7.0
4+
5+
[testenv]
6+
description = run the tests with pytest
7+
package = wheel
8+
wheel_build_env = .pkg
9+
10+
11+
deps =
12+
pytest>=6
13+
dbt-core>=1.6,<1.7
14+
dbt-duckdb>=1.6,<1.7
15+
ruamel-0.17.21: ruamel.yaml<=0.17.21
16+
ruamel-0.17.22: ruamel.yaml>0.17.21,<0.18
17+
18+
19+
commands =
20+
pytest {tty:--color=yes} {posargs}
21+
22+
setenv =
23+
PYTHONPATH = {toxinidir}/tests/:{env:PYTHONPATH}
24+
25+

tox-sqlalchemy.ini

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[tox]
2+
env_list = sqlalchemy-{14,20}
3+
minversion = 4.7.0
4+
5+
[testenv]
6+
description = run the tests with pytest
7+
package = wheel
8+
wheel_build_env = .pkg
9+
10+
11+
deps =
12+
pytest>=6
13+
dbt-core>=1.6,<1.7
14+
dbt-duckdb>=1.6,<1.7
15+
sqlalchemy-14: sqlalchemy>=1.4,<2.0
16+
sqlalchemy-20: sqlalchemy>=2.0
17+
18+
19+
commands =
20+
pytest {tty:--color=yes} {posargs}
21+
22+
setenv =
23+
PYTHONPATH = {toxinidir}/tests/:{env:PYTHONPATH}
24+
25+

tox.ini

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

0 commit comments

Comments
 (0)