Commit 1390f490 authored by Yori Fournier's avatar Yori Fournier
Browse files

further dev of run_step.sh -- important full_dep_hash still nedd to be read from file

parent 8dfdf186
STEP_NAME=$1
COMMIT=$2
shift; shift;
ARTIFACTS_DIR_HASHES=($@)
# echo ${ARTIFACTS_HASHES[@]}
source pipe-env.sh
......@@ -70,6 +74,7 @@ echo "archives_hash = \"sha1:${ARCHIVES_HASH}\"" >> ${TMP_DIR}/trace.toml
STEP_HASH_ID="${BUILD_HASH}-${PARAM_HASH}-${ARCHIVES_HASH}"
STEP_HASH=$(echo "${STEP_HASH}" | sha1sum)
STEP_HASH=${STEP_HASH%% *}
echo ${STEP_HASH_ID}
echo ${STEP_HASH}
......@@ -77,35 +82,66 @@ echo ${STEP_HASH}
echo "step-id = \"${STEP_HASH_ID}\"" >> ${TMP_DIR}/trace.toml
echo "step-hash = \"sha1:${STEP_HASH}\"" >> ${TMP_DIR}/trace.toml
exit 0
# CREATE DEPS HASH
STEPS=`./stoml ${PIPE_ROOT}/config.toml steps`
ARTIFACTS_DEPS=("${ARTIFACTS_DIR_HASHES[@]}")
echo $STEPS
echo "art deps: ${ARTIFACTS_DEPS[@]}"
echo "nbr art deps: ${#ARTIFACTS_DEPS[@]}"
if [[ ! " ${STEPS[*]} " =~ " ${STEP_NAME} " ]]; then
echo "ERROR: the step: ${STEP_NAME} is not defined."
exit 1
fi
#
ARTIFACTS_DEPS=(`./stoml ${PIPE_ROOT}/config.toml steps.${STEP_NAME}.artifacts`)
for archive in "${ARTIFACTS_DEPS[@]}";
do
cd ${PIPE_ROOT}/${ARCHIVES}
filenames=$(find "${archive}" -type f)
for filename in ${filenames};
if [[ ! ${#ARTIFACTS_DEPS[@]} == 0 ]];
then
# get the dep hash
for artifact in "${ARTIFACTS_DEPS[@]}";
do
sha1sum ${filename} >> ${TMP_DIR}/archives_checksum.sha1
done
cd ${PIPE_ROOT}
done;
artifact_hash=${artifact: -8}
dep_hash=${artifact: -17: -9}
parent_dep_hash=${artifact: -26: -18}
dep_name=${artifact:0: -27}
echo >> ${TMP_DIR}/trace.toml
echo "[[artifacts]]" >> ${TMP_DIR}/trace.toml
echo "step_name = \"${dep_name}\"" >> ${TMP_DIR}/trace.toml
echo "step_hash = \"${dep_hash}\"" >> ${TMP_DIR}/trace.toml
echo "dep_hash = \"${parent_dep_hash}\"" >> ${TMP_DIR}/trace.toml
echo "artifacts_hash = \"${artifact_hash}\"" >> ${TMP_DIR}/trace.toml
# read full_dep_hash from folder: artifact_hash.txt
full_dep_hash=$(date | sha1sum) # TO CORRECT THIS IS JUST FOR TEST [TODO]
full_dep_hash=${full_dep_hash%% *} # TO CORRECT THIS IS JUST FOR TEST [TODO]
echo "full_dep_hash = \"sha1:${full_dep_hash}\"" >> ${TMP_DIR}/trace.toml
DEP_HASHES=("${DEP_HASHES[@]} ${full_dep_hash}")
done;
echo "hashes: ${DEP_HASHES[@]}"
# sort the hashes
IFS=$'\n'; ordered=($(sort <<< "${DEP_HASHES[*]}")); unset IFS;
DEPS_HASH=$(echo "${ordered}" | sha1sum)
DEPS_HASH=${DEPS_HASH%% *}
else
DEPS_HASH="00000000"
fi;
ARTIFACT_HASH="00000000"
echo "step_name: ${STEP_NAME}"
echo " dep_hash: ${DEPS_HASH}"
echo "step_hash: ${STEP_HASH}"
echo " art_hash: ${ARTIFACT_HASH}"
echo " dir name: ${STEP_NAME}-${DEPS_HASH::8}-${STEP_HASH::8}-${ARTIFACT_HASH::8}"
# look in the artifacts directory if the step already exists
# run it if it does not exists
exit 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment