Skip to content

Commit

Permalink
CI add ability to run float32 tests by commit message (scikit-learn#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
lesteve authored and glemaitre committed Sep 12, 2022
1 parent fdba1a3 commit 8925933
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
29 changes: 26 additions & 3 deletions build_tools/azure/get_commit_message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import subprocess
import argparse


def get_commit_message():
Expand All @@ -21,9 +22,31 @@ def get_commit_message():
return commit_message


def parsed_args():
parser = argparse.ArgumentParser(
description=(
"Show commit message that triggered the build in Azure DevOps pipeline"
)
)
parser.add_argument(
"--only-show-message",
action="store_true",
default=False,
help=(
"Only print commit message. Useful for direct use in scripts rather than"
" setting output variable of the Azure job"
),
)
return parser.parse_args()


if __name__ == "__main__":
# set the environment variable to be propagated to other steps
args = parsed_args()
commit_message = get_commit_message()
print(f"##vso[task.setvariable variable=message;isOutput=true]{commit_message}")

print(f"commit message: {commit_message}") # helps debugging
if args.only_show_message:
print(commit_message)
else:
# set the environment variable to be propagated to other steps
print(f"##vso[task.setvariable variable=message;isOutput=true]{commit_message}")
print(f"commit message: {commit_message}") # helps debugging
2 changes: 1 addition & 1 deletion build_tools/azure/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pre_python_environment_install() {
apt-get update
apt-get install -y python3-dev python3-numpy python3-scipy \
python3-matplotlib libatlas3-base libatlas-base-dev \
python3-virtualenv python3-pandas ccache
python3-virtualenv python3-pandas ccache git

elif [[ "$DISTRIB" == "conda-pypy3" ]]; then
# need compilers
Expand Down
2 changes: 2 additions & 0 deletions build_tools/azure/posix-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ jobs:
-e CPU_COUNT=$CPU_COUNT
-e CCACHE_DIR=/ccache
-e CCACHE_COMPRESS=$CCACHE_COMPRESS
-e BUILD_SOURCEVERSIONMESSAGE="$BUILD_SOURCEVERSIONMESSAGE"
-e BUILD_REASON="$BUILD_REASON"
$DOCKER_CONTAINER
sleep 1000000
displayName: 'Start container'
Expand Down
7 changes: 7 additions & 0 deletions build_tools/azure/test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ if [[ "$BUILD_REASON" == "Schedule" ]]; then
export SKLEARN_RUN_FLOAT32_TESTS=1
fi

COMMIT_MESSAGE=$(python build_tools/azure/get_commit_message.py --only-show-message)

if [[ "$COMMIT_MESSAGE" =~ \[float32\] ]]; then
echo "float32 tests will be run due to commit message"
export SKLEARN_RUN_FLOAT32_TESTS=1
fi

mkdir -p $TEST_DIR
cp setup.cfg $TEST_DIR
cd $TEST_DIR
Expand Down
1 change: 1 addition & 0 deletions doc/developers/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ message, the following actions are taken.
[nogil] Build & test with the nogil experimental branches of CPython, Cython, NumPy, SciPy...
[icc-build] Build & test with the Intel C compiler (ICC)
[pypy] Build & test with PyPy
[float32] Run float32 tests by setting `SKLEARN_RUN_FLOAT32_TESTS=1`. See :ref:`environment_variable` for more details
[doc skip] Docs are not built
[doc quick] Docs built, but excludes example gallery plots
[doc build] Docs built including example gallery plots (very long)
Expand Down

0 comments on commit 8925933

Please sign in to comment.