├── README.md ├── install.sh ├── readme-src ├── green_discord_report.png ├── green_discord_report_resized.png ├── orange_discord_report.png ├── orange_discord_report_resized.png ├── red_discord_report.png ├── red_discord_report_resized.png ├── yellow_discord_report.png └── yellow_discord_report_resized.png └── src └── discordci /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Discord Ci ![issue](https://img.shields.io/github/issues/vavarier/install-discord-action?label=Discordci%20issue%27s&style=for-the-badge) 3 | 4 | Discord Ci est un outil pour les projets EPITECH permettant de lancer une norminette et des tests fonctionnels sur n'importe quel projet déjà implémentés. 5 | Les résultats des tests fonctionnels et de la norminette sont envoyés sur Discord. 6 | Tous les tests fonctionnels sont effectués sur l'environnement de la moulinette EPITECH. 7 | 8 | ## Sommaire 9 | 10 | 1. [Installation](#installation0) 11 | 1. [Créer un répo Github vide privé](#installation1) 12 | 2. [Cloner le repo](#installation2) 13 | 3. [Commencer l’installation](#installation3) 14 | 2. [Utilisation](#utilisation) 15 | 3. [Output](#output) 16 | 1. [Flags et discord report](#output1) 17 | 2. [Trace](#output2) 18 | 4. [Crédits](#credits) 19 | 20 | ## Installation 21 | 22 | ### 1- Créer un répo Git Hub vide privé 23 | 24 | Ce répo va permettre au programme d’effectuer différents Github actions et de passer le projet au peigne fin avec une norminette. 25 | 26 | ### 2- cloner le répo Git Hub de discord Ci 27 | 28 | le plus optimal est de cloner le répo dans : 29 | ``` 30 | /home/[nom d'utilisateur] 31 | ``` 32 | 33 | ### 3- Commencer l'Installation 34 | 35 | #### 3.1- exécuter l'installer dans le dossier cloner 36 | 37 | pour cela rentrez dans le repo et effectuez cette commande : 38 | ```bas 39 | ./install.sh 40 | ``` 41 | 42 | #### 3.2- renseigner la clef ssh de votre repo créé lors de l'étape 1 43 | 44 | lorsque ce message apparaîtra : 45 | ``` 46 | => PLS give an empty repository link 47 | ``` 48 | écrivez le lien ssh vers le repo créé lors de l'étape 1 49 | 50 | _exemple_ _clef_ _ssh_ _:_ 51 | 52 | ``git@github.com:[utilisateur name]/[project name].git`` 53 | 54 | #### 3.3- Créer un webhook 55 | 56 | Pour que Discord Ci vous envoi les résultats de ses tests vous allez devoir créer un webhook dans le channel Discord où vous voulez votre récapitulatif. 57 | 58 | Suivez ce lien pour créer un **[webhook]**(https://support.discord.com/hc/fr/articles/228383668-Utiliser-les-Webhooks) dans Discord 59 | 60 | #### 3.3- Renseigner l'adresse du webhook 61 | 62 | Coller le lien du webhook lorsque ce message sera affiché : 63 | ``` 64 | => PLS give discord webhook link 65 | ``` 66 | 67 | Ecrivez le lien du webhook créer dans l'étape précédente. 68 | 69 | #### voila vous avez installé et configuré Discord Ci 70 | 71 | ## Utilisation 72 | 73 | ### ``discordci`` 74 | 75 | > Affiche l'aide. 76 | 77 | ### ``discordci update`` 78 | 79 | > Télécharge et installe la dernière version de Discord Ci 80 | 81 | ### ``discordci web [webhook link]`` 82 | 83 | > Permet de changer le salon discord dans lequel Discord Ci envoi le compte rendu 84 | 85 | ### ``discordci repo [Git Hub SSH link]`` 86 | 87 | > Permet de changer le répo Github utilisé par Discord Ci 88 | 89 | ### ``discordci [path to the folder] [name of the project]`` 90 | 91 | > Permet de lancer une moulinette sur votre projet 92 | 93 | ### ``discordci [path to the folder] norm`` 94 | 95 | > Permet de n'appliquer que la norme 96 | 97 | ## Output 98 | 99 | ### Flag et discord report 100 | 101 | ![green_discord_report](https://github.com/vavarier/install-discord-action/blob/main/readme-src/green_discord_report_resized.png) 102 | 103 | ![issue](https://img.shields.io/badge/mouli-success-light--green?style=for-the-badge&logo=Cachet) 104 | > Tous les tests ont été passé et pas d'erreur de norme. 105 | 106 | ![yellow_discord_report](https://github.com/vavarier/install-discord-action/blob/main/readme-src/yellow_discord_report_resized.png) 107 | 108 | ![issue](https://img.shields.io/badge/mouli-norm%20error-ffff00?style=for-the-badge&logo=Swagger) 109 | > Les tests et la compilation ont été passé mais le projet contient des erreurs de normes. 110 | 111 | ![orange_discord_report](https://github.com/vavarier/install-discord-action/blob/main/readme-src/orange_discord_report_resized.png) 112 | 113 | ![issue](https://img.shields.io/badge/mouli-test%20error-ff7f00?style=for-the-badge&logo=Speedtest) 114 | > Il n'y a pas d'erreur de norme. Cepandant, il y a des tests qui ne sont pas passé. 115 | 116 | ![red_discord_report](https://github.com/vavarier/install-discord-action/blob/main/readme-src/red_discord_report_resized.png) 117 | 118 | ![issue](https://img.shields.io/badge/mouli-build%20error-ff0000?style=for-the-badge&logo=ZeroMQ) 119 | > Votre projet ne compile pas. 120 | 121 | ### Trace 122 | 123 | Le flag et le discord report viennent avec une trace sous le nom de ``trace.md``. 124 | Cette trace permet de voir en profondeur les erreurs de normes, les erreurs de compilation ou bien les tests qui ont échoués. 125 | 126 | 127 | ## Crédis 128 | 129 | ### Conception / programmation 130 | 131 | Valentin Dury : 132 | [![linkeding bage](https://img.shields.io/badge/-linkedind-0A66C2?logo=linkedin&style=for-the-badge)](https://www.linkedin.com/in/valentin-dury/) 133 | [![git hub bage](https://img.shields.io/badge/-GitHub-181717?logo=GitHub&style=for-the-badge)](https://github.com/Ardorax) 134 | [![mail](https://img.shields.io/badge/-Mail-0078D4?logo=Microsoft-Outlook&style=for-the-badge)](mailto:valentin.dury@epitech.eu) 135 | 136 | Valentin Nouri : 137 | [![git hub bage](https://img.shields.io/badge/-GitHub-181717?logo=GitHub&style=for-the-badge)](https://github.com/) 138 | [![mail](https://img.shields.io/badge/-Mail-0078D4?logo=Microsoft-Outlook&style=for-the-badge)](mailto:valentin.nouri@epitech.eu) 139 | 140 | ### Rédaction 141 | 142 | Baptiste Leroyer : 143 | [![linkeding bage](https://img.shields.io/badge/-linkedind-0A66C2?logo=linkedin&style=for-the-badge)](https://www.linkedin.com/in/baptiste-leroyer-a69894227/) 144 | [![git hub bage](https://img.shields.io/badge/-GitHub-181717?logo=GitHub&style=for-the-badge)](https://github.com/ZiplEix) 145 | [![mail](https://img.shields.io/badge/-Mail-0078D4?logo=Microsoft-Outlook&style=for-the-badge)](mailto:baptiste.leroyer@epitech.eu) 146 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "=> Browse to find old versions..." 3 | FILE=/usr/local/lib/discordci/ 4 | if [ -d $FILE ] 5 | then 6 | echo "=> Erasing old repository..." 7 | sudo rm -rf $FILE 8 | fi 9 | FILE=/usr/bin/discordci 10 | if [ -f $FILE ] 11 | then 12 | echo "=> Erasing old bin..." 13 | sudo rm -rf $FILE 14 | fi 15 | tput setaf 2 16 | echo "=> Done cleaning" 17 | tput sgr0 18 | 19 | echo "=> PLS give an empty repository link" 20 | while read line; do 21 | link=$line 22 | break 23 | done 24 | echo "=> PLS give discord webhook link" 25 | while read line; do 26 | discord=$line 27 | break 28 | done 29 | 30 | echo "=> Creating repository..." 31 | git clone $link discordci 32 | sudo mv discordci /usr/local/lib 33 | sudo echo $discord > /usr/local/lib/discordci/weblink 34 | tput setaf 2 35 | echo "=> Repository_created" 36 | tput sgr0 37 | 38 | echo "=> Copying source code..." 39 | sudo cp src/discordci /usr/local/bin/ 40 | tput setaf 2 41 | echo "=> Done copying source code" 42 | tput sgr0 43 | 44 | echo "=> Giving permissions..." 45 | sudo chmod 777 /usr/local/bin/discordci 46 | sudo chmod -R 777 /usr/local/lib/discordci 47 | tput setaf 2 48 | echo "=> Permissions given" 49 | tput sgr0 50 | 51 | tput setab 2 52 | tput blink 53 | echo "=> Installation Done" 54 | tput init 55 | tput sgr0 56 | -------------------------------------------------------------------------------- /readme-src/green_discord_report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vavarier/install-discord-action/32e11745f2eda2d7041ecb03c55fdaeb95961624/readme-src/green_discord_report.png -------------------------------------------------------------------------------- /readme-src/green_discord_report_resized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vavarier/install-discord-action/32e11745f2eda2d7041ecb03c55fdaeb95961624/readme-src/green_discord_report_resized.png -------------------------------------------------------------------------------- /readme-src/orange_discord_report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vavarier/install-discord-action/32e11745f2eda2d7041ecb03c55fdaeb95961624/readme-src/orange_discord_report.png -------------------------------------------------------------------------------- /readme-src/orange_discord_report_resized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vavarier/install-discord-action/32e11745f2eda2d7041ecb03c55fdaeb95961624/readme-src/orange_discord_report_resized.png -------------------------------------------------------------------------------- /readme-src/red_discord_report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vavarier/install-discord-action/32e11745f2eda2d7041ecb03c55fdaeb95961624/readme-src/red_discord_report.png -------------------------------------------------------------------------------- /readme-src/red_discord_report_resized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vavarier/install-discord-action/32e11745f2eda2d7041ecb03c55fdaeb95961624/readme-src/red_discord_report_resized.png -------------------------------------------------------------------------------- /readme-src/yellow_discord_report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vavarier/install-discord-action/32e11745f2eda2d7041ecb03c55fdaeb95961624/readme-src/yellow_discord_report.png -------------------------------------------------------------------------------- /readme-src/yellow_discord_report_resized.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vavarier/install-discord-action/32e11745f2eda2d7041ecb03c55fdaeb95961624/readme-src/yellow_discord_report_resized.png -------------------------------------------------------------------------------- /src/discordci: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import os 3 | from sys import * 4 | import fileinput 5 | import requests 6 | 7 | class Colors: 8 | OK = '\033[92m' 9 | WARNING = '\033[93m' 10 | FAIL = '\033[91m' 11 | END = '\033[0m' 12 | 13 | 14 | 15 | #help 16 | def helping(): 17 | print("Error in argument") 18 | print(" discordci -> print help") 19 | print(" discordci update -> update your bin") 20 | print(" discordci web [webhook link] -> change your webhook") 21 | print(" discordci repo [github ssh link] -> change the link of your empty repository") 22 | print(" discordci [path to the repo] [name of the project] -> lauch mouli on your project") 23 | print(" discordci [path to the repo] norm -> only apply norm and your repo") 24 | exit (0) 25 | 26 | #repo 27 | def set_repo(argv): 28 | if (len(argv) != 3): 29 | helping() 30 | print("ready to reset the empty github repo") 31 | os.system("sudo mv /usr/local/lib/discordci/weblink ~/") 32 | os.system("sudo rm -rf /usr/local/lib/discordci") 33 | os.system("git clone " + argv[2] + " ~/discordci") 34 | os.system("sudo mv ~/discordci /usr/local/lib/") 35 | os.system("sudo mv ~/weblink /usr/local/lib/discordci/") 36 | print(Colors.OK + "Update Done" + Colors.END) 37 | exit (0) 38 | 39 | #update 40 | def update(): 41 | print("ready to update your discordCI") 42 | os.system("git clone https://github.com/vavarier/install-discord-action ~/updatevanouri") 43 | os.system("sudo rm -rf /usr/local/bin/discordci") 44 | os.system("sudo cp ~/updatevanouri/src/discordci /usr/local/bin") 45 | os.system("rm -rf ~/updatevanouri") 46 | print(Colors.OK + "Update Done" + Colors.END) 47 | exit (0) 48 | 49 | #weblink 50 | def set_weblink(argv): 51 | print("ready to reset the webhook") 52 | os.system("echo " + argv[2] + " > /usr/local/lib/discordci/weblink") 53 | print(Colors.OK + "Update Done" + Colors.END) 54 | exit (0) 55 | 56 | def param(command, argv): 57 | if (command == "update"): 58 | update() 59 | if (command == "repo"): 60 | set_repo(argv) 61 | if (command == "web"): 62 | set_weblink(argv) 63 | 64 | #parsarg 65 | def parsarg(command, argv): 66 | if(os.path.isdir(command) == False): 67 | print("Directory dasn't exist") 68 | exit (84) 69 | url = "https://github.com/moulitek/" 70 | url += argv[2] 71 | r = requests.head(url) 72 | r = str(r)[11:-2] 73 | if (r == str(404)): 74 | print("this repo dasn't exist if this an error pls set an issue") 75 | exit (84) 76 | 77 | #normaluse 78 | def sending(command, argv): 79 | if(command[-1] != '/'): 80 | command += '/' 81 | #fill the push 82 | os.system("cp -rf " + command + "* " + command + ".gitignore /usr/local/lib/discordci") 83 | os.system("git clone https://github.com/moulitek/" + argv[2] + " ~/mouliDV") 84 | os.system("cp -rf ~/mouliDV/.github ~/mouliDV/mouliVD /usr/local/lib/discordci") 85 | os.chdir("/usr/local/lib/discordci") 86 | os.system("rm -rf ~/mouliDV") 87 | #push everything 88 | os.system("git add .") 89 | os.system("git commit -m new_push") 90 | os.system("git push") 91 | #clean the repo 92 | os.system("mkdir ~/valencum") 93 | os.system("cp -rf /usr/local/lib/discordci/.git /usr/local/lib/discordci/weblink ~/valencum") 94 | os.system("rm -rf /usr/local/lib/discordci/* /usr/local/lib/discordci/.*") 95 | #reset the repo 96 | os.system("mv ~/valencum /usr/local/lib/discordci") 97 | os.system("mv /usr/local/lib/discordci/valencum/.git /usr/local/lib/discordci/valencum/weblink /usr/local/lib/discordci") 98 | os.system("rm -rf /usr/local/lib/discordci/valencum") 99 | #push everything 100 | os.system("git add .") 101 | os.system("git commit -m new_push") 102 | os.system("git push") 103 | 104 | if (len(argv) <= 1 or len(argv) >= 4): 105 | helping() 106 | command = argv[1] 107 | 108 | ref = [["update"], ["repo"], ["web"]] 109 | for i in range(len(ref)): 110 | if (command == str(ref[i])[2:-2]): 111 | param(command, argv) 112 | 113 | parsarg(command, argv) 114 | sending(command, argv) 115 | --------------------------------------------------------------------------------