Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 123 additions & 3 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

- name: Run tests with coverage
run: |
python -m pytest tests/ -n auto --cov=src/bluetooth_sig --cov-report=html --cov-report=xml --cov-report=term-missing --cov-fail-under=70
python -m pytest tests/ -n auto --ignore=tests/benchmarks/ --cov=src/bluetooth_sig --cov-report=html --cov-report=xml --cov-report=term-missing --cov-fail-under=70

- name: Extract coverage percentage and create badge
if: matrix.python-version == '3.12'
Expand All @@ -78,9 +78,102 @@ jobs:
path: htmlcov
retention-days: 30

benchmark:
name: Performance Benchmarks
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/checkout@v5
with:
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: 'pyproject.toml'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[test]"

- name: Set consistent Python hash seed
run: echo "PYTHONHASHSEED=0" >> $GITHUB_ENV

- name: Run benchmarks
run: |
export PYTHONPATH=$GITHUB_WORKSPACE/src:$PYTHONPATH
python -m pytest tests/benchmarks/ \
--benchmark-only \
--benchmark-json=benchmark.json \
--benchmark-columns=min,max,mean,stddev \
--benchmark-sort=name

- name: Download previous benchmark data
uses: dawidd6/action-download-artifact@v9
if: github.event_name == 'pull_request'
continue-on-error: true
with:
name: benchmark-results
workflow: test-coverage.yml
branch: main
path: previous-benchmarks

- name: Compare with baseline
uses: benchmark-action/github-action-benchmark@v1
if: github.event_name == 'pull_request'
with:
name: 'Python Benchmarks'
tool: 'pytest'
output-file-path: benchmark.json
github-token: ${{ secrets.GITHUB_TOKEN }}
external-data-json-path: previous-benchmarks/benchmark.json
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
summary-always: true

- name: Download previous benchmark history
uses: dawidd6/action-download-artifact@v9
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
continue-on-error: true
with:
name: benchmark-history
workflow: test-coverage.yml
branch: main
path: benchmark-history

- name: Update benchmark history
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
python scripts/update_benchmark_history.py \
benchmark.json \
benchmark-history/history.json

- name: Upload benchmark results
uses: actions/upload-artifact@v5
with:
name: benchmark-results
path: benchmark.json
retention-days: 90

- name: Upload benchmark history
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v5
with:
name: benchmark-history
path: benchmark-history/history.json
retention-days: 90

build-docs:
name: Build Documentation
needs: test
needs: [test, benchmark]
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
Expand Down Expand Up @@ -120,12 +213,28 @@ jobs:


- name: Download coverage artifacts
uses: actions/download-artifact@v6
uses: actions/download-artifact@v5
with:
name: coverage-report
path: htmlcov
continue-on-error: true

- name: Download benchmark artifacts
uses: actions/download-artifact@v5
with:
name: benchmark-results
path: benchmarks
continue-on-error: true

- name: Download benchmark history
uses: dawidd6/action-download-artifact@v9
continue-on-error: true
with:
name: benchmark-history
workflow: test-coverage.yml
branch: main
path: benchmarks

- name: Link coverage into docs directory
run: |
if [ -d "htmlcov" ]; then
Expand All @@ -137,6 +246,17 @@ jobs:
echo "⚠️ No coverage reports found, docs will build without coverage"
fi

- name: Link benchmarks into docs directory
run: |
if [ -f "benchmarks/benchmark.json" ]; then
echo "✅ Benchmark results found, linking to docs/"
mkdir -p docs/benchmarks
cp benchmarks/benchmark.json docs/benchmarks/
ls -la docs/benchmarks/
else
echo "⚠️ No benchmark results found, docs will build without benchmarks"
fi

- name: Build documentation
run: |
mkdocs build
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,8 @@ docs/diagrams/.cache/
AGENTS.md
.serena/

.lint*/
.lint*/

# Benchmark results
benchmark.json
docs/benchmarks/*.json
Loading
Loading