| 1 |
name: "Test" |
| 2 |
description: "Run pytest" |
| 3 |
inputs: |
| 4 |
artifact-identifier: |
| 5 |
description: "Unique identifier for uploaded artifacts" |
| 6 |
required: true |
| 7 |
|
| 8 |
runs: |
| 9 |
using: "composite" |
| 10 |
steps: |
| 11 |
- name: Install dev dependencies |
| 12 |
shell: bash |
| 13 |
run: | |
| 14 |
python -m pip install --upgrade pip |
| 15 |
pip install .[dev] |
| 16 |
|
| 17 |
- name: Run pytest |
| 18 |
env: |
| 19 |
COVERAGE_FILE: .coverage.test.${{ inputs.artifact-identifier }} |
| 20 |
shell: bash |
| 21 |
run: pytest --cov debsbom |
| 22 |
|
| 23 |
- name: smoke test generate |
| 24 |
shell: bash |
| 25 |
env: |
| 26 |
COVERAGE_FILE: .coverage.smoke-generate.${{ inputs.artifact-identifier }} |
| 27 |
run: | |
| 28 |
coverage run $(which debsbom) -v generate -t spdx -t cdx -o sbom --validate |
| 29 |
|
| 30 |
- name: smoke test merge |
| 31 |
shell: bash |
| 32 |
run: | |
| 33 |
export COVERAGE_FILE=".coverage.merge.spdx.${{ inputs.artifact-identifier }}" |
| 34 |
coverage run $(which debsbom) -v merge --validate tests/data/merge-full.spdx.json tests/data/merge-minimal.spdx.json |
| 35 |
export COVERAGE_FILE=".coverage.merge.cdx.${{ inputs.artifact-identifier }}" |
| 36 |
coverage run $(which debsbom) -v merge --validate tests/data/merge-full.cdx.json tests/data/merge-minimal.cdx.json |
| 37 |
|
| 38 |
- name: test repack flow |
| 39 |
shell: bash |
| 40 |
run: | |
| 41 |
# run repack against known data |
| 42 |
export COVERAGE_FILE=".coverage.generate2.${{ inputs.artifact-identifier }}" |
| 43 |
coverage run $(which debsbom) -v generate -t spdx -o sbom-rp --root tests/root/tree --validate |
| 44 |
export COVERAGE_FILE=".coverage.smoke-download2.${{ inputs.artifact-identifier }}" |
| 45 |
coverage run $(which debsbom) -v download --sources --binaries sbom-rp.spdx.json |
| 46 |
export COVERAGE_FILE=".coverage.smoke-source-merge.${{ inputs.artifact-identifier }}" |
| 47 |
coverage run $(which debsbom) -v source-merge sbom-rp.spdx.json |
| 48 |
export COVERAGE_FILE=".coverage.smoke-repack.${{ inputs.artifact-identifier }}" |
| 49 |
coverage run $(which debsbom) -v repack sbom-rp.spdx.json sbom-rp.repacked.spdx.json |
| 50 |
grep -q "file:///sources/" sbom-rp.repacked.spdx.json |
| 51 |
export COVERAGE_FILE=".coverage.smoke-export.${{ inputs.artifact-identifier }}" |
| 52 |
coverage run $(which debsbom) -v export sbom-rp.spdx.json |
| 53 |
|
| 54 |
- name: smoke test delta |
| 55 |
shell: bash |
| 56 |
run: | |
| 57 |
export COVERAGE_FILE=".coverage.delta.spdx.${{ inputs.artifact-identifier }}" |
| 58 |
coverage run $(which debsbom) -v delta --validate tests/data/delta-base.spdx.json tests/data/delta-target.spdx.json |
| 59 |
export COVERAGE_FILE=".coverage.delta.cdx.${{ inputs.artifact-identifier }}" |
| 60 |
coverage run $(which debsbom) -v delta --validate tests/data/delta-base.cdx.json tests/data/delta-target.cdx.json |
| 61 |
|
| 62 |
- name: smoke test trace-path |
| 63 |
shell: bash |
| 64 |
run: | |
| 65 |
export COVERAGE_FILE=".coverage.tracepath.spdx.${{ inputs.artifact-identifier }}" |
| 66 |
coverage run $(which debsbom) -v --json trace-path tests/data/delta-base.spdx.json 'pkg:deb/debian/[email protected]%2Bb7?arch=amd64' |
| 67 |
export COVERAGE_FILE=".coverage.tracepath.cdx.${{ inputs.artifact-identifier }}" |
| 68 |
coverage run $(which debsbom) -v --json trace-path tests/data/delta-base.cdx.json 'pkg:deb/debian/[email protected]%2Bb7?arch=amd64' |
| 69 |
|
| 70 |
- name: smoke test filter |
| 71 |
shell: bash |
| 72 |
run: | |
| 73 |
export COVERAGE_FILE=".coverage.smoke-filter.spdx.source.${{ inputs.artifact-identifier }}" |
| 74 |
coverage run $(which debsbom) -v filter -t spdx --sources tests/data/filter.spdx.json filtered_sources.spdx.json |
| 75 |
export COVERAGE_FILE=".coverage.smoke-filter.spdx.binary.${{ inputs.artifact-identifier }}" |
| 76 |
coverage run $(which debsbom) -v filter -t spdx --binaries tests/data/filter.spdx.json filtered_binaries.spdx.json |
| 77 |
export COVERAGE_FILE=".coverage.smoke-filter.cdx.source.${{ inputs.artifact-identifier }}" |
| 78 |
coverage run $(which debsbom) -v filter -t cdx --sources tests/data/filter.cdx.json filtered_sources.cdx.json |
| 79 |
export COVERAGE_FILE=".coverage.smoke-filter.cdx.binary.${{ inputs.artifact-identifier }}" |
| 80 |
coverage run $(which debsbom) -v filter -t cdx --binaries tests/data/filter.cdx.json filtered_binaries.cdx.json |
| 81 |
export COVERAGE_FILE=".coverage.smoke-filter.spdx.package.${{ inputs.artifact-identifier }}" |
| 82 |
coverage run $(which debsbom) -v filter -t spdx --package dash tests/data/filter.spdx.json filtered_pkgs.spdx.json |
| 83 |
export COVERAGE_FILE=".coverage.smoke-filter.cdx.package.${{ inputs.artifact-identifier }}" |
| 84 |
coverage run $(which debsbom) -v filter -t cdx --package dash tests/data/filter.cdx.json filtered_pkgs.cdx.json |
| 85 |
|
| 86 |
DISTRO_ARCH="$(dpkg --print-architecture)" |
| 87 |
export COVERAGE_FILE=".coverage.smoke-filter.cdx.pipe.${{ inputs.artifact-identifier }}" |
| 88 |
$(which debsbom) -v generate --distro-arch $DISTRO_ARCH --root tests/root/tree -t cdx -o - | coverage run $(which debsbom) filter --package binutils --sbom-type cdx - filtered_stdin.cdx.json |
| 89 |
export COVERAGE_FILE=".coverage.smoke-filter.spdx.pipe.${{ inputs.artifact-identifier }}" |
| 90 |
$(which debsbom) -v generate --distro-arch $DISTRO_ARCH --root tests/root/tree -t spdx -o - | coverage run $(which debsbom) filter --package binutils --sbom-type spdx - filtered_stdin.spdx.json |
| 91 |
|
| 92 |
- name: smoke test sec-scan |
| 93 |
shell: bash |
| 94 |
run: | |
| 95 |
export COVERAGE_FILE=".coverage.secscan.${{ inputs.artifact-identifier }}" |
| 96 |
echo 'pkg:deb/debian/[email protected]?arch=source' | coverage run $(which debsbom) -v --json sec-scan --db tests/data/security-tracker.fake.json |
| 97 |
export COVERAGE_FILE=".coverage.secscan.${{ inputs.artifact-identifier }}" |
| 98 |
echo 'pkg:deb/debian/[email protected]?arch=source' | coverage run $(which debsbom) -v --json sec-scan --with-paths-to-root --db tests/data/security-tracker.fake.json |
| 99 |
export COVERAGE_FILE=".coverage.secscan.vex.${{ inputs.artifact-identifier }}" |
| 100 |
echo 'pkg:deb/debian/[email protected]?arch=source' | coverage run $(which debsbom) -v sec-scan --author "Test <[email protected]>" --format vex --db tests/data/security-tracker.fake.json |
| 101 |
export COVERAGE_FILE=".coverage.secscan.sarif.${{ inputs.artifact-identifier }}" |
| 102 |
echo 'pkg:deb/debian/[email protected]?arch=source' | coverage run $(which debsbom) -v sec-scan --format sarif --db tests/data/security-tracker.fake.json |
| 103 |
|
| 104 |
- name: upload smoke test SBOMs |
| 105 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 106 |
with: |
| 107 |
name: sbom-${{ inputs.artifact-identifier }} |
| 108 |
path: | |
| 109 |
sbom.cdx.json |
| 110 |
sbom.spdx.json |
| 111 |
if-no-files-found: error |
| 112 |
|
| 113 |
- name: Upload coverage data |
| 114 |
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 115 |
with: |
| 116 |
name: coverage-data-tests-${{ inputs.artifact-identifier }} |
| 117 |
path: .coverage.* |
| 118 |
include-hidden-files: true |
| 119 |
if-no-files-found: error |
| 120 |
|