commitflow-py3.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. name: Python 3 CI
  2. on:
  3. push:
  4. branches:
  5. - master
  6. pull_request:
  7. branches:
  8. - master
  9. jobs:
  10. build:
  11. runs-on: ${{ (matrix.python-version == '3.10' || matrix.python-version == '3.11') && 'ubuntu-22.04' || 'ubuntu-20.04' }}
  12. strategy:
  13. matrix:
  14. python-version: ['3.8', '3.9', '3.10', '3.11']
  15. permissions:
  16. pull-requests: write
  17. steps:
  18. - name: Checkout
  19. uses: actions/checkout@v4
  20. with:
  21. fetch-depth: 0
  22. - name: Check commit title format
  23. run: |
  24. ./tools/ci/check_for_commit_message.sh
  25. - name: Set up Python ${{ matrix.python-version }}
  26. uses: actions/setup-python@v5
  27. with:
  28. python-version: ${{ matrix.python-version }}
  29. - name: Cache pip
  30. uses: actions/cache@v4
  31. with:
  32. # This path is specific to Ubuntu
  33. path: ~/.cache/pip
  34. key: ${{ runner.os }}-pip-${{ hashFiles('desktop/core/requirements.txt') }}
  35. restore-keys: |
  36. ${{ runner.os }}-pip-
  37. ${{ runner.os }}-
  38. - name: Setup node 20 and cache npm
  39. uses: actions/setup-node@v4
  40. with:
  41. node-version: 20
  42. cache: 'npm'
  43. - name: Build Hue
  44. run: |
  45. sudo apt-get update
  46. sudo apt-get install -y gcc g++ build-essential python${{ matrix.python-version }}-dev python${{ matrix.python-version }}-venv python${{ matrix.python-version }}-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
  47. sudo curl -sL https://bootstrap.pypa.io/get-pip.py | sudo python${{ matrix.python-version }}
  48. sudo apt-get install -y python3-setuptools
  49. sudo apt-get install -y libncursesw5-dev libgdbm-dev libc6-dev libssl-dev openssl
  50. export PYTHON_VER=python${{ matrix.python-version }}
  51. export ROOT=$PWD
  52. make test_prep
  53. - name: Run python unit tests
  54. run: |
  55. ./build/env/bin/pytest
  56. - name: Upload pytest and code coverage reports
  57. if: matrix.python-version == '3.11'
  58. uses: actions/upload-artifact@v4
  59. with:
  60. name: hue-test-reports
  61. path: ./reports
  62. - name: Add pytest and code coverage PR comment
  63. if: matrix.python-version == '3.11'
  64. uses: MishaKav/pytest-coverage-comment@v1
  65. with:
  66. pytest-xml-coverage-path: ./reports/code-cov/coverage.xml
  67. junitxml-path: ./reports/pytest/test_report.xml
  68. junitxml-title: Pytest Report
  69. title: Backend Code Coverage Report
  70. badge-title: Backend Codecov
  71. report-only-changed-files: true
  72. xml-skip-covered: true
  73. remove-link-from-badge: true
  74. default-branch: master
  75. - name: Check and comment if no unit test files modified
  76. if: matrix.python-version == '3.11'
  77. run: |
  78. git fetch origin master
  79. changed_files=$(git diff --name-only origin/master)
  80. if echo "$changed_files" | grep -qE '(^test|_test\.py|^tests|_tests\.py|.test)'; then
  81. echo "✅ Unit test files were modified."
  82. else
  83. echo "⚠️ No unit test files modified."
  84. curl -X POST \
  85. -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
  86. -H "Accept: application/vnd.github.v3+json" \
  87. -d '{"body":"⚠️ No unit test files modified. Please ensure that changes are properly tested. ⚠️"}' \
  88. "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
  89. fi
  90. - name: Run python lints
  91. run: |
  92. PYTHONWARNINGS=always ./build/env/bin/hue runruff check
  93. - name: Run documentation lints
  94. run: |
  95. curl -O https://dl.google.com/go/go1.23.4.linux-amd64.tar.gz
  96. tar -xvf go1.23.4.linux-amd64.tar.gz
  97. go/bin/go install github.com/raviqqe/muffet/v2@latest
  98. curl --output hugo_0.69.0_Linux.tar.gz -L https://github.com/gohugoio/hugo/releases/download/v0.69.0/hugo_0.69.0_Linux-64bit.tar.gz
  99. tar -xvf hugo_0.69.0_Linux.tar.gz
  100. export PATH=$PWD:$HOME/go/bin:$PATH
  101. # Trigger linting if documentation changes
  102. ./tools/ci/check_for_website_dead_links.sh docs/docs-site
  103. # ./tools/ci/check_for_website_dead_links.sh docs/gethue