This commit is contained in:
parent
c39b9f9eb7
commit
0e10f51bff
@ -9,88 +9,83 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
# Install package in development mode
|
# Install package in development mode
|
||||||
pip install -e .
|
pip install -e .
|
||||||
# Install test dependencies if they exist
|
# Install test dependencies if they exist
|
||||||
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
|
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
|
||||||
if [ -f requirements/test.txt ]; then pip install -r requirements/test.txt; fi
|
if [ -f requirements/test.txt ]; then pip install -r requirements/test.txt; fi
|
||||||
# Install common test packages
|
# Install common test packages
|
||||||
pip install pytest pytest-cov flake8
|
pip install pytest pytest-cov flake8
|
||||||
|
|
||||||
- name: Lint with flake8
|
- name: Lint with flake8
|
||||||
run: |
|
run: |
|
||||||
# Stop the build if there are Python syntax errors or undefined names
|
# Stop the build if there are Python syntax errors or undefined names
|
||||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
# Exit-zero treats all errors as warnings
|
# Exit-zero treats all errors as warnings
|
||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
|
|
||||||
- name: Run tests with pytest
|
- name: Run tests with pytest
|
||||||
run: |
|
run: |
|
||||||
# Run tests with coverage
|
# Run tests with coverage
|
||||||
python -m pytest tests/ -v --cov=pyWebLayout --cov-report=term-missing --cov-report=json --cov-report=html
|
python -m pytest tests/ -v --cov=pyWebLayout --cov-report=term-missing --cov-report=json --cov-report=html
|
||||||
|
|
||||||
- name: Generate test coverage badge
|
- name: Generate test coverage badge
|
||||||
run: |
|
run: |
|
||||||
# Install coverage-badge for generating badges
|
# Install coverage-badge for generating badges
|
||||||
pip install coverage-badge
|
pip install coverage-badge
|
||||||
# Generate coverage badge from coverage data
|
# Generate coverage badge from coverage data
|
||||||
coverage-badge -o coverage.svg
|
coverage-badge -o coverage.svg
|
||||||
|
|
||||||
- name: Check documentation coverage
|
- name: Check documentation coverage
|
||||||
run: |
|
run: |
|
||||||
# Install interrogate for documentation coverage
|
# Install interrogate for documentation coverage
|
||||||
pip install interrogate
|
pip install interrogate
|
||||||
# Generate documentation coverage report and badge
|
# Generate documentation coverage report and badge
|
||||||
interrogate -v --ignore-init-method --ignore-init-module --ignore-magic --ignore-private --ignore-property-decorators --ignore-semiprivate --fail-under=80 --generate-badge coverage-docs.svg pyWebLayout/
|
interrogate -v --ignore-init-method --ignore-init-module --ignore-magic --ignore-private --ignore-property-decorators --ignore-semiprivate --fail-under=80 --generate-badge coverage-docs.svg pyWebLayout/
|
||||||
|
|
||||||
- name: Generate coverage reports
|
- name: Generate coverage reports
|
||||||
run: |
|
run: |
|
||||||
# Generate coverage summary for README
|
# Generate coverage summary for README
|
||||||
python -c "
|
python -c "
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
# Read coverage data
|
||||||
|
if os.path.exists('coverage.json'):
|
||||||
|
with open('coverage.json', 'r') as f:
|
||||||
|
coverage_data = json.load(f)
|
||||||
|
total_coverage = round(coverage_data['totals']['percent_covered'], 1)
|
||||||
|
# Create coverage summary file
|
||||||
|
with open('coverage-summary.txt', 'w') as f:
|
||||||
|
f.write(f'{total_coverage}%')
|
||||||
|
print(f'Test Coverage: {total_coverage}%')
|
||||||
|
else:
|
||||||
|
print('No coverage data found')
|
||||||
|
"
|
||||||
|
|
||||||
# Read coverage data
|
- name: Upload coverage artifacts
|
||||||
if os.path.exists('coverage.json'):
|
uses: actions/upload-artifact@v3
|
||||||
with open('coverage.json', 'r') as f:
|
with:
|
||||||
coverage_data = json.load(f)
|
name: coverage-reports
|
||||||
|
path: |
|
||||||
|
coverage.svg
|
||||||
|
coverage-docs.svg
|
||||||
|
htmlcov/
|
||||||
|
coverage.json
|
||||||
|
coverage-summary.txt
|
||||||
|
|
||||||
total_coverage = round(coverage_data['totals']['percent_covered'], 1)
|
- name: Test package installation
|
||||||
|
run: |
|
||||||
# Create coverage summary file
|
# Test that the package can be imported
|
||||||
with open('coverage-summary.txt', 'w') as f:
|
python -c "import pyWebLayout; print('Package imported successfully')"
|
||||||
f.write(f'{total_coverage}%')
|
|
||||||
|
|
||||||
print(f'Test Coverage: {total_coverage}%')
|
|
||||||
else:
|
|
||||||
print('No coverage data found')
|
|
||||||
"
|
|
||||||
|
|
||||||
- name: Upload coverage artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: coverage-reports
|
|
||||||
path: |
|
|
||||||
coverage.svg
|
|
||||||
coverage-docs.svg
|
|
||||||
htmlcov/
|
|
||||||
coverage.json
|
|
||||||
coverage-summary.txt
|
|
||||||
|
|
||||||
- name: Test package installation
|
|
||||||
run: |
|
|
||||||
# Test that the package can be imported
|
|
||||||
python -c "import pyWebLayout; print('Package imported successfully')"
|
|
||||||
Loading…
x
Reference in New Issue
Block a user