提交 911c2737 编写于 作者: HansBug's avatar HansBug 😆

Merge branch 'main' into doc/readme

......@@ -5,8 +5,8 @@ on:
types: [ published ]
jobs:
release:
name: Publish to official pypi
source_release:
name: Publish source package to official pypi
runs-on: ${{ matrix.os }}
if: ${{ github.repository == 'opendilab/treevalue' }}
strategy:
......@@ -14,11 +14,7 @@ jobs:
os:
- 'ubuntu-18.04'
python-version:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
steps:
- name: Checkout code
......@@ -39,10 +35,99 @@ jobs:
pip install --upgrade build
- name: Build packages
run: |
make package
make zip
- name: Publish distribution 📦 to real PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_PASSWORD }}
skip_existing: true
verbose: true
\ No newline at end of file
verbose: true
- name: Upload distribution 📦 to github release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*
tag: ${{ github.ref }}
file_glob: true
wheel_release:
name: Try build the wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-18.04'
# - 'windows-2019'
- 'macos-10.15'
python:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
architecture:
- x86_64
- arm64
- aarch64
- x86
- AMD64
exclude:
- os: ubuntu-18.04
architecture: arm64
- os: ubuntu-18.04
architecture: x86
- os: ubuntu-18.04
architecture: AMD64
- os: windows-2019
architecture: x86_64
- os: windows-2019
architecture: arm64
- os: windows-2019
architecture: aarch64
- os: macos-10.15
architecture: aarch64
- os: macos-10.15
architecture: x86
- os: macos-10.15
architecture: AMD64
- python: '3.6'
architecture: arm64
- python: '3.7'
architecture: arm64
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 20
- name: Set up QEMU
if: ${{ runner.os == 'Linux' }}
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.7.0
env:
CIBW_SKIP: "pp* *musllinux*"
CIBW_ARCHS: ${{ matrix.architecture }}
CIBW_PROJECT_REQUIRES_PYTHON: ~=${{ matrix.python }}.0
- name: Show the buildings
shell: bash
run: |
ls -al ./wheelhouse
- name: Publish distribution 📦 to real PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_PASSWORD }}
verbose: true
packages_dir: wheelhouse/
- name: Upload distribution 📦 to github release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: wheelhouse/*
tag: ${{ github.ref }}
file_glob: true
name: Release Test
on: workflow_dispatch
jobs:
source_release:
name: Try package the source
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-18.04'
python-version:
- '3.8'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 20
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up python dependences
run: |
pip install --upgrade pip
pip install --upgrade flake8 setuptools wheel twine
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-build.txt ]; then pip install -r requirements-build.txt; fi
if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi
pip install --upgrade build
- name: Build packages
run: |
make zip
ls -al dist
- name: Upload packed files to artifacts
uses: actions/upload-artifact@v2
with:
name: build-artifacts-source-pack
path: ./dist/*
wheel_release:
name: Try build the wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-18.04'
# - 'windows-2019'
- 'macos-10.15'
python:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
architecture:
- x86_64
- arm64
- aarch64
- x86
- AMD64
exclude:
- os: ubuntu-18.04
architecture: arm64
- os: ubuntu-18.04
architecture: x86
- os: ubuntu-18.04
architecture: AMD64
- os: windows-2019
architecture: x86_64
- os: windows-2019
architecture: arm64
- os: windows-2019
architecture: aarch64
- os: macos-10.15
architecture: aarch64
- os: macos-10.15
architecture: x86
- os: macos-10.15
architecture: AMD64
- python: '3.6'
architecture: arm64
- python: '3.7'
architecture: arm64
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 20
- name: Set up QEMU
if: ${{ runner.os == 'Linux' }}
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.7.0
env:
CIBW_SKIP: "pp* *musllinux*"
CIBW_ARCHS: ${{ matrix.architecture }}
CIBW_PROJECT_REQUIRES_PYTHON: ~=${{ matrix.python }}.0
- name: Show the buildings
shell: bash
run: |
ls -al ./wheelhouse
- name: Upload packed files to artifacts
uses: actions/upload-artifact@v2
with:
name: build-artifacts-${{ runner.os }}-cp${{ matrix.python }}-${{ matrix.architecture }}
path: ./wheelhouse/*
......@@ -2,7 +2,7 @@ name: Code Script Run
on:
push:
branches: [ main, 'dev/*', 'run/*' ]
branches: [ 'run/*' ]
jobs:
unittest:
......
name: Code Test
on:
- push
push:
branches:
- main
- dev/*
- fix/*
- test/*
jobs:
unittest:
......@@ -113,105 +118,3 @@ jobs:
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
benchmark:
name: Benchmark Test
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-18.04'
python-version:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 20
- name: Set up system dependences on linux
if: ${{ runner.os == 'Linux' }}
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 python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
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
pip install -r requirements-benchmark.txt
./install_test.sh
- name: Test the basic environment
run: |
python -V
pip --version
pip list
tree .
cloc treevalue
cloc test
- name: Run benckmark
env:
CI: 'true'
run: |
make clean build benchmark compare
try_release:
name: Try build the release
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-18.04'
python-version:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 20
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up python dependences
run: |
pip install --upgrade pip
pip install --upgrade flake8 setuptools wheel twine
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-build.txt ]; then pip install -r requirements-build.txt; fi
if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi
pip install --upgrade build
- name: Build packages
run: |
make package
ls -al dist
- name: Get package version
run: |
make build
python -c 'from treevalue.config.meta import __VERSION__;print(__VERSION__)'
echo "PACKAGE_VERSION=$(python -c 'from treevalue.config.meta import __VERSION__;print(__VERSION__)')" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
with:
name: treevalue-v${{ env.PACKAGE_VERSION }}-${{ matrix.os }}-${{ matrix.python-version }}
path: dist
.PHONY: docs test unittest build clean benchmark
.PHONY: docs test unittest build clean benchmark zip
PYTHON := $(shell which python)
......@@ -24,6 +24,9 @@ build:
$(PYTHON) setup.py build_ext --inplace \
$(if ${LINETRACE},--define CYTHON_TRACE,)
zip:
$(PYTHON) -m build --sdist --outdir ${DIST_DIR}
package:
$(PYTHON) -m build --sdist --wheel --outdir ${DIST_DIR}
for whl in `ls ${DIST_DIR}/*.whl`; do \
......
[build-system]
requires = ["setuptools", "wheel", "Cython"]
requires = [
"setuptools>=42",
"wheel",
"Cython",
]
[tool.cibuildwheel]
skip = ["pp*"] # Do not build for PyPy
## macOS build configuration
[tool.cibuildwheel.macos]
archs = ["x86_64", "arm64"] # Build for x86_64 and arm64
before-test = [# Unittest for linux
"pip install -r {project}/requirements-test.txt",
]
test-command = [
"cp -rf {project}/test test",
"cp {project}/pytest.ini pytest.ini",
"pytest test -sv -m unittest --log-level=DEBUG",
"rm -rf test",
]
## Linux build configuration
[tool.cibuildwheel.linux]
archs = ["x86_64", "aarch64"] # Build for x86_64 and arm64
skip = ["pp* *musllinux*"] # dependencies do not build for musl
before-test = [# Unittest for linux
"pip install -r {project}/requirements-test.txt",
]
test-command = [
"cp -rf {project}/test test",
"cp {project}/pytest.ini pytest.ini",
"pytest test -sv -m unittest --log-level=DEBUG",
"rm -rf test",
]
......@@ -9,6 +9,7 @@ pytest-rerunfailures~=10.2
pytest-timeout~=2.0.2
pytest-benchmark~=3.4.0
testtools>=2
hbutils>=0.6.13
setuptools<=59.5.0
numpy>=1.10
torch>=1.1.0
......
import os
import pathlib
import pickle
import unittest
import warnings
import zlib
import pytest
from click.testing import CliRunner
from hbutils.testing import cmdv
from treevalue import FastTreeValue, dump, graphics
from treevalue.entry.cli import treevalue_cli
......@@ -24,6 +26,7 @@ g = graphics(
@pytest.mark.unittest
class TestEntryCliGraph:
@unittest.skipUnless(cmdv('dot'), 'Dot installed only')
def test_simple_code_graph(self):
runner = CliRunner()
with runner.isolated_filesystem():
......@@ -54,6 +57,7 @@ class TestEntryCliGraph:
assert not os.path.exists('test_graph.gv')
assert len(result.output) <= 2500
@unittest.skipUnless(cmdv('dot'), 'Dot installed only')
def test_simple_code_multiple_graph(self):
runner = CliRunner()
with runner.isolated_filesystem():
......@@ -76,6 +80,7 @@ class TestEntryCliGraph:
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 17500
@unittest.skipUnless(cmdv('dot'), 'Dot installed only')
def test_simple_binary_graph(self):
runner = CliRunner()
with runner.isolated_filesystem():
......@@ -134,6 +139,7 @@ class TestEntryCliGraph:
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 6500
@unittest.skipUnless(cmdv('dot'), 'Dot installed only')
def test_duplicates(self):
runner = CliRunner()
with runner.isolated_filesystem():
......@@ -162,6 +168,7 @@ class TestEntryCliGraph:
shutil.copy('test_graph.svg', os.path.join(_p, 'test_graph.svg'))
assert os.path.getsize('test_graph.svg') <= 11000
@unittest.skipUnless(cmdv('dot'), 'Dot installed only')
def test_graph(self):
runner = CliRunner()
with runner.isolated_filesystem():
......@@ -203,6 +210,7 @@ class TestEntryCliGraph:
assert result.exit_code != 0
assert "Configuration should be KEY=VALUE, but 'bgcolor#ffffff00' found." in result.output
@unittest.skipUnless(cmdv('dot'), 'Dot installed only')
def test_file_with_invalid_permission(self):
runner = CliRunner()
with runner.isolated_filesystem():
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册