Skip to content

Commit

Permalink
replace python ci script from shell to python
Browse files Browse the repository at this point in the history
Signed-off-by: LiangliangSui <[email protected]>
  • Loading branch information
LiangliangSui committed Jan 21, 2024
1 parent 9ec9adc commit 23d0c73
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
push:
branches:
- main
- feature
- 'releases/**'
- 'deploy/**'
- 'test*'
Expand Down Expand Up @@ -154,17 +155,15 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.7, 3.12]
python-version: [3.12]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install bazel
run: ./ci/run_ci.sh install_bazel
- name: Run Python CI
run: ./ci/run_ci.sh python
run: python ./ci/run_ci.py python

go:
name: Golang CI
Expand Down
44 changes: 42 additions & 2 deletions ci/run_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@
import os
import logging
import importlib
import sys


BAZEL_VERSION = "6.3.2"

PYARROW_VERSION = "14.0.0"

PYARROW_LEGACY_VERSION = "12.0.0"


logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
)
Expand Down Expand Up @@ -71,6 +75,12 @@ def _get_bazel_download_url():
)


def cd_project_sub_dir(subdir):
cur_script_path = os.path.split(os.path.realpath(__file__))[0]
project_root_path = os.path.join(cur_script_path, "../")
os.chdir(os.path.join(project_root_path, subdir))


def _run_cpp():
_install_cpp_deps()
# run test
Expand All @@ -84,8 +94,7 @@ def _run_rust():
_exec_cmd("rustup component add clippy-preview")
_exec_cmd("rustup component add rustfmt")
logging.info("Executing fury rust tests")
cur_script_abs_path = os.path.split(os.path.realpath(__file__))[0]
os.chdir(os.path.join(cur_script_abs_path, "../rust"))
cd_project_sub_dir("rust")

cmds = (
"cargo doc --no-deps --document-private-items --all-features --open",
Expand All @@ -102,6 +111,14 @@ def _run_rust():
logging.info("Executing fury rust tests succeeds")


def _run_python():
logging.info("Executing fury python tests")
_install_pyfury()
cd_project_sub_dir("python")
_exec_cmd("pytest -v -s --durations=60 pyfury/tests")
logging.info("Executing fury python tests succeeds")


def _install_cpp_deps():
_exec_cmd(f"pip install pyarrow=={PYARROW_VERSION}")
_exec_cmd("pip install psutil")
Expand Down Expand Up @@ -133,6 +150,21 @@ def _install_bazel():
file.write(f"\nbuild --jobs={limit_jobs}")


def _install_pyfury():
cd_project_sub_dir("python")
major = sys.version_info.major
minor = sys.version_info.minor
if major == 3:
pick_version = PYARROW_VERSION if minor >= 8 else PYARROW_LEGACY_VERSION
else:
pick_version = PYARROW_VERSION if major > 3 else PYARROW_LEGACY_VERSION
logging.info(f"pick pyarrow version: {pick_version}")

_exec_cmd(f"pip install pyarrow=={pick_version}")
_exec_cmd("pip install Cython wheel numpy pytest pandas setuptools")
_exec_cmd("pip install -v -e .")


def _parse_args():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
Expand All @@ -156,6 +188,14 @@ def _parse_args():
)
rust_parser.set_defaults(func=_run_rust)

python_parser = subparsers.add_parser(
"python",
description="Run Python CI",
help="Run Python CI",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
python_parser.set_defaults(func=_run_python)

args = parser.parse_args()
arg_dict = dict(vars(args))
del arg_dict["func"]
Expand Down

0 comments on commit 23d0c73

Please sign in to comment.