mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Merge branch 'new-definitions-for-level-7-8-9' into cleanup-2
This commit is contained in:
commit
08db4b90eb
4 changed files with 121 additions and 119 deletions
|
@ -5,7 +5,7 @@
|
||||||
4 Backup and restore support
|
4 Backup and restore support
|
||||||
5 Clean
|
5 Clean
|
||||||
6 Open to contributions from the community
|
6 Open to contributions from the community
|
||||||
7 Successfully pass functional tests
|
7 Successfully pass all functional tests and linter tests
|
||||||
8 High quality app
|
8 Maintained and long-term good quality
|
||||||
9 Respect higher guidelines
|
9 High quality app
|
||||||
10 Package assessed as perfect
|
10 Package assessed as perfect
|
||||||
|
|
166
package_check.sh
166
package_check.sh
|
@ -302,6 +302,7 @@ then
|
||||||
|
|
||||||
# Clone in another directory
|
# Clone in another directory
|
||||||
git clone --quiet https://github.com/YunoHost/package_linter "$script_dir/package_linter_tmp"
|
git clone --quiet https://github.com/YunoHost/package_linter "$script_dir/package_linter_tmp"
|
||||||
|
pip3 install pyparsing six
|
||||||
|
|
||||||
# And replace
|
# And replace
|
||||||
cp -a "$script_dir/package_linter_tmp/." "$script_dir/package_linter/."
|
cp -a "$script_dir/package_linter_tmp/." "$script_dir/package_linter/."
|
||||||
|
@ -310,6 +311,7 @@ then
|
||||||
else
|
else
|
||||||
echo -e "\e[97mInstall Package linter.\n\e[0m"
|
echo -e "\e[97mInstall Package linter.\n\e[0m"
|
||||||
git clone --quiet $git_repository "$script_dir/package_linter"
|
git clone --quiet $git_repository "$script_dir/package_linter"
|
||||||
|
pip3 install pyparsing six
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update the version file
|
# Update the version file
|
||||||
|
@ -692,8 +694,8 @@ TEST_RESULTS () {
|
||||||
if level_can_change 5
|
if level_can_change 5
|
||||||
then
|
then
|
||||||
# Validated if Linter is ok. Or if Linter has been not tested but already validated before.
|
# Validated if Linter is ok. Or if Linter has been not tested but already validated before.
|
||||||
if [ $RESULT_linter -eq 1 ] || \
|
if [ $RESULT_linter -ge 1 ] || \
|
||||||
( [ $RESULT_linter -ne -1 ] && \
|
( [ $RESULT_linter -eq 0 ] && \
|
||||||
[ "${level[5]}" == "2" ] )
|
[ "${level[5]}" == "2" ] )
|
||||||
then level[5]=2
|
then level[5]=2
|
||||||
else level[5]=0
|
else level[5]=0
|
||||||
|
@ -704,104 +706,71 @@ TEST_RESULTS () {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Evaluate the sixth level
|
# Evaluate the sixth level
|
||||||
# -> The package can be backup and restore without error
|
# -> The package can be backup and restore without error
|
||||||
if level_can_change 6
|
if level_can_change 6
|
||||||
then
|
then
|
||||||
# Check the YEP 1.7 (https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-17---ajouter-lapp-%C3%A0-lorganisation-yunohost-apps---valid%C3%A9--manuel--official-)
|
# This is from the linter, tests if app is the Yunohost-apps organization
|
||||||
# Default value, YEP 1.7 not checked
|
if [ $RESULT_linter_level_6 -eq 1 ]
|
||||||
YEP17=-1
|
then level[6]=2
|
||||||
YEP17_labriqueinternet=-1
|
else level[6]=0
|
||||||
YEP17_failed=0
|
fi
|
||||||
if echo "$app_arg" | grep --extended-regexp --quiet "https?:\/\/"
|
fi
|
||||||
then
|
|
||||||
# If the app have been picked from github, check if this app was under the YunoHost-Apps organisation
|
|
||||||
# YEP17 will be equal to 1 if the app was under the YunoHost-Apps organisation
|
|
||||||
YEP17=$(echo "$app_arg" | grep --ignore-case --count "github.com/YunoHost-Apps/")
|
|
||||||
# If the app have been picked from github, check if this app was under the labriqueinternet organisation
|
|
||||||
# YEP17_labriqueinternet will be equal to 1 if the app was under the labriqueinternet organisation
|
|
||||||
YEP17_labriqueinternet=$(echo "$app_arg" | grep --ignore-case --count "github.com/labriqueinternet/")
|
|
||||||
if [ $YEP17 -ne 1 ] && [ $YEP17_labriqueinternet -ne 1 ]; then
|
|
||||||
ECHO_FORMAT "This app doesn't respect the YEP 1.7 ! (https://yunohost.org/#/packaging_apps_guidelines_fr)\n" "red"
|
|
||||||
YEP17_failed=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Validated if YEP 1.7 respected
|
# Evaluate the seventh level
|
||||||
if [ $YEP17_failed -eq 0 ]
|
# -> None errors in all tests performed
|
||||||
then level[6]=2
|
if level_can_change 7
|
||||||
else level[6]=0
|
then
|
||||||
fi
|
level[7]=0
|
||||||
fi
|
# Validated if none errors is happened.
|
||||||
|
if [ $RESULT_global_setup -ne -1 ] && \
|
||||||
|
[ $RESULT_global_remove -ne -1 ] && \
|
||||||
|
[ $RESULT_check_sub_dir -ne -1 ] && \
|
||||||
|
[ $RESULT_check_remove_sub_dir -ne -1 ] && \
|
||||||
|
[ $RESULT_check_remove_root -ne -1 ] && \
|
||||||
|
[ $RESULT_check_upgrade -ne -1 ] && \
|
||||||
|
[ $RESULT_check_private -ne -1 ] && \
|
||||||
|
[ $RESULT_check_public -ne -1 ] && \
|
||||||
|
[ $RESULT_check_multi_instance -ne -1 ] && \
|
||||||
|
[ $RESULT_check_path -ne -1 ] && \
|
||||||
|
[ $RESULT_check_port -ne -1 ] && \
|
||||||
|
[ $RESULT_check_backup -ne -1 ] && \
|
||||||
|
[ $RESULT_check_restore -ne -1 ] && \
|
||||||
|
[ $RESULT_change_url -ne -1 ] && \
|
||||||
|
[ $RESULT_action_config_panel -ne -1 ] && \
|
||||||
|
[ $RESULT_linter_level_7 -ge 1 ]
|
||||||
|
then
|
||||||
|
level[7]=2
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Evaluate the seventh level
|
# Evaluate the eighth level
|
||||||
# -> None errors in all tests performed
|
# This happens in the linter
|
||||||
if level_can_change 7
|
# When writing this, defined as app being maintained + long term quality (=
|
||||||
then
|
# certain amount of time level 5+ in the last year)
|
||||||
# Validated if none errors is happened.
|
level[8]=0
|
||||||
if [ $RESULT_global_setup -ne -1 ] && \
|
if [ $RESULT_linter_level_8 -ge 1 ]
|
||||||
[ $RESULT_global_remove -ne -1 ] && \
|
then
|
||||||
[ $RESULT_check_sub_dir -ne -1 ] && \
|
level[8]=2
|
||||||
[ $RESULT_check_remove_sub_dir -ne -1 ] && \
|
fi
|
||||||
[ $RESULT_check_remove_root -ne -1 ] && \
|
|
||||||
[ $RESULT_check_upgrade -ne -1 ] && \
|
|
||||||
[ $RESULT_check_private -ne -1 ] && \
|
|
||||||
[ $RESULT_check_public -ne -1 ] && \
|
|
||||||
[ $RESULT_check_multi_instance -ne -1 ] && \
|
|
||||||
[ $RESULT_check_path -ne -1 ] && \
|
|
||||||
[ $RESULT_check_port -ne -1 ] && \
|
|
||||||
[ $RESULT_check_backup -ne -1 ] && \
|
|
||||||
[ $RESULT_check_restore -ne -1 ] && \
|
|
||||||
[ $RESULT_change_url -ne -1 ] && \
|
|
||||||
[ $RESULT_action_config_panel -ne -1 ]
|
|
||||||
then level[7]=2
|
|
||||||
else level[7]=0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Evaluate the eighth level
|
# Evaluate the ninth level
|
||||||
# -> High quality package.
|
# -> High quality package.
|
||||||
# The level 8 can be validated only by the official list of app.
|
# The level 9 can be validated only by the official list of app.
|
||||||
level[8]=0
|
level[9]=0
|
||||||
# Define the level 8 only if we're working on a repository. Otherwise, we can't assert that this is the correct app.
|
# Define the level 8 only if we're working on a repository. Otherwise, we can't assert that this is the correct app.
|
||||||
if echo "$app_arg" | grep --extended-regexp --quiet "https?:\/\/"
|
if echo "$app_arg" | grep --extended-regexp --quiet "https?:\/\/"
|
||||||
then
|
then
|
||||||
# Get the last version of the app list
|
# Get the name of the app from the repository name.
|
||||||
wget -nv https://raw.githubusercontent.com/YunoHost/apps/master/apps.json -O "$script_dir/list.json"
|
app_name="$(basename --multiple --suffix=_ynh "$app_arg")"
|
||||||
|
|
||||||
# Get the name of the app from the repository name.
|
# Get the last version of the app list
|
||||||
app_name="$(basename --multiple --suffix=_ynh "$app_arg")"
|
list_url="https://raw.githubusercontent.com/YunoHost/apps/master/apps.json"
|
||||||
# Extract the app part from the json file. From the name line to the next "}" line.
|
if curl $list_url | jq ".$app_name.high_quality" | grep -q "true"
|
||||||
json_app_part=$(sed -n "/\"$app_name\"/,/}/p" "$script_dir/list.json")
|
then
|
||||||
if [ -z "$json_app_part" ]
|
level[9]=2
|
||||||
then
|
fi
|
||||||
echo "$app_name for the repository $app_arg can't be found in the app list."
|
fi
|
||||||
else
|
|
||||||
# Get high_quality tag for this app.
|
|
||||||
high_quality=$(echo "$json_app_part" | grep high_quality | awk '{print $2}')
|
|
||||||
if [ "${high_quality//,/}" == "true" ]
|
|
||||||
then
|
|
||||||
# This app is tag as a High Quality app.
|
|
||||||
level[8]=2
|
|
||||||
fi
|
|
||||||
# Get maintained tag for this app.
|
|
||||||
maintained=$(echo "$json_app_part" | grep maintained | awk '{print $2}')
|
|
||||||
# If maintained isn't empty or at true. This app can't be tag as a High Quality app.
|
|
||||||
# An app tagged as 'request_help' can still be High Quality, but not an app tagged as 'request_adoption'
|
|
||||||
if [ "${maintained//,/}" != "true" ] && [ "${maintained//[,\"]/}" != "request_help" ] && [ -n "$maintained" ]
|
|
||||||
then
|
|
||||||
if [ ${level[8]} -ge 1 ]
|
|
||||||
then
|
|
||||||
echo "As this app isn't maintained, it can't reach the level 8."
|
|
||||||
fi
|
|
||||||
level[8]=0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Evaluate the ninth level
|
|
||||||
# -> Not available yet...
|
|
||||||
level[9]=0
|
|
||||||
|
|
||||||
# Evaluate the tenth level
|
# Evaluate the tenth level
|
||||||
# -> Not available yet...
|
# -> Not available yet...
|
||||||
|
@ -845,7 +814,7 @@ TEST_RESULTS () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the package linter returned a critical error, the app is flagged as broken / level 0
|
# If the package linter returned a critical error, the app is flagged as broken / level 0
|
||||||
if [ $RESULT_linter -eq -2 ]
|
if [ $RESULT_linter -le -2 ]
|
||||||
then
|
then
|
||||||
ECHO_FORMAT "The package linter reported a critical failure ! App is considered broken !\n" "red" "bold"
|
ECHO_FORMAT "The package linter reported a critical failure ! App is considered broken !\n" "red" "bold"
|
||||||
global_level=0
|
global_level=0
|
||||||
|
@ -924,6 +893,9 @@ initialize_values() {
|
||||||
RESULT_witness=0
|
RESULT_witness=0
|
||||||
RESULT_alias_traversal=0
|
RESULT_alias_traversal=0
|
||||||
RESULT_linter=0
|
RESULT_linter=0
|
||||||
|
RESULT_linter_level_6=0
|
||||||
|
RESULT_linter_level_7=0
|
||||||
|
RESULT_linter_level_8=0
|
||||||
RESULT_global_setup=0
|
RESULT_global_setup=0
|
||||||
RESULT_global_remove=0
|
RESULT_global_remove=0
|
||||||
RESULT_check_sub_dir=0
|
RESULT_check_sub_dir=0
|
||||||
|
|
|
@ -83,7 +83,7 @@ sudo apt-get update >> "$LOG_BUILD_LXC" 2>&1
|
||||||
sudo apt-get install -y lxc lxctl >> "$LOG_BUILD_LXC" 2>&1
|
sudo apt-get install -y lxc lxctl >> "$LOG_BUILD_LXC" 2>&1
|
||||||
|
|
||||||
echo -e "\e[1m> Install git, curl and lynx\e[0m" | tee -a "$LOG_BUILD_LXC"
|
echo -e "\e[1m> Install git, curl and lynx\e[0m" | tee -a "$LOG_BUILD_LXC"
|
||||||
sudo apt-get install -y git curl lynx >> "$LOG_BUILD_LXC" 2>&1
|
sudo apt-get install -y git curl lynx jq python3-pip >> "$LOG_BUILD_LXC" 2>&1
|
||||||
# For those who have disabled APT::Install-Recommends we need to manually install the following packages.
|
# For those who have disabled APT::Install-Recommends we need to manually install the following packages.
|
||||||
sudo apt-get install -y debootstrap rsync bridge-utils >> "$LOG_BUILD_LXC" 2>&1
|
sudo apt-get install -y debootstrap rsync bridge-utils >> "$LOG_BUILD_LXC" 2>&1
|
||||||
|
|
||||||
|
|
|
@ -481,6 +481,10 @@ check_success () {
|
||||||
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
|
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_warning () {
|
||||||
|
ECHO_FORMAT "--- WARNING ---\n" "lyellow" "bold"
|
||||||
|
}
|
||||||
|
|
||||||
check_failed () {
|
check_failed () {
|
||||||
ECHO_FORMAT "--- FAIL ---\n" "red" "bold"
|
ECHO_FORMAT "--- FAIL ---\n" "red" "bold"
|
||||||
}
|
}
|
||||||
|
@ -1815,29 +1819,55 @@ PACKAGE_LINTER () {
|
||||||
unit_test_title "Package linter..."
|
unit_test_title "Package linter..."
|
||||||
|
|
||||||
# Execute package linter and linter_result gets the return code of the package linter
|
# Execute package linter and linter_result gets the return code of the package linter
|
||||||
"$script_dir/package_linter/package_linter.py" "$package_path" > "$temp_result"
|
"$script_dir/package_linter/package_linter.py" "$package_path" > "$script_dir/temp_linter_result.log"
|
||||||
|
"$script_dir/package_linter/package_linter.py" "$package_path" --json > "$script_dir/temp_linter_result.json"
|
||||||
# linter_result gets the return code of the package linter
|
|
||||||
local linter_result=$?
|
|
||||||
|
|
||||||
# Print the results of package linter and copy these result in the complete log
|
# Print the results of package linter and copy these result in the complete log
|
||||||
cat "$temp_result" | tee --append "$complete_log"
|
cat "$script_dir/temp_linter_result.log" | tee --append "$complete_log"
|
||||||
|
cat "$script_dir/temp_linter_result.json" >> "$complete_log"
|
||||||
|
|
||||||
# Check the result and print SUCCESS or FAIL
|
RESULT_linter_level_6=0
|
||||||
if [ $linter_result -eq 0 ]
|
RESULT_linter_level_7=0
|
||||||
then # Success
|
RESULT_linter_level_8=0
|
||||||
check_success
|
|
||||||
RESULT_linter=1
|
|
||||||
else # Fail
|
|
||||||
check_failed
|
|
||||||
RESULT_linter=-1
|
|
||||||
|
|
||||||
# If return code is 2, this is critical failure, app should be considered as broken (level 0)
|
# Check we qualify for level 6, 7, 8
|
||||||
if [ $linter_result -eq 2 ]
|
# Linter will have a warning called "app_in_github_org" if app ain't in the
|
||||||
then
|
# yunohost-apps org...
|
||||||
RESULT_linter=-2
|
if ! cat "$script_dir/temp_linter_result.json" | jq ".warning" | grep -q "app_in_github_org"
|
||||||
|
then
|
||||||
|
RESULT_linter_level_6=1
|
||||||
|
fi
|
||||||
|
if cat "$script_dir/temp_linter_result.json" | jq ".success" | grep -q "qualify_for_level_7"
|
||||||
|
then
|
||||||
|
RESULT_linter_level_7=1
|
||||||
|
fi
|
||||||
|
if cat "$script_dir/temp_linter_result.json" | jq ".success" | grep -q "qualify_for_level_8"
|
||||||
|
then
|
||||||
|
RESULT_linter_level_8=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If there are any critical errors, we'll force level 0
|
||||||
|
if [[ -n "$(cat "$script_dir/temp_linter_result.json" | jq ".critical" | grep -v '\[\]')" ]]
|
||||||
|
then
|
||||||
|
check_failed
|
||||||
|
RESULT_linter=-2
|
||||||
|
# If there are any regular errors, we'll cap to 4
|
||||||
|
elif [[ -n "$(cat "$script_dir/temp_linter_result.json" | jq ".error" | grep -v '\[\]')" ]]
|
||||||
|
then # FAil
|
||||||
|
check_failed
|
||||||
|
RESULT_linter=-1
|
||||||
|
# Otherwise, test pass (we'll display a warning depending on if there are
|
||||||
|
# any remaning warnings or not)
|
||||||
|
else
|
||||||
|
if [[ -n "$(cat "$script_dir/temp_linter_result.json" | jq ".warning" | grep -v '\[\]')" ]]
|
||||||
|
then
|
||||||
|
check_warning
|
||||||
|
RESULT_linter=1
|
||||||
|
else
|
||||||
|
check_success
|
||||||
|
RESULT_linter=2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_LAUNCHER () {
|
TEST_LAUNCHER () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue