Skip to content

Commit

Permalink
[+] Add all files
Browse files Browse the repository at this point in the history
  • Loading branch information
toro-nicolas committed Jun 4, 2024
0 parents commit dd4d3b3
Show file tree
Hide file tree
Showing 604 changed files with 112,951 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Disable statistics for generated documentation
docs/html/* linguist-detectable=false
docs/html/search/* linguist-detectable=false
docs/tests/* linguist-detectable=false

110 changes: 110 additions & 0 deletions .github/push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash

# Executables
executables="corewar"

# Couleur pour les messages
RED='\033[0;31m'
GREEN='\033[0;32m'
RESET='\033[0m'
BOLD='\033[1m'

# Fonction pour compter les occurrences d'un mot dans un fichier
count_occurrences() {
local word=$1
local file=$2
grep -o -i -w "$word" "$file" | wc -l
}

# Nom du fichier de résultat
file="plum_result.txt"

# Exécution du coding style checker
plum > $file

# Compter les occurrences de MAJOR, MINOR et INFO
major_count=$(count_occurrences "MAJOR" "$file")
minor_count=$(count_occurrences "MINOR" "$file")
info_count=$(count_occurrences "INFO" "$file")

# Vérifier si le fichier contient plus de 2 occurrences de MAJOR, MINOR ou INFO
if [ $major_count -gt 2 ] || [ $minor_count -gt 2 ] || [ $info_count -gt 2 ]; then
cat $file
echo -e "${RED}${BOLD}${BOLD}INTERDICTION DE PUSH:${RED}${RED} Le fichier contient des erreurs de Coding-Style !$RESET"
rm -rf $file
exit 1
else
echo -e "${GREEN}Aucune erreur de Coding-Style détecter.${RESET}"
fi

# Supprimer le fichier de résultat
rm -rf $file

# Tester la compilation
make >/dev/null 2>&1 &
pid=$!
wait $pid
if [ $? -ne 0 ]; then
echo -e "${RED}${BOLD}INTERDICTION DE PUSH:${RED} La compilation a échouée.${RESET}"
exit 1
else
echo -e "${GREEN}La compilation s'est déroulée correctement.${RESET}"
fi

# Tester
make clean >/dev/null 2>&1 &
pid=$!
wait $pid

# Check la création de l'exécutable
.github/workflows/check_program_compilation $executables >/dev/null 2>&1 &
pid=$!
wait $pid
if [ $? -ne 0 ]; then
echo -e "${RED}${BOLD}INTERDICTION DE PUSH:${RED} Les executables n'ont pas été trouvé.${RESET}"
exit 1
else
echo -e "${GREEN}Les executables ont bien été trouvé.${RESET}"
fi

# Check les fonctions autorisées
.github/workflows/check_banned_functions $executables .github/workflows/authorized_functions.txt > result.txt
pid=$!
wait $pid
if [ $? -ne 0 ]; then
cat result.txt
echo -e "${RED}${BOLD}INTERDICTION DE PUSH:${RED} Des fonctions bannies ont été trouvé.${RESET}"
rm -rf result.txt
exit 1
else
echo -e "${GREEN}Aucune fonction bannie n'a été trouvé.${RESET}"
fi
rm -rf result.txt

# Tester les unit tests
make tests_run >/dev/null 2>&1 &
pid=$!
wait $pid
if [ $? -ne 0 ]; then
echo -e "${RED}${BOLD}INTERDICTION DE PUSH:${RED} Les tests unitaires ont échoués.${RESET}"
exit 1
else
echo -e "${GREEN}Les tests unitaires se sont déroulés correctement.${RESET}"
fi

# Vérifier la taille du repository
make fclean >/dev/null 2>&1 &
pid=$!
wait $pid
size=$(du -sm --exclude='.git' | cut -f1)
limit=30
if [ "$size" -gt "$limit" ]; then
echo -e "${RED}${BOLD}INTERDICTION DE PUSH:${RED} La taille du repository dépasse la limite autorisée ($size MB > $limit MB)${RESET}"
exit 1
else
echo -e "${GREEN}La taille du repository est inférieure à la limite autorisée ($size MB < $limit MB)${RESET}"
fi

# Push
echo -e "${GREEN}${BOLD}PUSH AUTORISÉ !${RESET}"
git push
52 changes: 52 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: my_rpg

on: [push, pull_request]

env:
EXECUTABLE: my_rpg

jobs:
check_coding_style:
runs-on: ubuntu-latest
container:
image: ghcr.io/epitech/coding-style-checker:latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Launch coding style checker
run: check.sh $(pwd) $(pwd)
- name: Check coding style
run:
cat coding-style-reports.log;
.github/workflows/display_coding_style

check_program:
runs-on: ubuntu-latest
container:
image: epitechcontent/epitest-docker
needs: check_coding_style
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Launch "make"
run: make
timeout-minutes: 2
- name: Launch "make clean"
run: make clean
- name: Check program compilation
run: .github/workflows/check_program_compilation ${{ env.EXECUTABLE }}
- name: Launch "make tests_run"
run: make tests_run
timeout-minutes: 2
- name: Check repository size
run: |
make fclean
size=$(du -sm --exclude='.git' | cut -f1)
limit=30
if [ "$size" -gt "$limit" ]; then
echo "::error title=Repository size::Repository size is too big ($size MB > $limit MB)"
exit 1
else
echo "::notice title=Repository size::Repository size is correct ($size MB <= $limit MB)"
exit 0
fi
19 changes: 19 additions & 0 deletions .github/workflows/check_program_compilation
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/python3
import os
from sys import argv

if __name__ == "__main__":
if len(argv) == 2:
file_content = argv[1].split(",")
for file in file_content:
if not os.path.exists(file):
print("::error file=" + file + "::File not found")
exit(1)
if not os.access(file, os.X_OK):
print("::error file=" + file + "::File is not executable")
exit(1)
print("::notice title=Program compilation::All programs was compiled successfully")
exit(0)
else:
print("::notice title=Program compilation::All programs was compiled successfully")
exit(0)
22 changes: 22 additions & 0 deletions .github/workflows/display_coding_style
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/python3

if __name__ == "__main__":
with open("coding-style-reports.log", "r") as f:
file_content = f.readlines()
find = False
if len(file_content) > 0:
for line in file_content:
content = line.split(":")
if len(content[2].split(" ")) > 2:
continue
print("::error file=" + content[0] + ",line=" + content[1] +
",title=" + content[2].split(" ")[1] + " coding style error::" + content[3])
find = True
if find:
exit(1)
else:
print("::notice title=Coding Style::No errors found")
exit(0)
else:
print("::notice title=Coding Style::No errors found")
exit(0)
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
*.log*
/temp
*~
#*#
*.a
a.out
*.gcda
*.gcno
*.gcov
vgcore.*
.#*
*.o
foo.txt
*.old
unit_tests
.idea/
*.psd
.vscode/
maps/
exec
banana_reports
my_rpg
test.png
save/*
Binary file added B-MUL-200_my_rpg-3.pdf
Binary file not shown.
Loading

0 comments on commit dd4d3b3

Please sign in to comment.