File: test.yml

package info (click to toggle)
debsbom 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,248 kB
  • sloc: python: 5,965; makefile: 31
file content (117 lines) | stat: -rw-r--r-- 3,076 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Copyright (C) 2025 Siemens
#
# SPDX-License-Identifier: MIT

name: Tests

on:
  push:
    branches:
    - main
  pull_request:

jobs:
  test-minimal-deps:
    runs-on: ubuntu-24.04
    strategy:
      matrix:
        sbom-type: ["cdx", "spdx"]
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-python@v5
        with:
          python-version: 3.14

      - name: Install required dependencies for ${{ matrix.sbom-type }}
        shell: bash
        run: |
          python -m pip install --upgrade pip
          pip install .[${{ matrix.sbom-type }}]

      - name: Test the generate command with minimal dependencies for ${{ matrix.sbom-type }}
        shell: bash
        run: $(which debsbom) -v generate -t ${{ matrix.sbom-type }} -o sbom --root tests/root/tree --validate

      - name: Install test dependencies for ${{ matrix.sbom-type }}
        shell: bash
        run: pip install .[mindev]
      - name: Test pytest for subset ${{ matrix.sbom-type }}
        shell: bash
        run: pytest

  test:
    runs-on: ubuntu-24.04
    strategy:
      matrix:
        python-version: ["3.11", "3.12", "3.13", "3.14"]
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}

      - uses: ./.github/actions/pytest
        with:
          artifact-identifier: "${{ matrix.python-version }}"

  test-python-apt:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v5
      - name: Check if python-apt is available
        run: python -c "import apt"
      - uses: ./.github/actions/pytest
        with:
          artifact-identifier: "python-apt"

  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() }}