Commit b64a74cf authored by Ivan Mazhukin's avatar Ivan Mazhukin

epm ci: move test logic from gen-ci.sh to tests/run_one_ci.sh

parent cd354aac
Pipeline #16463 passed with stage
in 45 seconds
......@@ -20,42 +20,7 @@ for app in $apps; do
echo " tags:"
echo " - access"
echo " script:"
echo " - cd bin"
echo " - ./epmu"
echo " - ./epmi -y wget glibc-pthread git kubo coreutils"
echo " - export LOGDIR=\"\$CI_PROJECT_DIR\""
echo " - mkdir -p \"\$CI_PROJECT_DIR/epm-play-versions\" \"\$CI_PROJECT_DIR/epm-errors\" \"\$CI_PROJECT_DIR/epm-logs\" \"\$CI_PROJECT_DIR/epm-requires\""
echo " - export EGET_IPFS_FORCE_LOAD=1"
echo " - export EPM_IPFS_DB_UPDATE_SKIPPING=1"
echo " - export EGET_IPFS_API=/ip4/91.232.225.49/tcp/5001"
# 1) run the updater and DO NOT fail on its return code
echo " - set +e"
echo " - EPM=\$(pwd)/epm bash ../tests/update_versions.sh --ipfs --force --slow \"$app\""
echo " - update_exit_code=\$?"
echo " - set -e"
# 2) determine the package name and the path to the version file
echo " - |"
echo " package_name=\$(./epm play --package-name \"$app\")"
echo " version_file_path=\"\$CI_PROJECT_DIR/epm-play-versions/\$package_name\""
# 3) if the version is missing — try to write it ourselves, ignore any errors
echo " - |"
echo " if [ ! -s \"\$version_file_path\" ]; then"
echo " tmp_file=\$(mktemp)"
echo " ./epm print version for package \"\$package_name\" >\"\$tmp_file\" 2>>\"\$CI_PROJECT_DIR/epm-errors/\$package_name\" || true"
echo " if [ -s \"\$tmp_file\" ]; then mv -f \"\$tmp_file\" \"\$version_file_path\"; else rm -f \"\$tmp_file\"; fi"
echo " fi"
# 4) final code: success is determined by the presence of the version file
echo " - |"
echo " if [ -s \"\$version_file_path\" ]; then"
echo " echo \"V Successful installation: version recorded in \$version_file_path\""
echo " final_exit_code=0"
echo " else"
echo " echo \"X Version not recorded. Installation or test error.\""
echo " final_exit_code=\$update_exit_code"
echo " fi"
# 5) explicitly finish the job with the required exit code
echo " - echo \"test rc: \$final_exit_code\""
echo " - exit \"\$final_exit_code\""
echo " - bash ./tests/run_one_ci.sh $app"
echo " artifacts:"
echo " when: always"
echo " expire_in: 2 days"
......
#!/usr/bin/env bash
set -euo pipefail
# args
APP="${1:?usage: tests/run_one_ci.sh <app>}"
# layout
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" # .../repo/tests
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" # .../repo
PROJECT_DIR="${CI_PROJECT_DIR:-$REPO_ROOT}"
LOGDIR="$PROJECT_DIR"
PLAY_DIR="$LOGDIR/epm-play-versions"
ERR_DIR="$LOGDIR/epm-errors"
LOG_DIR="$LOGDIR/epm-logs"
REQ_DIR="$LOGDIR/epm-requires"
mkdir -p "$PLAY_DIR" "$ERR_DIR" "$LOG_DIR" "$REQ_DIR"
# deps & env
cd "$REPO_ROOT/bin"
./epmu
./epmi -y wget glibc-pthread git kubo coreutils
export LOGDIR
export EGET_IPFS_FORCE_LOAD=1
export EPM_IPFS_DB_UPDATE_SKIPPING=1
export EGET_IPFS_API=/ip4/91.232.225.49/tcp/5001
# run updater
set +e
EPM="$(pwd)/epm" bash "$SCRIPT_DIR/update_versions.sh" --ipfs --force --slow "$APP"
update_exit_code=$?
set -e
# determine package name & version file path
package_name="$(./epm play --package-name "$APP")"
version_file_path="$PLAY_DIR/$package_name"
# if version file missing, try to write it ourselves
if [ ! -s "$version_file_path" ]; then
tmp_file="$(mktemp)"
./epm print version for package "$package_name" >"$tmp_file" 2>>"$ERR_DIR/$package_name" || true
if [ -s "$tmp_file" ]; then
mv -f "$tmp_file" "$version_file_path"
else
rm -f "$tmp_file"
fi
fi
# final result: success if version file exists
if [ -s "$version_file_path" ]; then
echo "V $APP: Test PASS for version -> $version_file_path"
final_exit_code=0
else
echo "X $APP: Test FAILED"
final_exit_code="$update_exit_code"
fi
echo "exit code: $final_exit_code"
exit "$final_exit_code"
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