forked from TA-Lib/ta-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(TA-Lib#43) New test-dist.py script to verify release candidate
- Loading branch information
1 parent
003d14c
commit 51ceaad
Showing
6 changed files
with
168 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# install_tests/__init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import os | ||
|
||
def log_params(host: str, package_file_path: str, temp_dir: str, version: str, sudo_pwd: str): | ||
print(f"Testing ta-lib-python installation on {host}") | ||
# Never display or log sudo_pwd, but want to know if it was specified. | ||
if sudo_pwd: | ||
hidden_sudo_pwd = "(hidden)" | ||
else: | ||
hidden_sudo_pwd = "\"\"" | ||
|
||
print(f" package_file_path={package_file_path}") | ||
print(f" temp_dir={temp_dir}") | ||
print(f" version={version}") | ||
print(f" sudo_pwd={hidden_sudo_pwd}") | ||
|
||
# Create a dummy file "PARAMS" into temp_dir to help debugging. | ||
with open(os.path.join(temp_dir, "PARAMS"), "w") as f: | ||
f.write(f"package_file_path={package_file_path}\n") | ||
f.write(f"temp_dir={temp_dir}\n") | ||
f.write(f"version={version}\n") | ||
f.write(f"sudo_pwd={hidden_sudo_pwd}\n") | ||
|
||
return | ||
|
||
def test_python_windows(package_file_path: str, temp_dir: str, version: str, sudo_pwd: str): | ||
# Test installation procedure for ta-lib-python and validate | ||
# that this ta-lib package release candidate is OK. | ||
# | ||
# Parameters | ||
# ---------- | ||
# package_file_path is the ta-lib-{version}-win64.zip | ||
# | ||
# temp_dir is an empty directory that can be used | ||
# for most intermediate file operations. | ||
# | ||
# version is the "0.0.0" string expected to be returned | ||
# by the installed ta-lib package. | ||
# | ||
# sudo_pwd can be pipeline into a "sudo -S" command. | ||
# If sudo_pwd is an empty string, then call "sudo" without | ||
# "-S" and let it be interactive. | ||
# More info: | ||
# https://stackoverflow.com/questions/60807449/run-github-action-as-sudo | ||
# | ||
# Test Behavior | ||
# ------------- | ||
# Must re-install/upgrade if ta-lib is already installed. | ||
# | ||
# Recommended to create a venv in temp_dir to simulate | ||
# a user setup. | ||
# | ||
# Leave all intermediate files in temp_dir after the test | ||
# (might be useful for debugging). | ||
# | ||
# Just sys.exit(1) on any problem discovered. | ||
|
||
log_params("Windows", package_file_path, temp_dir, version, sudo_pwd) | ||
|
||
# TODO - Implement the test !!! | ||
|
||
return | ||
|
||
def test_python_linux(package_file_path: str, temp_dir: str, version: str, sudo_pwd: str): | ||
# Same as test_python_windows except package_file_path is | ||
# the ta-lib-{version}-src.tar.gz | ||
# | ||
# Installation to be done with autotools "./configure" | ||
|
||
log_params("Linux", package_file_path, temp_dir, version, sudo_pwd) | ||
|
||
# TODO - Implement the test !!! | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Test release candidate assets in 'dist' | ||
# | ||
# This script can be called directly by a dev and also from various | ||
# GitHub Actions, branches and platforms (e.g. ubuntu-latest, windows-2022) | ||
# | ||
# The script must be executed from within a TA-Lib Git repos. | ||
# | ||
# Failing this test will **block** the official release. | ||
# | ||
# Returns a non-zero exit code if any problem is found. | ||
|
||
import argparse | ||
import os | ||
import sys | ||
import platform | ||
import tempfile | ||
|
||
from utilities.common import verify_git_repo, get_version_string, create_temp_dir | ||
from install_tests.python import test_python_windows, test_python_linux | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Test release candidate assets in 'dist'") | ||
parser.add_argument('-p', '--pwd', type=str, default="", help="Password for sudo commands") | ||
args = parser.parse_args() | ||
|
||
sudo_pwd = args.pwd | ||
|
||
root_dir = verify_git_repo() | ||
version = get_version_string(root_dir) | ||
temp_dir = create_temp_dir(root_dir) | ||
|
||
# Identify the dist package to test by this host. | ||
host_platform = sys.platform | ||
if host_platform == "linux": | ||
package_file_path = os.path.join(root_dir, "dist", f"ta-lib-{version}-src.tar.gz") | ||
elif host_platform == "win32": | ||
arch = platform.architecture()[0] | ||
if arch == '64bit': | ||
package_file_path = os.path.join(root_dir, "dist", f"ta-lib-{version}-win64.zip") | ||
else: | ||
print( f"Architecture [{arch}] not yet supported. Only 64 bits supported on windows.") | ||
else: | ||
print(f"Unsupported platform [{host_platform}]") | ||
sys.exit(1) | ||
|
||
if not os.path.isfile(package_file_path): | ||
print(f"Package file not found: {package_file_path}. Do './scripts/package.py") | ||
sys.exit(1) | ||
|
||
# Simulate user doing a ta-lib-python installation. | ||
if host_platform == "linux": | ||
test_python_linux(package_file_path, temp_dir, version, sudo_pwd) | ||
elif host_platform == "win32": | ||
test_python_windows(package_file_path, temp_dir, version, sudo_pwd) | ||
else: | ||
print(f"Unsupported platform [{host_platform}]") | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# utilities/__init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters