|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +function sha () |
| 4 | +{ |
| 5 | + sha512sum | cut -d " " -f 1 |
| 6 | +} |
| 7 | + |
| 8 | +for f in .github/workflows/* ; do |
| 9 | + expected_sha=$(wget -qO- "https://raw.githubusercontent.com/MATF-Software-Verification/VS-project-ci/main/$f" | sha) |
| 10 | + current_sha=$(cat $f | sha) |
| 11 | + if [ "$expected_sha" != "$current_sha" ]; then |
| 12 | + echo "FATAL: Your CI files are not in sync with the official repository - make sure the .github/ directory matches the upstream" |
| 13 | + exit 2 |
| 14 | + fi |
| 15 | +done |
| 16 | +if [ -f gate ]; then |
| 17 | + echo "FATAL: The 'gate' script should not be added to the repository - CI checks use the upstream version" |
| 18 | + exit 2 |
| 19 | +fi |
| 20 | +echo "PASS: GitHub workflows are up to date" |
| 21 | + |
| 22 | +ret=0 |
| 23 | + |
| 24 | +function flc () |
| 25 | +{ |
| 26 | + cat "$@" 2>/dev/null | wc -l |
| 27 | +} |
| 28 | + |
| 29 | +# Submodule check |
| 30 | +submodule_count=$(git submodule | wc -l) |
| 31 | +if [ $submodule_count -eq 0 ]; then |
| 32 | + echo "FAIL: The repository does not appear to contain a submodule pointing to the original project. See: https://git-scm.com/book/en/v2/Git-Tools-Submodules" |
| 33 | + ret=1 |
| 34 | +else |
| 35 | + echo "PASS: Submodule check passed" |
| 36 | +fi |
| 37 | + |
| 38 | +# Binary files check |
| 39 | +if find . -exec file {} \; | grep -i elf ; then |
| 40 | + echo "FAIL: ELF files located in the repository. You should not upload executable files, use .gitignore to ignore such files." |
| 41 | + ret=1 |
| 42 | +else |
| 43 | + echo "PASS: ELF type check passed" |
| 44 | +fi |
| 45 | + |
| 46 | +# LICENSE check |
| 47 | +if [ ! -f LICENSE ]; then |
| 48 | + echo "WARN: LICENSE missing. Please add a license." |
| 49 | +else |
| 50 | + echo "PASS: LICENSE check" |
| 51 | +fi |
| 52 | + |
| 53 | +# README check |
| 54 | +if [ -f "README.md" ]; then |
| 55 | + readme_lc=$(flc README.md) |
| 56 | + if [ $readme_lc -lt 10 ]; then |
| 57 | + echo "FAIL: README is not detailed enough. Please add a more extensive README." |
| 58 | + ret=1 |
| 59 | + else |
| 60 | + echo "PASS: README check" |
| 61 | + fi |
| 62 | +else |
| 63 | + echo "FAIL: README missing" |
| 64 | + ret=1 |
| 65 | +fi |
| 66 | + |
| 67 | +# ProjectAnalysisReport check |
| 68 | +par_lc=$(flc ProjectAnalysisReport.*) |
| 69 | +if [ $par_lc != 0 ]; then |
| 70 | + if [ $par_lc -lt 50 ]; then |
| 71 | + echo "FAIL: ProjectAnalysisReport is not detailed enough. Please add a more extensive ProjectAnalysisReport." |
| 72 | + ret=1 |
| 73 | + else |
| 74 | + echo "PASS: ProjectAnalysisReport check" |
| 75 | + fi |
| 76 | +else |
| 77 | + echo "FAIL: ProjectAnalysisReport missing" |
| 78 | + ret=1 |
| 79 | +fi |
| 80 | + |
| 81 | + |
| 82 | +# Final note |
| 83 | +if [ $ret -ne 0 ]; then |
| 84 | + echo |
| 85 | + echo "=== GATE FAILED ===" |
| 86 | + echo "Please re-read instructions on the course webpage: https://www.verifikacijasoftvera.matf.bg.ac.rs/#1_tab" |
| 87 | +else |
| 88 | + echo "=== GATE PASSED ===" |
| 89 | +fi |
| 90 | + |
| 91 | +exit $ret |
0 commit comments