Skip to content

test: turn Python warnings into errors during test #305

test: turn Python warnings into errors during test

test: turn Python warnings into errors during test #305

Workflow file for this run

# Copyright (C) 2025 Siemens
#
# SPDX-License-Identifier: MIT
name: Tests
on:
push:
jobs:
test:
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Run pytest
env:
COVERAGE_FILE: .coverage.test.${{matrix.python-version }}
run: pytest --cov debsbom
- name: smoke test generate
env:
COVERAGE_FILE: .coverage.smoke.${{matrix.python-version }}
run: coverage run $(which debsbom) -v generate -t spdx -t cdx -o sbom --validate
- name: upload smoke test SBOMs
uses: actions/upload-artifact@v4
with:
name: sbom-${{ matrix.python-version }}
path: |
sbom.cdx.json
sbom.spdx.json
if-no-files-found: error
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-tests-${{ matrix.python-version }}
path: .coverage.*
include-hidden-files: true
if-no-files-found: error
coverage:
name: Check coverage
needs: test
runs-on: ubuntu-24.04
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13
- name: Install dependencies
run: |
python -m pip install --upgrade coverage[toml]
pip install .[dev]
- name: Download coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-data-*
merge-multiple: true
- name: Check coverage and fail it it’s under 85%
run: |
cat >.coveragerc <<EOF
[run]
source = debsbom
[paths]
source =
src/debsbom
*/site-packages/debsbom
*/runner/work/debsbom/src/debsbom
EOF
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
# Report and write to summary.
python -m coverage report | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY
# Report again and fail if under 85%.
python -Im coverage report --fail-under=85
- name: Upload HTML report if check failed
uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov
if: ${{ failure() }}
docs:
name: Docs
runs-on: ubuntu-24.04
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Build HTML docs
run: |
cd docs
make html