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 # Looks for file by name
current_project_file=$(jq -n "$project_files" | jq --arg FILE_NAME "$project_id_file_name" -jc ' current_project_file=$(jq -n "$project_files" | jq --arg FILE_NAME "$project_id_file_name" -jc '
.data | map(select(.fileName<=($FILE_NAME))) | .[0] // empty') .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 # 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 ' 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') .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 fi
# trys to make the output directory incase it doesnt exist. # trys to make the output directory incase it doesnt exist.
mkdir -p "$out_dir" mkdir -p "$out_dir"
debug "DEBUG: PROJECT_FILE: ${PROJECT_FILE}"
# grabs needed values from our json return # grabs needed values from our json return
file_name=$(jq -n "$PROJECT_FILE" | jq -jc '.fileName // empty' ) file_name=$(jq -n "$PROJECT_FILE" | jq -jc '.fileName // empty' )
download_url=$(jq -n "$PROJECT_FILE" | jq -jc '.downloadUrl // 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" log "ERROR: given MODS_FORGEAPI_FILE file does not exist"
exit 2 exit 2
fi fi
debug "DEBUG: MODS_FORGEAPI_KEY: ${MODS_FORGEAPI_FILE}"
# Needs loop here to look up release types befor calling download. # Needs loop here to look up release types befor calling download.
while read -r current_project; do 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 # 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' ) project_id=$(jq -n "$current_project" | jq -r '.projectId // empty' )
current_release_type=$(jq -n "$current_project" | jq -r '.releaseType // empty' ) current_release_type=$(jq -n "$current_project" | jq -r '.releaseType // empty' )

View File

@ -66,6 +66,28 @@ function isTrue() {
return ${result} 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() { function isDebugging() {
if isTrue "${DEBUG:-false}"; then if isTrue "${DEBUG:-false}"; then
return 0 return 0

View File

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

View File

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

View File

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

View File

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