Skip to content

Commit 1db28bd

Browse files
authored
[build-ml-whl] Improve safety and logging (#61)
* Improve safety and logging * Add maxdepth arg * Simplify exports * Drop unnecessary 'head'
1 parent da39e22 commit 1db28bd

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

actions/build-ml-whl/action.yaml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,53 +23,59 @@ outputs:
2323
description: status of wheel build
2424
value: ${{ steps.build.outputs.status }}
2525

26-
# can we just pass in build args instead of updating the variables in version.py?
2726
runs:
2827
using: composite
2928
steps:
3029
- name: build
3130
id: build
32-
shell: bash
3331
run: |-
32+
echo "::group::Installing virtualenv and creating a venv"
3433
pip install virtualenv
3534
virtualenv venv
35+
echo "::endgroup::"
36+
3637
source venv/bin/activate
38+
39+
echo "::group::Installing setuptools-scm"
3740
pip install setuptools-scm==8.2.0
41+
echo "::endgroup::"
3842
39-
BUILD_TYPE="dev"
43+
export BUILD_TYPE="nightly"
4044
if ${{ inputs.release }}; then
41-
export BUILD_TYPE="release"
45+
BUILD_TYPE="release"
4246
elif ${{ inputs.dev }}; then
43-
export BUILD_TYPE="dev"
44-
else
45-
export BUILD_TYPE="nightly"
47+
BUILD_TYPE="dev"
4648
fi
4749
echo "BUILD_TYPE=${BUILD_TYPE}"
4850
49-
makefile_path=$(find . -type f -name "Makefile")
50-
cd $(dirname ${makefile_path})
51+
makefile_path=$(find . -maxdepth 2 -type f -name "Makefile")
52+
echo "makefile_path=${makefile_path}"
53+
makefile_dir=$(dirname "${makefile_path}")
54+
echo "makefile_dir=${makefile_dir}"
55+
cd "${makefile_dir}"
5156
5257
status=0
5358
make build || status=$?
5459
WHL_NAME=$(find dist -name '*.whl' -exec basename {} \;)
5560
TARGZ_NAME=$(find dist -name '*.tar.gz' -exec basename {} \;)
5661
5762
# check if created wheel match build type
58-
if [[ $BUILD_TYPE = "dev" ]] && [[ ! "$WHL_NAME" =~ \.dev ]]; then
59-
echo "ERROR: $WHL_NAME not dev build"
63+
if [[ ${BUILD_TYPE} = "dev" ]] && [[ ! "${WHL_NAME}" =~ \.dev ]]; then
64+
echo "ERROR: ${WHL_NAME} does not match dev build naming pattern"
6065
status=1
6166
fi
62-
if [[ $BUILD_TYPE = "release" ]] && ([[ "$WHL_NAME" =~ \.dev ]] || [[ "$WHL_NAME" =~ a[0-9]{8}- ]]); then
63-
echo "ERROR: $WHL_NAME not release build"
67+
if [[ ${BUILD_TYPE} = "release" ]] && ([[ "${WHL_NAME}" =~ \.dev ]] || [[ "${WHL_NAME}" =~ a[0-9]{8}- ]]); then
68+
echo "ERROR: ${WHL_NAME} does not match release build naming pattern"
6469
status=1
6570
fi
66-
if [[ $BUILD_TYPE = "nightly" ]] && [[ ! "$WHL_NAME" =~ a[0-9]{8}- ]]; then
67-
echo "ERROR: $WHL_NAME not nightly build"
71+
if [[ ${BUILD_TYPE} = "nightly" ]] && [[ ! "${WHL_NAME}" =~ a[0-9]{8}- ]]; then
72+
echo "ERROR: ${WHL_NAME} does not match nightly build naming pattern"
6873
status=1
6974
fi
7075
7176
echo "=========== Build Status ==========="
72-
echo "whlname=$WHL_NAME" | tee -a "$GITHUB_OUTPUT"
73-
echo "tarname=$TARGZ_NAME" | tee -a "$GITHUB_OUTPUT"
77+
echo "whlname=${WHL_NAME}" | tee -a "$GITHUB_OUTPUT"
78+
echo "tarname=${TARGZ_NAME}" | tee -a "$GITHUB_OUTPUT"
7479
echo "status=${status}" | tee -a "$GITHUB_OUTPUT"
7580
exit ${status}
81+
shell: bash

0 commit comments

Comments
 (0)