pr-comments.yml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 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: Check and comment if no unit test files modified
  63. run: |
  64. git fetch origin master
  65. changed_files=$(git diff --name-only origin/master)
  66. if echo "$changed_files" | grep -qE '(^test|_test\.py|^tests|_tests\.py|.test)'; then
  67. echo "✅ Unit test files were modified."
  68. else
  69. echo "⚠️ No unit test files modified."
  70. curl -X POST \
  71. -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
  72. -H "Accept: application/vnd.github.v3+json" \
  73. -d '{"body":"⚠️ No unit test files modified. Please ensure that changes are properly tested. ⚠️"}' \
  74. "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
  75. fi