Testing multiple ckans with interdependencies now works
This commit is contained in:
parent
256586a3af
commit
2da5cda1e7
108
build.sh
108
build.sh
|
@ -14,6 +14,16 @@ LATEST_CKAN_META="https://github.com/KSP-CKAN/CKAN-meta/archive/master.tar.gz"
|
||||||
# Third party utilities.
|
# Third party utilities.
|
||||||
JQ_PATH="jq"
|
JQ_PATH="jq"
|
||||||
|
|
||||||
|
# Return codes.
|
||||||
|
EXIT_OK=0
|
||||||
|
|
||||||
|
# Allow us to specify a commit id as the first argument
|
||||||
|
if [ -n "$1" ]
|
||||||
|
then
|
||||||
|
echo "Using CLI argument of $1"
|
||||||
|
ghprbActualCommit=$1
|
||||||
|
fi
|
||||||
|
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------
|
||||||
# Function for creating dummy KSP directories to
|
# Function for creating dummy KSP directories to
|
||||||
# test on. Takes version as an argument.
|
# test on. Takes version as an argument.
|
||||||
|
@ -104,18 +114,71 @@ create_dummy_ksp () {
|
||||||
ln -s downloads_cache dummy_ksp/CKAN/downloads
|
ln -s downloads_cache dummy_ksp/CKAN/downloads
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------
|
||||||
|
# Function for injecting metadata into a tar.gz
|
||||||
|
# archive. Assummes metadata.tar.gz to be present.
|
||||||
|
# ------------------------------------------------
|
||||||
|
inject_metadata () {
|
||||||
|
# TODO: Arrays + Bash Functions aren't fun. This needs
|
||||||
|
# Improvement but appears to work. The variables are
|
||||||
|
# available to the called functions.
|
||||||
|
|
||||||
|
# Check input, requires at least 1 argument.
|
||||||
|
if [ $# -ne 1 ]
|
||||||
|
then
|
||||||
|
echo "Nothing to inject."
|
||||||
|
cp metadata.tar.gz master.tar.gz
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract the metadata into a new folder.
|
||||||
|
rm -rf CKAN-meta-master
|
||||||
|
tar -xzf metadata.tar.gz
|
||||||
|
|
||||||
|
# Copy in the files to inject.
|
||||||
|
# TODO: Unsure why this suddenly needs [*] declaration
|
||||||
|
# but it does work
|
||||||
|
for f in ${OTHER_FILES[*]}
|
||||||
|
do
|
||||||
|
echo "Injecting $f"
|
||||||
|
cp $f CKAN-meta-master
|
||||||
|
done
|
||||||
|
|
||||||
|
# Recompress the archive.
|
||||||
|
rm -f master.tar.gz
|
||||||
|
tar -czf master.tar.gz CKAN-meta-master
|
||||||
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------
|
||||||
|
# Main entry point.
|
||||||
|
# ------------------------------------------------
|
||||||
|
|
||||||
# Find the changes to test.
|
# Find the changes to test.
|
||||||
echo "Finding changes to test..."
|
echo "Finding changes to test..."
|
||||||
|
|
||||||
if [ -n $ghprbActualCommit ]
|
if [ -n "$ghprbActualCommit" ]
|
||||||
then
|
then
|
||||||
echo Commit hash: $ghprbActualCommit
|
echo "Commit hash: $ghprbActualCommit"
|
||||||
echo Changes in this commit:
|
|
||||||
export COMMIT_CHANGES="`git diff --diff-filter=AM --name-only --stat origin/master`"
|
export COMMIT_CHANGES="`git diff --diff-filter=AM --name-only --stat origin/master`"
|
||||||
echo $COMMIT_CHANGES
|
|
||||||
else
|
else
|
||||||
echo "No commit ID to test"
|
echo "No commit provided, skipping further tests."
|
||||||
exit 1
|
exit $EXIT_OK
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make sure we start from a clean slate.
|
||||||
|
if [ -d "downloads_cache/" ]
|
||||||
|
then
|
||||||
|
rm -rf downloads_cache
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "master.tar.gz" ]
|
||||||
|
then
|
||||||
|
rm -f master.tar.gz
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "metadata.tar.gz" ]
|
||||||
|
then
|
||||||
|
rm -f metadata.tar.gz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# CKAN Validation files
|
# CKAN Validation files
|
||||||
|
@ -125,7 +188,7 @@ chmod a+x ckan-validate.py
|
||||||
|
|
||||||
# fetch latest ckan.exe
|
# fetch latest ckan.exe
|
||||||
echo "Fetching latest ckan.exe"
|
echo "Fetching latest ckan.exe"
|
||||||
wget --quiet $LATEST_CKAN_URL -O ckan.exe
|
#wget --quiet $LATEST_CKAN_URL -O ckan.exe
|
||||||
|
|
||||||
# Fetch the latest metadata.
|
# Fetch the latest metadata.
|
||||||
echo "Fetching latest metadata"
|
echo "Fetching latest metadata"
|
||||||
|
@ -138,22 +201,22 @@ then
|
||||||
mkdir downloads_cache
|
mkdir downloads_cache
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for f in $COMMIT_CHANGES
|
for ckan in $COMMIT_CHANGES
|
||||||
do
|
do
|
||||||
# set -e doesn't apply inside an if block CKAN#1273
|
# set -e doesn't apply inside an if block CKAN#1273
|
||||||
if [ "$f" = "build.sh" ]; then
|
if [ "$ckan" = "build.sh" ]; then
|
||||||
echo "Lets try not to validate our build script with CKAN"
|
echo "Lets try not to validate our build script with CKAN"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./ckan-validate.py $f
|
./ckan-validate.py $ckan
|
||||||
echo ----------------------------------------------
|
echo ----------------------------------------------
|
||||||
cat $f | python -m json.tool
|
cat $ckan | python -m json.tool
|
||||||
echo ----------------------------------------------
|
echo ----------------------------------------------
|
||||||
|
|
||||||
# Extract identifier and KSP version.
|
# Extract identifier and KSP version.
|
||||||
CURRENT_IDENTIFIER=$($JQ_PATH '.identifier' $f)
|
CURRENT_IDENTIFIER=$($JQ_PATH '.identifier' $ckan)
|
||||||
CURRENT_KSP_VERSION=$($JQ_PATH 'if .ksp_version then .ksp_version else .ksp_version_min end' $f)
|
CURRENT_KSP_VERSION=$($JQ_PATH 'if .ksp_version then .ksp_version else .ksp_version_min end' $ckan)
|
||||||
|
|
||||||
# Strip "'s.
|
# Strip "'s.
|
||||||
CURRENT_IDENTIFIER=${CURRENT_IDENTIFIER//'"'}
|
CURRENT_IDENTIFIER=${CURRENT_IDENTIFIER//'"'}
|
||||||
|
@ -162,14 +225,29 @@ do
|
||||||
echo "Extracted $CURRENT_IDENTIFIER as identifier."
|
echo "Extracted $CURRENT_IDENTIFIER as identifier."
|
||||||
echo "Extracted $CURRENT_KSP_VERSION as KSP version."
|
echo "Extracted $CURRENT_KSP_VERSION as KSP version."
|
||||||
|
|
||||||
|
# Get a list of all the OTHER files.
|
||||||
|
OTHER_FILES=()
|
||||||
|
|
||||||
|
for o in $COMMIT_CHANGES
|
||||||
|
do
|
||||||
|
if [ "$ckan" != "$o" ] && [ "$ckan" != "build.sh" ]
|
||||||
|
then
|
||||||
|
OTHER_FILES+=($o)
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "Other files: ${OTHER_FILES[*]}"
|
||||||
|
|
||||||
|
# Inject into metadata.
|
||||||
|
inject_metadata $OTHER_FILES
|
||||||
|
|
||||||
# Create a dummy KSP install.
|
# Create a dummy KSP install.
|
||||||
create_dummy_ksp $CURRENT_KSP_VERSION $ghprbActualCommit
|
create_dummy_ksp $CURRENT_KSP_VERSION $ghprbActualCommit
|
||||||
|
|
||||||
echo "Running ckan update"
|
echo "Running ckan update"
|
||||||
mono ckan.exe update
|
mono ckan.exe update
|
||||||
|
|
||||||
echo Running ckan install -c $f
|
echo Running ckan install -c $ckan
|
||||||
mono --debug ckan.exe install -c $f --headless
|
mono --debug ckan.exe install -c $ckan --headless
|
||||||
|
|
||||||
# Show all installed mods.
|
# Show all installed mods.
|
||||||
echo "Installed mods:"
|
echo "Installed mods:"
|
||||||
|
|
Loading…
Reference in New Issue