pr-comments.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. name: PR Comments
  2. on:
  3. pull_request:
  4. branches:
  5. - master
  6. jobs:
  7. backend-tests-and-coverage:
  8. runs-on: ubuntu-latest
  9. steps:
  10. - name: Checkout code
  11. uses: actions/checkout@v4
  12. - name: Set up Python 3.11
  13. uses: actions/setup-python@v5
  14. with:
  15. python-version: 3.11
  16. - name: Cache pip
  17. uses: actions/cache@v4
  18. with:
  19. # This path is specific to Ubuntu
  20. path: ~/.cache/pip
  21. key: ${{ runner.os }}-pip-${{ hashFiles('desktop/core/generate_requirements.py') }}
  22. restore-keys: |
  23. ${{ runner.os }}-pip-
  24. ${{ runner.os }}-
  25. - name: Setup node 20 and cache npm
  26. uses: actions/setup-node@v4
  27. with:
  28. node-version: 20
  29. cache: 'npm'
  30. - name: Build Hue
  31. run: |
  32. sudo apt-get update
  33. sudo apt-get install -y build-essential asciidoc libkrb5-dev libldap2-dev libsasl2-dev libxslt-dev libsasl2-modules-gssapi-mit libsnappy-dev libgdbm-dev
  34. export PYTHON_VER=python3.11
  35. export SKIP_PYTHONDEV_CHECK=true
  36. export ROOT=$PWD
  37. make apps test_prep
  38. - name: Run python unit tests
  39. continue-on-error: true
  40. run: |
  41. ./build/env/bin/pytest
  42. - name: Add pytest and code coverage PR comment
  43. uses: MishaKav/pytest-coverage-comment@v1
  44. with:
  45. pytest-xml-coverage-path: ./reports/code-cov/coverage.xml
  46. title: Backend Code Coverage Report
  47. badge-title: Coverage
  48. report-only-changed-files: true
  49. xml-skip-covered: true
  50. remove-link-from-badge: true
  51. default-branch: master
  52. python-ut-files-check:
  53. runs-on: ubuntu-latest
  54. steps:
  55. - name: Checkout code
  56. uses: actions/checkout@v4
  57. - name: Get changed test files
  58. id: changed-test-files
  59. uses: tj-actions/changed-files@v45
  60. with:
  61. files_yaml: |
  62. test:
  63. - '**/*_test{s,}.py' # Matches files ending with `_test.py` (e.g., `some_module_test.py`, `some_module_tests.py`)
  64. - '**/test{s,}_*.py' # Matches files starting with `test_` (e.g., `test_helper.py`, `tests_helper.py`)
  65. - '**/test{s,}.py' # Matches both `test.py` and `tests.py` (e.g., `some_folder/test.py`, `some_folder/tests.py`)
  66. - '**/*.test.*' # Matches files containing `.test.` anywhere in the name (e.g., `test_file.test.py`, `module.test.js`)
  67. - name: Check if test files were modified
  68. id: check-test-files
  69. run: |
  70. if [[ "${{ steps.changed-test-files.outputs.test_any_changed }}" == "true" ]]; then
  71. echo "comment_message=✅ Test files were modified. Ensure that the tests cover all relevant changes. ✅" >> $GITHUB_ENV
  72. else
  73. echo "comment_message=⚠️ No test files modified. Please ensure that changes are properly tested. ⚠️" >> $GITHUB_ENV
  74. fi
  75. - name: Update PR with test file change status
  76. uses: mshick/add-pr-comment@v2
  77. with:
  78. message: '${{ env.comment_message }}'
  79. allow-repeats: false
  80. ui-tests-and-coverage:
  81. runs-on: ubuntu-latest
  82. steps:
  83. - name: Checkout code
  84. uses: actions/checkout@v4
  85. - name: Cache npm with setup node
  86. uses: actions/setup-node@v4
  87. with:
  88. node-version: 20
  89. cache: 'npm'
  90. - name: Install npm dependencies
  91. run: npm ci
  92. - name: Run js tests with coverage
  93. run: |
  94. # https://jestjs.io/docs/en/troubleshooting.html#tests-are-extremely-slow-on-docker-andor-continuous-integration-ci-server
  95. npm run test-coverage -- --runInBand
  96. - name: Add jest coverage PR comment
  97. uses: MishaKav/jest-coverage-comment@v1
  98. with:
  99. coverage-summary-path: ./reports/jest/coverage-summary.json
  100. summary-title: UI Code Coverage Report
  101. badge-title: Coverage
  102. hide-comment: false
  103. create-new-comment: false
  104. hide-summary: false
  105. coverage-title: Coverage Report