exhaustive-analysis.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # .github/workflows/exhaustive-analysis.yml
  2. # Thorough static analysis for releases and scheduled runs
  3. ---
  4. name: Exhaustive Analysis
  5. on:
  6. # Run on release branches and tags
  7. push:
  8. branches:
  9. - "release/**"
  10. tags:
  11. - "v*"
  12. # Nightly exhaustive analysis
  13. schedule:
  14. - cron: "0 3 * * *" # 3 AM UTC daily
  15. # Manual trigger
  16. workflow_dispatch:
  17. permissions:
  18. contents: read
  19. issues: write
  20. pull-requests: write
  21. env:
  22. BUILD_TYPE: Release
  23. jobs:
  24. exhaustive-lint:
  25. name: Exhaustive Static Analysis
  26. runs-on: ubuntu-latest
  27. timeout-minutes: 90
  28. steps:
  29. - name: Checkout Code
  30. uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
  31. with:
  32. fetch-depth: 0
  33. - name: MegaLinter (Exhaustive)
  34. uses: oxsecurity/megalinter/flavors/c_cpp@55a59b24a441e0e1943080d4a512d827710d4a9d
  35. id: ml
  36. env:
  37. VALIDATE_ALL_CODEBASE: true
  38. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  39. DISABLE_LINTERS: SPELL_CSPELL
  40. DISABLE_ERRORS: false
  41. # Exhaustive cppcheck analysis
  42. C_CPPCHECK_ARGUMENTS: >-
  43. --check-level=exhaustive
  44. --inline-suppr
  45. --enable=warning,style,performance,portability
  46. --std=c99
  47. --platform=unix64
  48. --suppress=missingIncludeSystem
  49. --suppress=missingInclude
  50. - name: Archive Exhaustive Reports
  51. if: always()
  52. uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
  53. with:
  54. name: megalinter-exhaustive-reports
  55. path: |
  56. megalinter-reports
  57. mega-linter.log
  58. retention-days: 30
  59. - name: Create Issue on Failure
  60. if: failure() && github.event_name == 'schedule'
  61. uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd
  62. with:
  63. script: |
  64. const runUrl = `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}`;
  65. github.rest.issues.create({
  66. owner: context.repo.owner,
  67. repo: context.repo.repo,
  68. title: '🔍 Exhaustive Static Analysis Failed',
  69. body: `The nightly exhaustive static analysis has detected issues.
  70. **Run:** ${runUrl}
  71. **Date:** ${new Date().toISOString()}
  72. Please review the analysis reports in the workflow artifacts.`,
  73. labels: ['automated', 'static-analysis']
  74. });
  75. build-release:
  76. name: Build & Test (Release Config)
  77. runs-on: ubuntu-latest
  78. needs: exhaustive-lint
  79. if: success()
  80. steps:
  81. - name: Checkout Code
  82. uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
  83. with:
  84. fetch-depth: 0
  85. - name: Install Dependencies
  86. run: |
  87. sudo apt-get update
  88. sudo apt-get install -y \
  89. libcap-dev \
  90. lcov \
  91. cpputest
  92. - name: Set up Python
  93. uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
  94. with:
  95. python-version: "3.11"
  96. - name: Install gcovr
  97. run: pip install gcovr
  98. - name: Configure CMake (Release)
  99. run: |
  100. cmake -S ${{ github.workspace }}/source \
  101. -B ${{ github.workspace }}/build \
  102. -DCMAKE_BUILD_TYPE=Release \
  103. -DOpENer_PLATFORM:STRING="POSIX" \
  104. -DBUILD_SHARED_LIBS:BOOL=OFF \
  105. -DOpENer_TRACES:BOOL=OFF \
  106. -DOpENer_TESTS:BOOL=ON \
  107. -DCPPUTEST_HOME:PATH=/usr \
  108. -DCMAKE_C_FLAGS="-O2 -Wall -Wextra -Werror"
  109. - name: Build
  110. run: cmake --build "${{ github.workspace }}/build" --config Release -j "$(nproc)"
  111. - name: Test
  112. working-directory: ${{ github.workspace }}/build
  113. run: ctest -C Release --output-on-failure --parallel "$(nproc)"
  114. - name: Generate Release Coverage
  115. run: |
  116. gcovr --html-details --output coverage-release.html
  117. gcovr --cobertura --output coverage-release.xml
  118. gcovr --print-summary | tee coverage-release-summary.txt
  119. - name: Upload Release Artifacts
  120. uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
  121. with:
  122. name: release-build-artifacts
  123. path: |
  124. ${{ github.workspace }}/build
  125. coverage-release*.html
  126. coverage-release.xml
  127. coverage-release-summary.txt
  128. retention-days: 90