| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- name: PR Comments
- on:
- pull_request:
- branches:
- - master
- jobs:
- backend-tests-and-coverage:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- - name: Set up Python 3.11
- uses: actions/setup-python@v5
- with:
- python-version: 3.11
- - name: Cache pip
- uses: actions/cache@v4
- with:
- # This path is specific to Ubuntu
- path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('desktop/core/generate_requirements.py') }}
- restore-keys: |
- ${{ runner.os }}-pip-
- ${{ runner.os }}-
- - name: Setup node 20 and cache npm
- uses: actions/setup-node@v4
- with:
- node-version: 20
- cache: 'npm'
- - name: Build Hue
- run: |
- sudo apt-get update
- sudo apt-get install -y build-essential asciidoc libkrb5-dev libldap2-dev libsasl2-dev libxslt-dev libsasl2-modules-gssapi-mit libsnappy-dev libgdbm-dev
- export PYTHON_VER=python3.11
- export SKIP_PYTHONDEV_CHECK=true
- export ROOT=$PWD
- make apps test_prep
- - name: Run python unit tests
- continue-on-error: true
- run: |
- ./build/env/bin/pytest
- - name: Add pytest and code coverage PR comment
- uses: MishaKav/pytest-coverage-comment@v1
- with:
- pytest-xml-coverage-path: ./reports/code-cov/coverage.xml
- title: Backend Code Coverage Report
- badge-title: Coverage
- report-only-changed-files: true
- xml-skip-covered: true
- remove-link-from-badge: true
- default-branch: master
- python-ut-files-check:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- - name: Get changed test files
- id: changed-test-files
- uses: tj-actions/changed-files@v45
- with:
- files_yaml: |
- test:
- - '**/*_test{s,}.py' # Matches files ending with `_test.py` (e.g., `some_module_test.py`, `some_module_tests.py`)
- - '**/test{s,}_*.py' # Matches files starting with `test_` (e.g., `test_helper.py`, `tests_helper.py`)
- - '**/test{s,}.py' # Matches both `test.py` and `tests.py` (e.g., `some_folder/test.py`, `some_folder/tests.py`)
- - '**/*.test.*' # Matches files containing `.test.` anywhere in the name (e.g., `test_file.test.py`, `module.test.js`)
- - name: Check if test files were modified
- id: check-test-files
- run: |
- if [[ "${{ steps.changed-test-files.outputs.test_any_changed }}" == "true" ]]; then
- echo "comment_message=✅ Test files were modified. Ensure that the tests cover all relevant changes. ✅" >> $GITHUB_ENV
- else
- echo "comment_message=⚠️ No test files modified. Please ensure that changes are properly tested. ⚠️" >> $GITHUB_ENV
- fi
- - name: Update PR with test file change status
- uses: mshick/add-pr-comment@v2
- with:
- message: '${{ env.comment_message }}'
- allow-repeats: false
- ui-tests-and-coverage:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- - name: Cache npm with setup node
- uses: actions/setup-node@v4
- with:
- node-version: 20
- cache: 'npm'
- - name: Install npm dependencies
- run: npm ci
- - name: Run js tests with coverage
- run: |
- # https://jestjs.io/docs/en/troubleshooting.html#tests-are-extremely-slow-on-docker-andor-continuous-integration-ci-server
- npm run test-coverage -- --runInBand
- - name: Add jest coverage PR comment
- uses: MishaKav/jest-coverage-comment@v1
- with:
- coverage-summary-path: ./reports/jest/coverage-summary.json
- summary-title: UI Code Coverage Report
- badge-title: Coverage
- hide-comment: false
- create-new-comment: false
- hide-summary: false
- coverage-title: Coverage Report
|