pr-comments.yml 3.3 KB

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