mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
More mail notifications
This commit is contained in:
parent
7453d5994b
commit
e0ddde7db5
4 changed files with 108 additions and 8 deletions
13
README-fr.md
13
README-fr.md
|
@ -80,6 +80,9 @@ package_check/package_check.sh APP_ynh
|
|||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
```
|
||||
### `;; Nom du test`
|
||||
Nom du scénario de test qui sera effectué.
|
||||
|
@ -128,6 +131,16 @@ Il est à noter que les niveaux 4, 8, 9 et 10 ne peuvent être fixés à *auto*
|
|||
- Niveau 9 : L'application respecte toutes les YEP optionnelles. -- Doit être vérifié manuellement
|
||||
- Niveau 10 : L'application est jugée parfaite. -- Doit être vérifié manuellement
|
||||
|
||||
### `;;; Options`
|
||||
Options supplémentaires disponible dans le check_process.
|
||||
Ces options sont facultatives.
|
||||
|
||||
- `Email` : Permet d'indiquer un email alternatif à celui qui est présent dans le manifest pour les notifications de package check, lorsque celui-ci s'exécute en contexte d'intégration continue.
|
||||
- `Notification` : Degré de notification souhaité pour l'application. Il y a 3 niveaux de notification disponible.
|
||||
- `down` : Envoi un mail seulement si le niveau de l'application a baissé.
|
||||
- `change` : Envoi un mail seulement si le niveau de l'application a changé.
|
||||
- `all` : Envoi un mail pour chaque test de l'application, quel que ce soit le résultat.
|
||||
|
||||
---
|
||||
Le script `package_check.sh` accepte 6 arguments en plus du package à tester.
|
||||
- `--bash-mode`: Rend le script autonome. Aucune intervention de l'utilisateur ne sera nécessaire.
|
||||
|
|
13
README.md
13
README.md
|
@ -80,6 +80,9 @@ package_check/package_check.sh APP_ynh
|
|||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
```
|
||||
### `;; Test name`
|
||||
Name of tests series that will be perform.
|
||||
|
@ -128,6 +131,16 @@ The level 4, 8, 9 and 10 shouldn't be fixed at *auto*, because they don't be tes
|
|||
- Level 9 : The application respects all optionnal YEP. -- Must be validated manually
|
||||
- Level 10 : The application has judged as perfect. -- Must be validated manually
|
||||
|
||||
### `;;; Options`
|
||||
Supplementary options available in the check_process.
|
||||
These options are facultative.
|
||||
|
||||
- `Email` : Allow to specify an alternative email than this is in the manifest for notification by package check, when it's in a context of continuous integration.
|
||||
- `Notification` : Grade of notification for this application. There are 3 available levels.
|
||||
- `down` : Send an email only if the level of this application has decreased.
|
||||
- `change` : Send an email if the level of this application has changed.
|
||||
- `all` : Send an email for each test on this application, whiech ever the result.
|
||||
|
||||
---
|
||||
The `package_check.sh` script accept 6 arguments in addition of package to be checked.
|
||||
- `--bash-mode`: The script will work without user intervention.
|
||||
|
|
|
@ -32,3 +32,6 @@
|
|||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
|
|
|
@ -806,9 +806,10 @@ then
|
|||
partial1="${check_process}_part1"
|
||||
partial2="${check_process}_part2"
|
||||
|
||||
|
||||
# Extract the level section
|
||||
partial_check_process=$partial1
|
||||
extract_section "^;;; Levels" "^;; " "$check_process"
|
||||
extract_section "^;;; Levels" ";; " "$check_process"
|
||||
|
||||
# Get the value associated to each level
|
||||
for i in `seq 1 10`
|
||||
|
@ -819,6 +820,19 @@ then
|
|||
level[$i]=$(echo "$line" | cut -d'=' -f2)
|
||||
done
|
||||
|
||||
|
||||
# Extract the Options section
|
||||
partial_check_process=$partial1
|
||||
extract_section "^;;; Options" ";; " "$check_process"
|
||||
|
||||
# Try to find a optionnal email address to notify the maintainer
|
||||
# In this case, this email will be used instead of the email from the manifest.
|
||||
dest="$(echo $(find_string "^Email=") | cut -d '=' -f2)"
|
||||
|
||||
# Try to find a optionnal option for the grade of notification
|
||||
notification_grade="$(echo $(find_string "^Notification=") | cut -d '=' -f2)"
|
||||
|
||||
|
||||
# Parse each tests serie
|
||||
while read tests_serie
|
||||
do
|
||||
|
@ -1073,17 +1087,54 @@ echo "You can find the complete log of these tests in $complete_log"
|
|||
|
||||
|
||||
|
||||
#=================================================
|
||||
# Notification grade
|
||||
#=================================================
|
||||
|
||||
notif_grade () {
|
||||
# Check the level of notification from the check_process.
|
||||
# Echo 1 if the grade is reached
|
||||
|
||||
compare_grade ()
|
||||
{
|
||||
if echo "$notification_grade" | grep -q "$1"; then
|
||||
echo 1
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
all)
|
||||
# If 'all' is needed, only a grade of notification at 'all' can match
|
||||
compare_grade "^all$"
|
||||
;;
|
||||
change)
|
||||
# If 'change' is needed, notification at 'all' or 'change' can match
|
||||
compare_grade "^all$\|^change$"
|
||||
;;
|
||||
down)
|
||||
# If 'down' is needed, notification at 'all', 'change' or 'down' match
|
||||
compare_grade "^all$\|^change$\|^down$"
|
||||
;;
|
||||
*)
|
||||
echo 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# Inform of the results by XMPP and/or by mail
|
||||
#=================================================
|
||||
|
||||
send_mail=0
|
||||
|
||||
# Keep only the name of the app
|
||||
app_name=${package_dir%_ynh_check}
|
||||
|
||||
# If package check it's in the official CI environment
|
||||
# Check the level variation
|
||||
elif [ $type_exec_env -eq 2 ]
|
||||
if [ $type_exec_env -eq 2 ]
|
||||
then
|
||||
|
||||
# Get the job name, stored in the work_list
|
||||
|
@ -1125,15 +1176,22 @@ then
|
|||
# If non previous level was found
|
||||
if [ -z "$previous_level" ]; then
|
||||
message="$message just reach the level $global_level"
|
||||
send_mail=$(notif_grade all)
|
||||
# If the level stays the same
|
||||
elif [ $global_level -eq $previous_level ]; then
|
||||
message="$message stays at level $global_level"
|
||||
# Need notification at 'all' to notify by email
|
||||
send_mail=$(notif_grade all)
|
||||
# If the level go up
|
||||
elif [ $global_level -gt $previous_level ]; then
|
||||
message="$message rise from level $previous_level to level $global_level"
|
||||
# Need notification at 'change' to notify by email
|
||||
send_mail=$(notif_grade change)
|
||||
# If the level go down
|
||||
elif [ $global_level -lt $previous_level ]; then
|
||||
message="$message go down from level $previous_level to level $global_level"
|
||||
# Need notification at 'down' to notify by email
|
||||
send_mail=$(notif_grade down)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
@ -1141,9 +1199,15 @@ fi
|
|||
# If the app completely failed and obtained 0
|
||||
if [ $global_level -eq 0 ]
|
||||
then
|
||||
message="${message}Application $app_name has completely failed the continuous integration tests"
|
||||
message="${message}Application $app_name has completely failed the continuous integration tests"
|
||||
|
||||
# Always send an email if the app failed
|
||||
send_mail=1
|
||||
fi
|
||||
|
||||
# The mail subject is the message to send, before any logs informations
|
||||
subject="[YunoHost] $message"
|
||||
|
||||
# If the test was perform in the official CI environment
|
||||
# Add the log address
|
||||
# And inform with xmpp
|
||||
|
@ -1164,17 +1228,24 @@ then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Send a mail to main maintainer if the app failed and obtained the level 0.
|
||||
# Send a mail to main maintainer according to notification option in the check_process.
|
||||
# Only if package check is in a CI environment (Official or not)
|
||||
if [ $global_level -eq 0 ] && [ $type_exec_env -ge 1 ]
|
||||
if [ $type_exec_env -ge 1 ] && [ $send_mail -eq 1 ]
|
||||
then
|
||||
|
||||
# Get the maintainer email from the manifest
|
||||
dest=$(grep '\"email\": ' "$package_path/manifest.json" | cut -d '"' -f 4)
|
||||
# Add a 'from' header for the official CI only.
|
||||
if [ $type_exec_env -eq 2 ]; then
|
||||
from_yuno="-a \"From: yunohost@yunohost.org\""
|
||||
fi
|
||||
|
||||
# Get the maintainer email from the manifest. If it doesn't found if the check_process
|
||||
if [ -z "$dest" ]; then
|
||||
dest=$(grep '\"email\": ' "$package_path/manifest.json" | cut -d '"' -f 4)
|
||||
fi
|
||||
|
||||
# Send the message by mail, if a address has been find
|
||||
if [ -n "$dest" ]; then
|
||||
mail -a "From: yunohost@yunohost.org" -s "[YunoHost] Your app $app_name has completely failed the continuous integration tests" "$dest" <<< "$message"
|
||||
mail $from_yuno -s "$subject" "$dest" <<< "$message"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue