未验证 提交 e889da2c 编写于 作者: HansBug's avatar HansBug 😆 提交者: GitHub

Merge pull request #40 from opendilab/test/py310

dev(hansbug): try add unittest for python 3.10 and other os
......@@ -10,7 +10,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.7 ]
python-version:
- '3.8'
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
......
......@@ -15,7 +15,8 @@ jobs:
if: "!contains(github.event.head_commit.message, 'ci skip')"
strategy:
matrix:
python-version: [ 3.7 ]
python-version:
- '3.8'
services:
plantuml:
......
......@@ -18,6 +18,7 @@ jobs:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
steps:
- name: Checkout code
......
......@@ -19,6 +19,7 @@ jobs:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
steps:
- name: Checkout code
......
......@@ -13,37 +13,84 @@ jobs:
matrix:
os:
- 'ubuntu-18.04'
# - 'windows-2019' # need to be fixed, see: https://github.com/opendilab/treevalue/issues/41
- 'macos-10.15'
python-version:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
steps:
- name: Get system version for Linux
if: ${{ contains(matrix.os, 'ubuntu') }}
shell: bash
run: |
echo "OS_NAME=Linux" >> $GITHUB_ENV
echo "IS_WIN=" >> $GITHUB_ENV
echo "IS_MAC=" >> $GITHUB_ENV
- name: Get system version for Windows
if: ${{ contains(matrix.os, 'windows') }}
shell: bash
run: |
echo "OS_NAME=Windows" >> $GITHUB_ENV
echo "IS_WIN=1" >> $GITHUB_ENV
echo "IS_MAC=" >> $GITHUB_ENV
- name: Get system version for MacOS
if: ${{ contains(matrix.os, 'macos') }}
shell: bash
run: |
echo "OS_NAME=MacOS" >> $GITHUB_ENV
echo "IS_WIN=" >> $GITHUB_ENV
echo "IS_MAC=1" >> $GITHUB_ENV
- name: Set environment for Cpython
if: ${{ !contains(matrix.python-version, 'pypy') }}
shell: bash
run: |
echo "IS_PYPY=" >> $GITHUB_ENV
- name: Set environment for PyPy
if: ${{ contains(matrix.python-version, 'pypy') }}
shell: bash
run: |
echo "IS_PYPY=1" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 20
- name: Set up system dependences on linux
if: ${{ runner.os == 'Linux' }}
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y tree cloc wget curl make graphviz
sudo apt-get install -y libxml2-dev libxslt-dev python-dev # need by pypy3
dot -V
- name: Set up system dependences on Windows
if: ${{ env.OS_NAME == 'Windows' }}
shell: bash
run: |
choco install tree cloc wget curl make zip graphviz
dot -V
- name: Set up system dependences on MacOS
if: ${{ env.OS_NAME == 'MacOS' }}
shell: bash
run: |
brew install tree cloc wget curl make zip graphviz
dot -V
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install --upgrade flake8 setuptools wheel twine
pip install -r requirements.txt
pip install -r requirements-build.txt
pip install -r requirements-test.txt
./install_test.sh
- name: Test the basic environment
shell: bash
run: |
python -V
pip --version
......@@ -55,6 +102,7 @@ jobs:
env:
CI: 'true'
LINETRACE: 1
shell: bash
run: |
make clean build unittest
- name: Upload coverage to Codecov
......@@ -80,6 +128,7 @@ jobs:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
steps:
- name: Checkout code
......@@ -104,6 +153,7 @@ jobs:
pip install -r requirements.txt
pip install -r requirements-build.txt
pip install -r requirements-test.txt
pip install -r requirements-benchmark.txt
./install_test.sh
- name: Test the basic environment
run: |
......@@ -117,7 +167,7 @@ jobs:
env:
CI: 'true'
run: |
make clean build benchmark
make clean build benchmark compare
try_release:
name: Try build the release
......@@ -133,6 +183,7 @@ jobs:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
steps:
- name: Checkout code
......
.PHONY: docs test unittest build clean
.PHONY: docs test unittest build clean benchmark
PYTHON := $(shell which python)
......@@ -6,12 +6,14 @@ DOC_DIR := ./docs
DIST_DIR := ./dist
WHEELHOUSE_DIR := ./wheelhouse
TEST_DIR := ./test
BENCHMARK_DIR := ./benchmark
SRC_DIR := ./treevalue
RUNS_DIR := ./runs
RANGE_DIR ?= .
RANGE_TEST_DIR := ${TEST_DIR}/${RANGE_DIR}
RANGE_SRC_DIR := ${SRC_DIR}/${RANGE_DIR}
RANGE_DIR ?= .
RANGE_TEST_DIR := ${TEST_DIR}/${RANGE_DIR}
RANGE_BENCH_DIR := ${BENCHMARK_DIR}/${RANGE_DIR}
RANGE_SRC_DIR := ${SRC_DIR}/${RANGE_DIR}
CYTHON_FILES := $(shell find ${SRC_DIR} -name '*.pyx')
......@@ -55,6 +57,14 @@ benchmark:
--benchmark-sort=mean \
$(if ${WORKERS},-n ${WORKERS},)
compare:
pytest "${RANGE_BENCH_DIR}" \
-sv -m benchmark \
--benchmark-columns=min,max,mean,median,IQR,ops,rounds,iterations \
--benchmark-disable-gc \
--benchmark-sort=mean \
$(if ${WORKERS},-n ${WORKERS},)
docs:
$(MAKE) -C "${DOC_DIR}" build
pdocs:
......
pytest-benchmark~=3.4.0
dm-tree>=0.1.6
tianshou>=0.4.5
jax[cpu]>=0.2.17
\ No newline at end of file
......@@ -8,11 +8,8 @@ pytest-xdist>=1.34.0
pytest-rerunfailures~=10.2
pytest-timeout~=2.0.2
pytest-benchmark~=3.4.0
numpy>=1.10
torch>=1.1.0,<=1.10.0
easydict>=1.7,<2
testtools>=2
setuptools<=59.5.0
dm-tree>=0.1.6
tianshou>=0.4.5
jax[cpu]>=0.2.17
\ No newline at end of file
numpy>=1.10
torch>=1.1.0
easydict>=1.7,<2
\ No newline at end of file
......@@ -80,6 +80,7 @@ setup(
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],
entry_points={
'console_scripts': [
......
......@@ -35,9 +35,9 @@ class TestEntryCliGraph:
assert result.exit_code == 0
assert os.path.exists('test_graph.svg')
assert 5000 <= os.path.getsize('test_graph.svg') <= 7000
assert os.path.getsize('test_graph.svg') <= 7000
assert os.path.exists('test_graph.gv')
assert 1500 <= os.path.getsize('test_graph.gv') <= 2500
assert os.path.getsize('test_graph.gv') <= 2500
def test_simple_code_graph_to_stdout(self):
runner = CliRunner()
......@@ -52,7 +52,7 @@ class TestEntryCliGraph:
assert result.exit_code == 0
assert not os.path.exists('test_graph.svg')
assert not os.path.exists('test_graph.gv')
assert 1500 <= len(result.output) <= 2500
assert len(result.output) <= 2500
def test_simple_code_multiple_graph(self):
runner = CliRunner()
......@@ -64,7 +64,7 @@ class TestEntryCliGraph:
assert result.exit_code == 0
assert os.path.exists('test_graph.svg')
assert 10000 <= os.path.getsize('test_graph.svg') <= 13000
assert os.path.getsize('test_graph.svg') <= 13000
with runner.isolated_filesystem():
result = runner.invoke(
......@@ -74,7 +74,7 @@ class TestEntryCliGraph:
assert result.exit_code == 0
assert os.path.exists('test_graph.svg')
assert 15500 <= os.path.getsize('test_graph.svg') <= 17500
assert os.path.getsize('test_graph.svg') <= 17500
def test_simple_binary_graph(self):
runner = CliRunner()
......@@ -89,7 +89,7 @@ class TestEntryCliGraph:
assert result.exit_code == 0
assert os.path.exists('test_graph.svg')
assert 5500 <= os.path.getsize('test_graph.svg') <= 6500
assert os.path.getsize('test_graph.svg') <= 6500
with runner.isolated_filesystem():
with open('g1.bg', 'wb') as file:
......@@ -106,7 +106,7 @@ class TestEntryCliGraph:
assert result.exit_code == 0
assert os.path.exists('test_graph.svg')
assert 15500 <= os.path.getsize('test_graph.svg') <= 17500
assert os.path.getsize('test_graph.svg') <= 17500
with runner.isolated_filesystem():
with open('test.entry.cli.test_graph.t1', 'wb') as file:
......@@ -119,7 +119,7 @@ class TestEntryCliGraph:
assert result.exit_code == 0
assert os.path.exists('test_graph.svg')
assert 10000 <= os.path.getsize('test_graph.svg') <= 13000
assert os.path.getsize('test_graph.svg') <= 13000
with runner.isolated_filesystem():
with open('test.entry.cli.test_graph.t1', 'wb') as file:
......@@ -132,7 +132,7 @@ class TestEntryCliGraph:
assert result.exit_code == 0
assert os.path.exists('test_graph.svg')
assert 5500 <= os.path.getsize('test_graph.svg') <= 6500
assert os.path.getsize('test_graph.svg') <= 6500
def test_duplicates(self):
runner = CliRunner()
......@@ -145,7 +145,7 @@ class TestEntryCliGraph:
assert result.exit_code == 0
assert os.path.exists('test_graph.svg')
assert 8000 <= os.path.getsize('test_graph.svg') <= 12000
assert os.path.getsize('test_graph.svg') <= 12000
_p = os.path.abspath(os.curdir)
with runner.isolated_filesystem():
......@@ -160,7 +160,7 @@ class TestEntryCliGraph:
assert os.path.exists('test_graph.svg')
import shutil
shutil.copy('test_graph.svg', os.path.join(_p, 'test_graph.svg'))
assert 10000 <= os.path.getsize('test_graph.svg') <= 11000
assert os.path.getsize('test_graph.svg') <= 11000
def test_graph(self):
runner = CliRunner()
......@@ -174,7 +174,7 @@ class TestEntryCliGraph:
assert result.exit_code == 0
assert os.path.exists('test_graph.svg')
assert 14000 <= os.path.getsize('test_graph.svg') <= 16500
assert os.path.getsize('test_graph.svg') <= 16500
content = pathlib.Path('test_graph.svg').read_text()
assert 'first title' not in content
......@@ -190,7 +190,7 @@ class TestEntryCliGraph:
)
assert result.exit_code == 0
assert 5000 <= len(result.output) <= 6000
assert len(result.output) <= 6000
assert '#ffffff00' in result.output
with runner.isolated_filesystem():
......@@ -221,4 +221,4 @@ class TestEntryCliGraph:
assert result.exit_code == 0
assert os.path.exists('test_graph.svg')
assert 500 <= os.path.getsize('test_graph.svg') <= 1000
assert os.path.getsize('test_graph.svg') <= 1000
......@@ -616,7 +616,7 @@ def get_tree_test(tree_value_clazz: Type[TreeValue]):
},
})
graph = t.graph('t')
assert 2210 <= len(graph.source) <= 2290
assert len(graph.source) <= 2290
def test_graphics(self):
t = tree_value_clazz({
......@@ -645,7 +645,7 @@ def get_tree_test(tree_value_clazz: Type[TreeValue]):
title="This is a demo of 2 trees with dup value.",
cfg={'bgcolor': '#ffffffff'},
)
assert 4910 <= len(graph_1.source) <= 4960
assert len(graph_1.source) <= 4960
graph_2 = tree_value_clazz.graphics(
(t, 't'), (t1, 't1'),
......@@ -654,7 +654,7 @@ def get_tree_test(tree_value_clazz: Type[TreeValue]):
title="This is a demo of 2 trees with dup value.",
cfg={'bgcolor': '#ffffffff'},
)
assert 5420 <= len(graph_2.source) <= 5480
assert len(graph_2.source) <= 5480
graph_3 = tree_value_clazz.graphics(
(t, 't'), (t1, 't1'),
......@@ -663,7 +663,7 @@ def get_tree_test(tree_value_clazz: Type[TreeValue]):
title="This is a demo of 2 trees with dup value.",
cfg={'bgcolor': '#ffffffff'},
)
assert 4700 <= len(graph_3.source) <= 4760
assert len(graph_3.source) <= 4760
graph_4 = tree_value_clazz.graphics(
(t, 't'), (t1, 't1'),
......@@ -672,7 +672,7 @@ def get_tree_test(tree_value_clazz: Type[TreeValue]):
title="This is a demo of 2 trees with dup value.",
cfg={'bgcolor': '#ffffffff'},
)
assert 3720 <= len(graph_4.source) <= 3780
assert len(graph_4.source) <= 3780
graph_6 = tree_value_clazz.graphics(
(t, 't'), (t1, 't1'),
......@@ -681,7 +681,7 @@ def get_tree_test(tree_value_clazz: Type[TreeValue]):
title="This is a demo of 2 trees with dup value.",
cfg={'bgcolor': '#ffffffff'},
)
assert 4700 <= len(graph_6.source) <= 4760
assert len(graph_6.source) <= 4760
def test_func(self):
t1 = tree_value_clazz({'a': 1, 'b': 2, 'x': {'c': 3, 'd': 4}})
......
......@@ -37,7 +37,7 @@ class TestTreeTreeGraph:
title="This is a demo of 2 trees with dup value.",
cfg={'bgcolor': '#ffffffff'},
)
assert 4910 <= len(graph_1.source) <= 4960
assert len(graph_1.source) <= 4960
graph_2 = graphics(
(t, 't'), (t1, 't1'),
......@@ -46,7 +46,7 @@ class TestTreeTreeGraph:
title="This is a demo of 2 trees with dup value.",
cfg={'bgcolor': '#ffffffff'},
)
assert 5420 <= len(graph_2.source) <= 5480
assert len(graph_2.source) <= 5480
graph_3 = graphics(
(t, 't'), (t1, 't1'),
......@@ -55,7 +55,7 @@ class TestTreeTreeGraph:
title="This is a demo of 2 trees with dup value.",
cfg={'bgcolor': '#ffffffff'},
)
assert 4700 <= len(graph_3.source) <= 4760
assert len(graph_3.source) <= 4760
graph_4 = graphics(
(t, 't'), (t1, 't1'),
......@@ -64,7 +64,7 @@ class TestTreeTreeGraph:
title="This is a demo of 2 trees with dup value.",
cfg={'bgcolor': '#ffffffff'},
)
assert 3720 <= len(graph_4.source) <= 3780
assert len(graph_4.source) <= 3780
graph_6 = graphics(
(t, 't'), (t1, 't1'),
......@@ -73,4 +73,4 @@ class TestTreeTreeGraph:
title="This is a demo of 2 trees with dup value.",
cfg={'bgcolor': '#ffffffff'},
)
assert 4700 <= len(graph_6.source) <= 4760
assert len(graph_6.source) <= 4760
......@@ -10,21 +10,21 @@ class TestUtilsTree:
g = build_graph((t, 't'), graph_title="Demo of build_graph.")
assert "Demo of build_graph." in g.source
assert "t.x" in g.source
assert 530 < len(g.source) <= 560
assert len(g.source) <= 560
g2 = build_graph(t, graph_title="Demo 2 of build_graph.")
assert "Demo 2 of build_graph." in g2.source
assert "<root_0>" in g2.source
assert "<root_0>.x" in g2.source
assert 550 < len(g2.source) <= 580
assert len(g2.source) <= 580
g3 = build_graph((t,), graph_title="Demo 3 of build_graph.")
assert "Demo 3 of build_graph." in g3.source
assert "<root_0>" in g3.source
assert "<root_0>.x" in g3.source
assert 550 < len(g3.source) <= 580
assert len(g3.source) <= 580
g4 = build_graph((), graph_title="Demo 4 of build_graph.")
assert "Demo 4 of build_graph." in g4.source
assert "node" not in g4.source
assert 90 <= len(g4.source) <= 110
assert len(g4.source) <= 110
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册