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