my_rpg #110
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: my_rpg | |
on: | |
push: | |
paths: | |
- '**.c' | |
- '**.h' | |
branches-ignore: | |
- 'ga-ignore-*' | |
pull_request: | |
branches-ignore: | |
- 'ga-ignore-*' | |
workflow_dispatch: | |
inputs: | |
executables: | |
description: 'Comma-separated list of executables to check' | |
required: true | |
default: 'my_rpg' | |
run_jp_tests: | |
description: 'Run JsonParser tests' | |
required: true | |
default: false | |
type: boolean | |
schedule: | |
- cron: '0 0 * * *' | |
env: | |
EXECUTABLES: ${{ github.event.inputs.executables }} | |
NOW: "" | |
TIMESTAMP: "" | |
jobs: | |
check_repository_size: | |
name: Check repository size | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check repository size | |
run: | | |
size=$(du -sk --exclude="./.git" "." | cut -f 1) | |
if [ $size -gt 30000 ] | |
then | |
echo "The current directory is bigger than 30MB" | |
echo "::error title=Repository size::The repository is too big, please remove unnecessary files ($size KB)" | |
exit 1 | |
else | |
if [ $size -gt 25000 ] | |
then | |
echo "::warning title=Repository size::The repository is $size KB, the maximum size is 30000 KB" | |
else | |
echo "::notice title=Repository size::The repository is $size KB" | |
fi | |
fi | |
check_coding_style: | |
name: Check coding style | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/epitech/coding-style-checker:latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check coding style | |
run: | | |
check.sh $(pwd) $(pwd) | |
cat coding-style-reports.log > logs.txt | |
cat logs.txt | while read line | |
do | |
echo ::error title=$(echo $line | cut -d':' -f3) coding style error,file=$(echo $line | cut -d':' -f1),line=$(echo $line | cut -d':' -f2 | cut -c 1-):: $(echo $line | cut -d':' -f4) | |
done | |
if [ -s logs.txt ] | |
then | |
exit 1 | |
else | |
echo "::notice title=Coding style::No coding style error found" | |
fi | |
check_static_functions: | |
name: Check static functions | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check static functions | |
run: | | |
nonstatic=0 | |
c_files=$(find . -name "*.c") | |
for file in $c_files; do | |
if [[ $(grep -c "^ *\(int\|void\|double\|float\|char\|long\|short\) *[a-zA-Z0-9_]*([^)]*)" $file) -gt 1 ]]; then | |
echo "::warning title=Check static functions,file=$file::More than one non-static function in this file" | |
nonstatic=1 | |
fi | |
done | |
if [ $nonstatic -eq 0 ] | |
then | |
echo "::notice title=Check static functions::All files do not contain more than one non-static function" | |
fi | |
run_json_parser_tests: | |
name: Run json parser tests | |
if: ${{ github.event.inputs.run_jp_tests == 'true' }} | |
runs-on: ubuntu-latest | |
container: | |
image: epitechcontent/epitest-docker | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check if json parser tests are present | |
run: | | |
if [ ! -d tests/ ] | |
then | |
echo "::warning title=Missing tests::No tests were found in tests/" | |
exit 1 | |
fi | |
- name: Run tests | |
run: | | |
testsfailed=0 | |
make -C tests/ run_tests 2> logs.txt | |
cat logs.txt | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" | while read line | |
do | |
if [[ $line == *"----"* && $line == *":"* ]] | |
then | |
my_file=$(echo $line | cut -d' ' -f2 | cut -d':' -f1) | |
my_line=$(echo $line | cut -d':' -f2) | |
my_message=$(echo $line | cut -d':' -f3 | cut -c2-) | |
echo "::error title=Json Parser test failed,file=$my_file,line=$my_line::$my_message" | |
testsfailed=1 | |
fi | |
done | |
rm logs.txt | |
if [ $testsfailed -eq 1 ] | |
then | |
exit 1 | |
else | |
echo "::notice title=Json Parser tests::All tests passed" | |
fi | |
- name: Make fclean | |
run: make -C tests/ fclean | |
check_program_compilation: | |
name: Check program compilation | |
runs-on: ubuntu-latest | |
container: | |
image: epitechcontent/epitest-docker | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Make | |
run: | | |
make | |
if [ echo $? -ne 0 ] | |
then | |
echo "::error title=Compilation error::Compilation failed" | |
exit 1 | |
else | |
echo "::notice title=Compilation::No compilation error found" | |
fi | |
timeout-minutes: 2 | |
- name: Check warnings | |
run: | | |
warningspresent=0 | |
make re 2> warnings.txt | |
cat warnings.txt | while read line | |
do | |
if [[ $line == *"warning:"* ]] | |
then | |
my_file=$(echo "$line" | cut -d':' -f1) | |
my_line=$(echo "$line" | cut -d':' -f2) | |
my_message=$(echo "$line" | cut -d':' -f5 | cut -c2-) | |
echo "::warning title=Compilation warning,file=$my_file,line=$my_line::$my_message" | |
warningspresent=1 | |
fi | |
done | |
if [ $warningspresent -eq 0 ] | |
then | |
echo "::notice title=Compilation::No compilation warning found" | |
fi | |
- name: Check executables | |
run: | | |
missing=0 | |
IFS=','; read -a array <<< "${{ env.EXECUTABLES }}" | |
for element in "${array[@]}" | |
do | |
if [ -z $(ls | grep -w $element$) ] | |
then | |
echo "::error title=Missing file,file=$element::This file was not found in your repository" | |
missing=1 | |
fi | |
done | |
if [ $missing -eq 1 ] | |
then | |
exit 1 | |
else | |
echo "::notice title=Compilation::All executables were found" | |
fi | |
- name: Make fclean | |
run: make fclean |