pr-comments.yml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. name: PR Comments
  2. on:
  3. pull_request:
  4. branches:
  5. - master
  6. permissions:
  7. contents: write
  8. checks: write
  9. pull-requests: write
  10. jobs:
  11. pytest-codecov-comment:
  12. runs-on: ubuntu-22.04
  13. steps:
  14. - name: Checkout code
  15. uses: actions/checkout@v4
  16. - name: Set up Python 3.11
  17. uses: actions/setup-python@v5
  18. with:
  19. python-version: 3.11
  20. - name: Cache pip
  21. uses: actions/cache@v4
  22. with:
  23. # This path is specific to Ubuntu
  24. path: ~/.cache/pip
  25. key: ${{ runner.os }}-pip-${{ hashFiles('desktop/core/requirements.txt') }}
  26. restore-keys: |
  27. ${{ runner.os }}-pip-
  28. ${{ runner.os }}-
  29. - name: Setup node 20 and cache npm
  30. uses: actions/setup-node@v4
  31. with:
  32. node-version: 20
  33. cache: 'npm'
  34. - name: Build Hue
  35. run: |
  36. sudo apt-get update
  37. 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
  38. sudo curl -sL https://bootstrap.pypa.io/get-pip.py | sudo python3.11
  39. sudo apt-get install -y python3-setuptools
  40. sudo apt-get install -y libncursesw5-dev libgdbm-dev libc6-dev libssl-dev openssl
  41. export PYTHON_VER=python3.11
  42. export ROOT=$PWD
  43. make test_prep
  44. - name: Run python unit tests
  45. run: |
  46. ./build/env/bin/pytest
  47. - name: Add pytest and code coverage PR comment
  48. uses: MishaKav/pytest-coverage-comment@v1
  49. with:
  50. pytest-xml-coverage-path: ./reports/code-cov/coverage.xml
  51. junitxml-path: ./reports/pytest/test_report.xml
  52. junitxml-title: Pytest Report
  53. title: Backend Code Coverage Report
  54. badge-title: Backend Codecov
  55. report-only-changed-files: true
  56. xml-skip-covered: true
  57. remove-link-from-badge: true
  58. default-branch: master
  59. ut-files-comment:
  60. runs-on: ubuntu-22.04
  61. steps:
  62. - name: Checkout code
  63. uses: actions/checkout@v4
  64. - name: Check and comment if no unit test files modified
  65. run: |
  66. git fetch origin master
  67. changed_files=$(git diff --name-only origin/master)
  68. if echo "$changed_files" | grep -qE '(^test|_test\.py|^tests|_tests\.py|.test)'; then
  69. echo "✅ Unit test files were modified."
  70. else
  71. echo "⚠️ No unit test files modified."
  72. curl -X POST \
  73. -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
  74. -H "Accept: application/vnd.github.v3+json" \
  75. -d '{"body":"⚠️ No unit test files modified. Please ensure that changes are properly tested. ⚠️"}' \
  76. "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
  77. fi