From 0e10f51bffedb5a1e872f8f930728171bb9be048 Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sat, 7 Jun 2025 15:42:37 +0200 Subject: [PATCH] fix ci yml --- .gitea/workflows/ci.yml | 161 +++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 83 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 672d700..456dd1b 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -9,88 +9,83 @@ on: jobs: test: runs-on: self-hosted - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' + - name: Checkout code + uses: actions/checkout@v4 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - # Install package in development mode - pip install -e . - # Install test dependencies if they exist - 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 - # Install common test packages - pip install pytest pytest-cov flake8 - - - name: Lint with flake8 - run: | - # Stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # Exit-zero treats all errors as warnings - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - - name: Run tests with pytest - run: | - # Run tests with coverage - python -m pytest tests/ -v --cov=pyWebLayout --cov-report=term-missing --cov-report=json --cov-report=html - - - name: Generate test coverage badge - run: | - # Install coverage-badge for generating badges - pip install coverage-badge - # Generate coverage badge from coverage data - coverage-badge -o coverage.svg - - - name: Check documentation coverage - run: | - # Install interrogate for documentation coverage - pip install interrogate - # 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: Generate coverage reports - run: | - # Generate coverage summary for README - python -c " -import json -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') -" - - - 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')" + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + # Install package in development mode + pip install -e . + # Install test dependencies if they exist + 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 + # Install common test packages + pip install pytest pytest-cov flake8 + + - name: Lint with flake8 + run: | + # Stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # Exit-zero treats all errors as warnings + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Run tests with pytest + run: | + # Run tests with coverage + python -m pytest tests/ -v --cov=pyWebLayout --cov-report=term-missing --cov-report=json --cov-report=html + + - name: Generate test coverage badge + run: | + # Install coverage-badge for generating badges + pip install coverage-badge + # Generate coverage badge from coverage data + coverage-badge -o coverage.svg + + - name: Check documentation coverage + run: | + # Install interrogate for documentation coverage + pip install interrogate + # 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: Generate coverage reports + run: | + # Generate coverage summary for README + python -c " + import json + 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') + " + + - 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')" \ No newline at end of file