|
| 1 | +name: Checking Code Integrity |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + code_integrity_checks: |
| 7 | + name: Code Integrity Checks |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v4 |
| 11 | + |
| 12 | + - name: Run clang-format style check for C/C++ source code. |
| 13 | + |
| 14 | + if: always() |
| 15 | + with: |
| 16 | + clang-format-version: '10' |
| 17 | + check-path: 'src/EnergyPlus' |
| 18 | + |
| 19 | + - name: Run clang-format style check for C/C++ unit test code. |
| 20 | + |
| 21 | + if: always() |
| 22 | + with: |
| 23 | + clang-format-version: '10' |
| 24 | + check-path: 'tst/EnergyPlus/unit' |
| 25 | + |
| 26 | + - name: Custom Check |
| 27 | + if: always() |
| 28 | + run: ./scripts/dev/custom_check.sh . |
| 29 | + |
| 30 | + - name: Install cppcheck |
| 31 | + if: always() |
| 32 | + run: | |
| 33 | + mkdir cppcheck |
| 34 | + cd cppcheck |
| 35 | + wget https://github.com/danmar/cppcheck/archive/2.10.tar.gz |
| 36 | + tar xfz 2.10.tar.gz |
| 37 | + mkdir build |
| 38 | + cd build |
| 39 | + cmake -DCMAKE_BUILD_TYPE=Release ../cppcheck-2.10/ |
| 40 | + make -j $(nproc) |
| 41 | + sudo make install |
| 42 | + cd .. |
| 43 | + rm -Rf cppcheck |
| 44 | +
|
| 45 | + - name: Cache cppcheck-build-directory |
| 46 | + if: always() |
| 47 | + id: cppcheckcache |
| 48 | + uses: actions/cache@v4 |
| 49 | + with: |
| 50 | + path: .cppcheck-build-dir/ |
| 51 | + key: cppcheckcache |
| 52 | + |
| 53 | + - name: cppcheck-build-directory not found |
| 54 | + # If the build cache wasn't found in the cache |
| 55 | + if: always() && steps.cppcheckcache.outputs.cache-hit != 'true' |
| 56 | + run: mkdir .cppcheck-build-dir |
| 57 | + |
| 58 | + - name: cppcheck-build-directory was found |
| 59 | + # If the build cache wasn't found in the cache |
| 60 | + if: always() && steps.cppcheckcache.outputs.cache-hit == 'true' |
| 61 | + run: ls .cppcheck-build-dir/ || true |
| 62 | + |
| 63 | + - name: Run CppCheck |
| 64 | + id: cpp_check_run |
| 65 | + if: always() |
| 66 | + run: > |
| 67 | + cppcheck --cppcheck-build-dir=.cppcheck-build-dir |
| 68 | + -D__cppcheck__ -UEP_Count_Calls -DEP_NO_OPENGL -UGROUND_PLOT -DLINK_WITH_PYTHON -DMSVC_DEBUG -DSKYLINE_MATRIX_REMOVE_ZERO_COLUMNS -U_OPENMP -Ugeneratetestdata |
| 69 | + -DEP_cache_GlycolSpecificHeat -DEP_cache_PsyTsatFnPb -UEP_nocache_Psychrometrics -UEP_psych_errors -UEP_psych_stats |
| 70 | + --force |
| 71 | + --std=c++17 |
| 72 | + --inline-suppr |
| 73 | + --suppress=cppcheckError |
| 74 | + --suppress=unusedFunction:src/EnergyPlus/api/autosizing.cc |
| 75 | + --suppress=unusedFunction:src/EnergyPlus/api/datatransfer.cc |
| 76 | + --suppress=unusedFunction:src/EnergyPlus/api/func.cc |
| 77 | + --suppress=unusedFunction:src/EnergyPlus/api/runtime.cc |
| 78 | + --suppress=unusedFunction:src/EnergyPlus/api/state.cc |
| 79 | + --suppress=unusedFunction:src/EnergyPlus/Psychrometrics.cc |
| 80 | + --enable=all |
| 81 | + -i EnergyPlus/DXCoils.cc |
| 82 | + -i EnergyPlus/RefrigeratedCase.cc |
| 83 | + -i EnergyPlus/SolarShading.cc |
| 84 | + -j $(nproc) |
| 85 | + --template='[{file}:{line}]:({severity}),[{id}],{message}' |
| 86 | + --suppress="uninitvar:*" |
| 87 | + ./src |
| 88 | + 3>&1 1>&2 2>&3 | tee cppcheck.txt |
| 89 | +
|
| 90 | + - name: Parse and colorize cppcheck |
| 91 | + if: always() && steps.cpp_check_run.outcome == 'success' |
| 92 | + run: python ./scripts/dev/colorize_cppcheck_results.py |
| 93 | + |
| 94 | + - name: Upload cppcheck results as artifact |
| 95 | + if: always() |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + with: |
| 98 | + name: EnergyPlus-${{ github.sha }}-cppcheck_results.txt |
| 99 | + path: cppcheck.txt |
0 commit comments