fix ci yml
All checks were successful
Python CI / test (push) Successful in 1m14s

This commit is contained in:
Duncan Tourolle 2025-06-07 15:42:37 +02:00
parent c39b9f9eb7
commit 0e10f51bff

View File

@ -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
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies - name: Set up Python
run: | uses: actions/setup-python@v4
python -m pip install --upgrade pip with:
# Install package in development mode python-version: '3.x'
pip install -e .
# Install test dependencies if they exist - name: Install dependencies
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi run: |
if [ -f requirements/test.txt ]; then pip install -r requirements/test.txt; fi python -m pip install --upgrade pip
# Install common test packages # Install package in development mode
pip install pytest pytest-cov flake8 pip install -e .
# Install test dependencies if they exist
- name: Lint with flake8 if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
run: | if [ -f requirements/test.txt ]; then pip install -r requirements/test.txt; fi
# Stop the build if there are Python syntax errors or undefined names # Install common test packages
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics pip install pytest pytest-cov flake8
# Exit-zero treats all errors as warnings
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Lint with flake8
run: |
- name: Run tests with pytest # Stop the build if there are Python syntax errors or undefined names
run: | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# Run tests with coverage # Exit-zero treats all errors as warnings
python -m pytest tests/ -v --cov=pyWebLayout --cov-report=term-missing --cov-report=json --cov-report=html flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Generate test coverage badge - name: Run tests with pytest
run: | run: |
# Install coverage-badge for generating badges # Run tests with coverage
pip install coverage-badge python -m pytest tests/ -v --cov=pyWebLayout --cov-report=term-missing --cov-report=json --cov-report=html
# Generate coverage badge from coverage data
coverage-badge -o coverage.svg - name: Generate test coverage badge
run: |
- name: Check documentation coverage # Install coverage-badge for generating badges
run: | pip install coverage-badge
# Install interrogate for documentation coverage # Generate coverage badge from coverage data
pip install interrogate coverage-badge -o coverage.svg
# 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/ - name: Check documentation coverage
run: |
- name: Generate coverage reports # Install interrogate for documentation coverage
run: | pip install interrogate
# Generate coverage summary for README # Generate documentation coverage report and badge
python -c " 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/
import json
import os - name: Generate coverage reports
run: |
# Read coverage data # Generate coverage summary for README
if os.path.exists('coverage.json'): python -c "
with open('coverage.json', 'r') as f: import json
coverage_data = json.load(f) import os
# Read coverage data
total_coverage = round(coverage_data['totals']['percent_covered'], 1) if os.path.exists('coverage.json'):
with open('coverage.json', 'r') as f:
# Create coverage summary file coverage_data = json.load(f)
with open('coverage-summary.txt', 'w') as f: total_coverage = round(coverage_data['totals']['percent_covered'], 1)
f.write(f'{total_coverage}%') # Create coverage summary file
with open('coverage-summary.txt', 'w') as f:
print(f'Test Coverage: {total_coverage}%') f.write(f'{total_coverage}%')
else: print(f'Test Coverage: {total_coverage}%')
print('No coverage data found') else:
" print('No coverage data found')
"
- name: Upload coverage artifacts
uses: actions/upload-artifact@v3 - name: Upload coverage artifacts
with: uses: actions/upload-artifact@v3
name: coverage-reports with:
path: | name: coverage-reports
coverage.svg path: |
coverage-docs.svg coverage.svg
htmlcov/ coverage-docs.svg
coverage.json htmlcov/
coverage-summary.txt coverage.json
coverage-summary.txt
- name: Test package installation
run: | - name: Test package installation
# Test that the package can be imported run: |
python -c "import pyWebLayout; print('Package imported successfully')" # Test that the package can be imported
python -c "import pyWebLayout; print('Package imported successfully')"