pr-comments.yml 3.5 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-22.04
  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/requirements.txt') }}
  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 gcc g++ build-essential python3.11-dev python3.11-venv python3.11-distutils asciidoc rsync curl sudo libkrb5-dev libldap2-dev libsasl2-dev libxml2-dev libxslt-dev libsasl2-modules-gssapi-mit libsnappy-dev libffi-dev # This should not be needed as some point
  36. sudo curl -sL https://bootstrap.pypa.io/get-pip.py | sudo python3.11
  37. sudo apt-get install -y python3-setuptools
  38. sudo apt-get install -y libncursesw5-dev libgdbm-dev libc6-dev libssl-dev openssl
  39. export PYTHON_VER=python3.11
  40. export ROOT=$PWD
  41. make apps test_prep
  42. - name: Run python unit tests
  43. run: |
  44. ./build/env/bin/pytest
  45. - name: Add pytest and code coverage PR comment
  46. uses: MishaKav/pytest-coverage-comment@v1
  47. with:
  48. pytest-xml-coverage-path: ./reports/code-cov/coverage.xml
  49. junitxml-path: ./reports/pytest/test_report.xml
  50. junitxml-title: Pytest Report
  51. title: Backend Code Coverage Report
  52. badge-title: Backend Codecov
  53. report-only-changed-files: true
  54. xml-skip-covered: true
  55. remove-link-from-badge: true
  56. default-branch: master
  57. python-ut-files-comment:
  58. runs-on: ubuntu-22.04
  59. steps:
  60. - name: Checkout code
  61. uses: actions/checkout@v4
  62. - name: Get changed test files
  63. id: changed-test-files
  64. uses: tj-actions/changed-files@v45
  65. with:
  66. files_yaml: |
  67. test:
  68. - '**/*_test{s,}.py' # Matches files ending with `_test.py` (e.g., `some_module_test.py`, `some_module_tests.py`)
  69. - '**/test{s,}_*.py' # Matches files starting with `test_` (e.g., `test_helper.py`, `tests_helper.py`)
  70. - '**/test{s,}.py' # Matches both `test.py` and `tests.py` (e.g., `some_folder/test.py`, `some_folder/tests.py`)
  71. - '**/*.test.*' # Matches files containing `.test.` anywhere in the name (e.g., `test_file.test.py`, `module.test.js`)
  72. - name: Check if test files were modified
  73. id: check-test-files
  74. run: |
  75. if [[ "${{ steps.changed-test-files.outputs.test_any_changed }}" == "true" ]]; then
  76. echo "comment_message=✅ Test files were modified. Ensure that the tests cover all relevant changes" >> $GITHUB_ENV
  77. else
  78. echo "comment_message=⚠️ No test files modified. Please ensure that changes are properly tested. ⚠️" >> $GITHUB_ENV
  79. fi
  80. - name: Update PR with test file change status
  81. uses: mshick/add-pr-comment@v2
  82. with:
  83. message: "${{ env.comment_message }}"
  84. allow-repeats: false