updating forgeapi tests and adding is false (#1548)

Co-authored-by: christopher blodgett <christopher.blodgett@gmail.com>
This commit is contained in:
chblodg 2022-06-05 13:16:12 -07:00 committed by GitHub
parent 1fb04c069c
commit 4f9de809f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 21 deletions

View File

@ -118,7 +118,7 @@ modFileByProjectID(){
# Looks for file by name
current_project_file=$(jq -n "$project_files" | jq --arg FILE_NAME "$project_id_file_name" -jc '
.data | map(select(.fileName<=($FILE_NAME))) | .[0] // empty')
elif $( ! isTrue "$MODS_FORGEAPI_IGNORE_GAMETYPE" ) && $FILTER_BY_FAMILY ; then
elif isFalse "${MODS_FORGEAPI_IGNORE_GAMETYPE}" && $FILTER_BY_FAMILY ; then
# Looks for file by version and server type in lowercase
current_project_file=$(jq -n "$project_files" | jq --arg RELEASE_FILTER "$RELEASE_NUMBER_FILTER" --arg GAME_TYPE "${FAMILY,,}" --arg VERSION "$VANILLA_VERSION" -jc '
.data | sort_by(.id) | reverse | map(select(.gameVersions[] | ascii_downcase | contains ($GAME_TYPE))) | map(select(.gameVersions[] | contains ($VERSION))) | map(select(.releaseType<=($RELEASE_FILTER|tonumber))) | .[0] // empty')
@ -160,7 +160,7 @@ downloadModPackfromModFile() {
fi
# trys to make the output directory incase it doesnt exist.
mkdir -p "$out_dir"
debug "DEBUG: PROJECT_FILE: ${PROJECT_FILE}"
# grabs needed values from our json return
file_name=$(jq -n "$PROJECT_FILE" | jq -jc '.fileName // empty' )
download_url=$(jq -n "$PROJECT_FILE" | jq -jc '.downloadUrl // empty' )
@ -204,9 +204,10 @@ if [ "$MODS_FORGEAPI_FILE" ] && [ -z "$MODS_FORGEAPI_PROJECTIDS" ]; then
log "ERROR: given MODS_FORGEAPI_FILE file does not exist"
exit 2
fi
debug "DEBUG: MODS_FORGEAPI_KEY: ${MODS_FORGEAPI_FILE}"
# Needs loop here to look up release types befor calling download.
while read -r current_project; do
debug "DEBUG: current_project: ${current_project}"
# Per stack overflow we can use //empty to return empty string that works with -z
project_id=$(jq -n "$current_project" | jq -r '.projectId // empty' )
current_release_type=$(jq -n "$current_project" | jq -r '.releaseType // empty' )

View File

@ -66,6 +66,28 @@ function isTrue() {
return ${result}
}
function isFalse() {
local oldState
oldState=$(shopt -po xtrace)
shopt -u -o xtrace
local value=${1,,}
result=
case ${value} in
false | off)
result=0
;;
*)
result=1
;;
esac
eval "$oldState"
return ${result}
}
function isDebugging() {
if isTrue "${DEBUG:-false}"; then
return 0

View File

@ -7,6 +7,7 @@ services:
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
DEBUG: "FALSE"
# Using custom to bypass Fabric setup
TYPE: CUSTOM
# Using family to test FORGEAPI Family filter.

View File

@ -1,11 +1,11 @@
[{
"name": "On A Stick [FABRIC]",
"projectId": "550544",
"releaseType": "release"
},
{
"name": "Fabric Voice Mod",
"projectId": "416089",
"releaseType": "beta"
}
[
{
"name": "Flan (Land Claim Tool)",
"projectId": "404578"
},
{
"name": "Fabric Voice Mod",
"projectId": "416089",
"releaseType": "beta"
}
]

View File

@ -1,5 +1,5 @@
# Validates specific beta call out for specific mod:
mc-image-helper assert fileExists "/data/mods/voicechat-fabric*"
mc-image-helper assert fileExists "/data/mods/onastick-fabric*"
# Dependent of on a stick:
mc-image-helper assert fileExists "/data/mods/flan*"
# Dependent of flan:
mc-image-helper assert fileExists "/data/mods/fabric-api*"

View File

@ -7,6 +7,7 @@ services:
environment:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
DEBUG: "FALSE"
# Using custom to bypass Fabric setup
TYPE: CUSTOM
# Using family to test FORGEAPI Family filter.
@ -17,13 +18,13 @@ services:
MODS_FORGEAPI_IGNORE_GAMETYPE: "TRUE"
# Validates that Biomes does not download terrablender
# Using default false for testing:
# MODS_FORGEAPI_DOWNLOAD_DEPENDENCIES: "FALSE"
MODS_FORGEAPI_DOWNLOAD_DEPENDENCIES: "FALSE"
# Contains mix of Forge and Fabric mods
MODS_FORGEAPI_PROJECTIDS: 306612,416089,220318
MODS_FORGEAPI_PROJECTIDS: 416089,493246
# Allows for Beta releases of 416089 the Fabric Voice Mod
MODS_FORGEAPI_RELEASES: BETA
MODS_FORGEAPI_KEY: ${MODS_FORGEAPI_KEY}
REMOVE_OLD_FORGEAPI_MODS: "FALSE"
REMOVE_OLD_FORGEAPI_MODS: "TRUE"
volumes:
- ./data:/data
- ./fake.jar:/servers/fake.jar

View File

@ -1,5 +1,5 @@
mc-image-helper assert fileExists "/data/mods/BiomesOPlenty*"
# testing dependencies don't get downloaded when download dependencies is set to false.
! mc-image-helper assert fileExists "/data/mods/TerraBlender*"
mc-image-helper assert fileExists "/data/mods/voicechat-fabric*"
mc-image-helper assert fileExists "/data/mods/fabric-api*"
mc-image-helper assert fileExists "/data/mods/flan*"
# Dependent of flan, but dependencies are set to false:
! mc-image-helper assert fileExists "/data/mods/fabric-api*"